> ## Documentation Index
> Fetch the complete documentation index at: https://forest-docs-cli-reference-headless-commands.mintlify.site/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
```

<Info>
  The Forest CLI requires **Node.js >= 18.0.0**.
</Info>

## 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`](/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`](/reference/cli/branch) | Create a branch or list existing branches  |
| [`forest switch`](/reference/cli/switch) | Switch to a different branch               |
| `forest set-origin`                      | Set an environment as your branch's origin |

### Deployment

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

### Environments

| Command                                                            | Description                                      |
| ------------------------------------------------------------------ | ------------------------------------------------ |
| `forest environments`                                              | List all environments                            |
| [`forest environments:create`](/reference/cli/environments-create) | Create a new environment                         |
| [`forest environments:get`](/reference/cli/environments-get)       | Get an environment's configuration               |
| [`forest environments:update`](/reference/cli/environments-update) | Update an environment                            |
| [`forest environments:delete`](/reference/cli/environments-delete) | Delete an environment                            |
| [`forest environments:reset`](/reference/cli/environments-reset)   | Reset all layout changes on a remote environment |

### Projects

| Command                                                                | Description                                     |
| ---------------------------------------------------------------------- | ----------------------------------------------- |
| `forest projects`                                                      | List all projects                               |
| `forest projects:get`                                                  | Get a project's configuration                   |
| [`forest projects:create:demo`](/reference/cli/projects-create-demo)   | Create a project with a zero-DB demo datasource |
| [`forest projects:create:sql`](/reference/cli/projects-create-sql)     | Create a project from a SQL database            |
| [`forest projects:create:nosql`](/reference/cli/projects-create-nosql) | Create a project from a NoSQL (Mongo) database  |

### Layout

| Command                                              | Description                                                         |
| ---------------------------------------------------- | ------------------------------------------------------------------- |
| [`forest layout:pull`](/reference/cli/layout-pull)   | Pull an environment's layout into a `forest-layout.json` file       |
| [`forest layout:apply`](/reference/cli/layout-apply) | Apply a `forest-layout.json` to an environment                      |
| [`forest layout:patch`](/reference/cli/layout-patch) | Patch the layout directly (single PATCH per domain, like the front) |

### Workflows

| Command                                                  | Description                                                             |
| -------------------------------------------------------- | ----------------------------------------------------------------------- |
| [`forest workflow:apply`](/reference/cli/workflow-apply) | Create or update a workflow from a JSON `steps` spec (compiles to BPMN) |

### Roles

| Command                                              | Description                                                   |
| ---------------------------------------------------- | ------------------------------------------------------------- |
| [`forest roles:create`](/reference/cli/roles-create) | Create a role                                                 |
| [`forest roles:apply`](/reference/cli/roles-apply)   | Apply a wide-format CSV of role permissions to an environment |
| [`forest roles:copy`](/reference/cli/roles-copy)     | Copy roles between environments                               |
| [`forest roles:export`](/reference/cli/roles-export) | Export an environment's roles to a CSV                        |

### Teams

| Command                                                        | Description                          |
| -------------------------------------------------------------- | ------------------------------------ |
| [`forest teams:create`](/reference/cli/teams-create)           | Create a team                        |
| [`forest teams:delete`](/reference/cli/teams-delete)           | Delete a team                        |
| [`forest teams:copy-layout`](/reference/cli/teams-copy-layout) | Copy a team's layout to another team |

### Users

| Command                                              | Description                                    |
| ---------------------------------------------------- | ---------------------------------------------- |
| [`forest users:list`](/reference/cli/users-list)     | List the users of a project                    |
| [`forest users:invite`](/reference/cli/users-invite) | Invite users to a project                      |
| [`forest users:edit`](/reference/cli/users-edit)     | Edit a user's role, teams, or permission level |

### 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                      |
