> ## Documentation Index
> Fetch the complete documentation index at: https://docs.forest.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Forest CLI

> Command-line tool for managing your Forest projects, branches, environments, and deployments

# Forest CLI

The Forest CLI (`forest`) is a command-line tool that lets you manage your Forest layout changes throughout your development workflow, from local development to production deployment.

## Installation

```bash theme={null}
npm install -g forest-cli
```

You can verify the installation with:

```bash theme={null}
forest --version
```

> [!NOTE]
>
> The Forest CLI requires **Node.js >= 18.0.0**.

## Getting started

Once installed, authenticate with your Forest account:

```bash theme={null}
forest login
```

Then initialize your development environment from your project directory:

```bash theme={null}
forest init
```

## Commands

### Authentication

| Command | Description |
| - | - |
| [`forest login`](https://docs.forest.app/reference/cli/login) | Sign in to your Forest account |
| `forest logout` | Sign out of your account |
| `forest user` | Display the currently logged-in user |

### Branch management

| Command | Description |
| - | - |
| [`forest branch`](https://docs.forest.app/reference/cli/branch) | Create a branch or list existing branches |
| [`forest switch`](https://docs.forest.app/reference/cli/switch) | Switch to a different branch |
| `forest set-origin` | Set an environment as your branch's origin |

### Deployment

| Command | Description |
| - | - |
| [`forest push`](https://docs.forest.app/reference/cli/push) | Push layout changes from your branch to its origin environment |
| [`forest deploy`](https://docs.forest.app/reference/cli/deploy) | Deploy layout changes to the production (reference) environment |

### Environment management

| Command | Description |
| - | - |
| `forest environments` | List all environments |
| `forest environments:create` | Create a new environment |
| `forest environments:delete` | Delete an environment |
| `forest environments:update` | Update an environment |
| `forest environments:reset` | Reset all layout changes on a remote environment |

### Project management

| Command | Description |
| - | - |
| `forest projects` | List all projects |
| `forest projects:get` | Get a project's configuration |

### Roles and teams

| Command | Description |
| - | - |
| `forest roles:copy` | Copy role permissions from one environment to another with the same schema |
| `forest roles:export` | Export every role's permissions on one environment to a CSV file |
| `forest roles:apply <file>` | Apply a CSV of role permissions to an environment, after showing the changes |
| `forest teams:copy-layout` | Copy one team's layout onto another in the same project, overwriting it |

```bash theme={null}
forest roles:copy --from production --to staging
```

`roles:copy` runs once per pair of environments, however many teams you have. Between environments whose schemas differ, such as a legacy agent's and a new one's, use `roles:export` and `roles:apply`, which match permissions by collection and action name.

### Schema

| Command | Description |
| - | - |
| `forest schema:apply` | Apply your local schema to a specific environment |
| `forest schema:diff` | Compare the schemas of two environments |
| `forest schema:update` | Refresh your schema by generating missing files |

## Development workflow

A typical development workflow with the Forest CLI looks like this:

1. **Create a branch** to isolate your layout changes:
   ```bash theme={null}
   forest branch feature/my-feature --origin production
   ```

2. **Work locally**, make layout changes in your Forest UI connected to your development environment.

3. **Push your changes** to a staging or test environment for review:
   ```bash theme={null}
   forest push
   ```

4. **Deploy to production** once changes are validated:
   ```bash theme={null}
   forest deploy
   ```

## Docker usage

You can also run the CLI via Docker without installing it locally:

```bash theme={null}
docker run --rm --init -it \
  -v `pwd`:/usr/src/app \
  -v ~/.forest.d:/usr/src/cli/.forest.d \
  -e TOKEN_PATH="/usr/src/cli" \
  forestadmin/toolbelt:latest [command]
```

## Global options

All commands support the following options:

| Option | Description |
| - | - |
| `--help` | Display usage information for the command |
| `--version` | Show the CLI version |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.