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
Options
| Option | Description |
|---|---|
-p, --projectId | The ID of the project to initialize |
What it does
forest init is an interactive wizard that:
- Authenticates you if you are not already logged in
- Selects the Forest project to connect to
- Configures your local agent endpoint (host and port)
- Creates your Development Environment on Forest
- Optionally sets up your database connection
- Creates or updates your
.envfile with the required environment variables
Run
forest init from your project’s root directory, the same directory where your agent code lives.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.
Project selection
If your account is linked to multiple projects, you will be asked to select the one matching your current codebase:Endpoint configuration
Forest needs to know where your local agent is running to set up the Development Environment:http://localhost:3310) or provide a custom URL.
Database configuration (optional)
forest init will offer to set up your DATABASE_URL if it is not already configured:
.env file.
Environment variables
After a successfulforest 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) |
The
FOREST_ENV_SECRET uniquely identifies your Development Environment. Keep this value private and do not share it.Example
Troubleshooting
Not logged in Runforest 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.