# Environment configuration as code in Replicas

Manage Replicas environments from YAML or JSON. Apply local files through the CLI, or keep environment changes alongside your code in Git.

- Author: Kavin Valli
- Published: 2026-11-27
- Category: Announcements
- Canonical: https://replicas.dev/blog/environment-configuration-as-code

You can now manage Replicas environments from YAML or JSON. Apply a local file with the CLI, or connect a repository and have configuration changes apply after merge.

When a pull request changes how an application builds or adds a database dependency, its environment often needs to change too. Keeping configuration alongside code lets reviewers check both in one place. Agents can read the setup scripts and instructions as they inspect the repository, then edit them in the same pull request as the application change.

## Define the environment in a file

Save a file such as `infra/development.yaml`:

```yaml
environment:
  repositories:
    - your-org/your-app
  systemPrompt: "Run relevant tests before opening a pull request."
  warmHook: |
    cd ~/workspaces/your-app
    pnpm install --frozen-lockfile
    pnpm build
  startHook: |
    cd ~/workspaces/your-app
    replicas service start dev "pnpm dev --port 3000"
  variables:
    NODE_ENV: "development"
  requiredSecrets:
    - DATABASE_URL
```

The warm hook installs dependencies and builds while Replicas prepares the environment. The start hook starts the development server when a workspace boots. The format also supports files, skills, MCP servers, and other environment settings.

Keep secret values in Replicas or a connected secret provider. `requiredSecrets` declares which credentials the environment needs, so reviewers can see the requirements without putting values in Git.

## Apply locally or from Git

Preview and apply the file to an existing environment:

```bash
replicas environment config preview "Development" --file ./infra/development.yaml
replicas environment config apply "Development" --file ./infra/development.yaml
```

The preview shows what will change before you apply it. Declared settings become read-only in the app; settings outside the file stay editable.

For Git, a root `replicas.json` can point to the configuration:

```json
{
  "infra": "./infra/development.yaml"
}
```

Commit both files to the default branch, then link the repository from the environment's **Configuration source** section. The configuration can live in the application repository or a dedicated infrastructure repository attached to the environment.

Git updates wait for manual review by default. Turn on **Apply Git changes automatically** to apply merges and direct pushes to the default branch. Invalid configuration or missing required secrets preserve the previously applied settings and show an error.

## Terraform is coming soon

Terraform support is coming soon, so you can manage Replicas environments alongside the rest of your infrastructure.

## Start with an existing environment

You can export an environment's settings and adopt them into a configuration file while preserving its inheritance. You can also ask the Replicas agent:

> Move my Development environment into YAML configuration. Preserve its current settings and inheritance, keep secret values out of the file, and show me the preview before applying.

The [configuration guide](https://docs.replicas.dev/features/environment-configuration) covers the full format, Git setup, and migration steps.

