> ## Documentation Index
> Fetch the complete documentation index at: https://forest-chore-open-api.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# forest init

> Set up your Forest development environment in your current project directory

# forest init

Set up your development environment in your current project directory. This command configures your local Forest environment, linking your codebase to a project on Forest.

## Usage

```bash theme={null}
forest init [options]
```

## Options

| Option            | Description                         |
| ----------------- | ----------------------------------- |
| `-p, --projectId` | The ID of the project to initialize |

## What it does

`forest init` is an interactive wizard that:

1. Authenticates you if you are not already logged in
2. Selects the Forest project to connect to
3. Configures your local agent endpoint (host and port)
4. Creates your **Development Environment** on Forest
5. Optionally sets up your database connection
6. Creates or updates your `.env` file with the required environment variables

<Warning>
  `forest init` is not meant to create a new project from scratch. If you do not have an existing Forest project yet, create one from the UI first.
</Warning>

<Info>
  Run `forest init` from your project's **root directory**, the same directory where your agent code lives.
</Info>

## Interactive prompts

### Authentication

If you are not already logged in, `forest init` will prompt for your credentials. You can also authenticate beforehand with [`forest login`](/reference/cli/login).

### Project selection

If your account is linked to multiple projects, you will be asked to select the one matching your current codebase:

```
? Select your project:
  ❯ My CRM Admin
    Internal Operations Tool
    Customer Support Panel
```

If your account has only one project, this step is skipped automatically.

### Endpoint configuration

Forest needs to know where your local agent is running to set up the Development Environment:

```
? Enter your local admin backend endpoint: (http://localhost:3310)
```

Press **Enter** to accept the default (`http://localhost:3310`) or provide a custom URL.

<Tip>
  Your Development Environment is created as soon as you confirm the endpoint. 🎉
</Tip>

### Database configuration (optional)

`forest init` will offer to set up your `DATABASE_URL` if it is not already configured:

```
? You don't have a DATABASE_URL yet. Do you need help setting it? (Y/n)
```

If you accept, you will be guided through entering your database credentials, which will be written to your `.env` file.

## Environment variables

After a successful `forest init`, the following variables are added to your `.env` file:

| Variable            | Description                                         |
| ------------------- | --------------------------------------------------- |
| `FOREST_ENV_SECRET` | Secret key identifying your Development Environment |
| `DATABASE_URL`      | Your database connection string (if configured)     |

<Info>
  The `FOREST_ENV_SECRET` uniquely identifies your Development Environment. Keep this value private and do not share it.
</Info>

## Example

```bash theme={null}
$ cd my-forest-admin-project
$ forest init

? Select your project: My CRM Admin
? Enter your local admin backend endpoint: (http://localhost:3310)
✅ Development Environment created!
? You don't have a DATABASE_URL yet. Do you need help setting it? Yes
...
✅ Your .env file has been updated.
```

## Troubleshooting

**Not logged in**
Run [`forest login`](/reference/cli/login) first, or let `forest init` handle authentication interactively.

**Project not found**
Ensure your Forest account has access to the project. Contact your project admin if needed.

**Endpoint unreachable**
Make sure your local agent is running before confirming the endpoint. Forest will attempt to reach it during setup.
