Interactive Setup
The m3-forge init command provides an interactive setup wizard to configure your M3 Forge environment. It generates a .env file with all required configuration values.
Quick Start
# Interactive mode - step through each configuration section
m3-forge init --interactive
# Quick mode - generate .env with all defaults
m3-forge init --defaultsCommand Options
| Option | Short | Description |
|---|---|---|
--interactive | -i | Run the interactive setup wizard |
--defaults | Accept all defaults without prompting | |
--config <path> | -c | Use a custom YAML configuration file |
--force | -f | Overwrite existing .env file (creates backup) |
Setup Modes
Interactive Mode
Step through each configuration section with the ability to:
- Accept default values
- Modify individual settings
- Skip optional sections (OAuth, SMTP, etc.)
m3-forge init --interactiveQuick Mode
Generate a .env file immediately using all default values. JWT secrets are automatically generated.
m3-forge init --defaultsCustom Configuration
Load defaults from a custom YAML file:
m3-forge init --interactive --config ./my-config.yamlExisting .env Protection
The setup wizard protects existing .env files from accidental overwrites:
| Scenario | Behavior |
|---|---|
--defaults with existing .env | Refuses - shows help message |
--interactive with existing .env | Prompts for confirmation |
--force with existing .env | Creates backup, then overwrites |
When an existing file is overwritten, a timestamped backup is created: .env.backup.1767183625738
Configuration Groups
The setup wizard configures the following sections:
| Group | Required | Description |
|---|---|---|
| Database | Yes | PostgreSQL connection settings |
| API Server | Yes | Server port, environment, URLs |
| JWT Configuration | Yes | Authentication tokens (auto-generated) |
| GitHub OAuth | No | GitHub login integration |
| Google OAuth | No | Google login integration |
| S3 Storage | No | Object storage configuration |
| Gateways | No | Marie-AI processing gateway tokens |
| Annotator | No | Annotator configuration paths |
| Email / SMTP | No | Email sending configuration |
| Application URLs | Yes | Public URLs for the application |
Auto-Generated Values
The following values are automatically generated if left empty:
- JWT_ACCESS_SECRET - 64-byte hex string
- JWT_REFRESH_SECRET - 64-byte hex string
Derived Values
Some values are automatically derived from others:
- GITHUB_CALLBACK_URL - Derived from
API_URL+/api/auth/github/callback - GOOGLE_CALLBACK_URL - Derived from
API_URL+/api/auth/google/callback
YAML Configuration Files
Default Template
The setup uses a built-in template (setup-defaults.yaml) containing all default values and configuration metadata.
User Overrides
Create a setup-overrides.yaml file to customize defaults for your environment:
# setup-overrides.yaml
version: "1.0"
groups:
database:
variables:
DATABASE_URL:
default: "postgresql://prod_user:secret@db.example.com:5432/marie_prod"
api_server:
variables:
NODE_ENV:
default: "production"
FRONTEND_URL:
default: "https://app.example.com"
API_URL:
default: "https://app.example.com"Override File Locations
The setup wizard searches for override files in this order:
--config <path>(CLI argument)./setup-overrides.yaml(current directory)~/.m3-forge/setup.yaml(home directory)
Extending Base Configuration
Override files can extend other files:
# production.yaml
extends: "./base-config.yaml"
groups:
# Only override what's different
database:
variables:
DATABASE_URL:
default: "postgresql://localhost:5432/marie_dev"Examples
Development
# Quick setup for local development
m3-forge init --defaultsSave Configuration for Team
After interactive setup, you can save your choices:
? Also save as setup-overrides.yaml for future use? YesThis creates a setup-overrides.yaml that can be committed to your repository (excluding sensitive values like secrets).
Generated .env Format
The generated .env file includes:
- Section headers with descriptions
- Comments explaining each variable
- Timestamp of generation
# .env
# M3 Forge - Environment Configuration
# Generated by m3-forge init
# Generated at: 2025-01-15T10:30:00.000Z
# =============================================================================
# Database
# PostgreSQL connection settings
# =============================================================================
# PostgreSQL connection string
DATABASE_URL=postgresql://user:password@localhost:5432/marie_studio
# =============================================================================
# JWT Configuration
# JSON Web Token settings for authentication
# =============================================================================
# JWT access token secret
JWT_ACCESS_SECRET=07d880031b1a0ee79fd05613c21f2f05...Troubleshooting
”Setup defaults template not found”
The CLI package may not be properly installed. Try:
cd packages/cli
pnpm build“.env file already exists”
Use one of these options:
--forceto overwrite (creates backup)--interactiveto review and confirm- Manually delete or rename the existing file
Validation Errors
If required values are missing, you’ll see validation errors. You can:
- Continue with incomplete configuration (not recommended)
- Re-run setup and provide the missing values