Environment files live under `.ellipsis/` on the default branch, with `ellipsis.kind: environment` and a unique name. See [Environments](/docs/environments) for when each setup script runs.

## Node.js project

```yaml title=".ellipsis/environments/web-environment.yaml"
ellipsis:
  kind: environment
  name: web-environment

repositories:
  - name: web-repo

hooks:
  build_base:
    inputs:
      - web-repo/package.json
      - web-repo/package-lock.json
    run: |
      cd /sandbox/web-repo
      npm ci
  after_checkout: |
    cd /sandbox/web-repo
    npm run build --if-present
  before_start: |
    cd /sandbox/web-repo
    test -d node_modules

compute:
  memory: 8GB
```

`npm ci` reruns only when `package.json` or the lockfile changes. The build reruns for each new commit. `before_start` checks that dependencies exist each time a session starts or resumes.

## Python project

```yaml title=".ellipsis/environments/python-environment.yaml"
ellipsis:
  kind: environment
  name: python-environment

repositories:
  - name: api-repo

hooks:
  build_base:
    inputs: [api-repo/requirements.txt]
    run: |
      cd /sandbox/api-repo
      python -m venv .venv
      .venv/bin/pip install -r requirements.txt

variables:
  - name: PYTHONUNBUFFERED
    value: '1'

compute:
  cpu: 2
  memory: 8GB
  timeout: 45m
```

The agent can run `/sandbox/api-repo/.venv/bin/python` with the project's dependencies.

## Multiple repositories

```yaml title=".ellipsis/environments/full-stack-environment.yaml"
ellipsis:
  kind: environment
  name: full-stack-environment

repositories:
  - name: web-repo
    ref: main
  - name: api-repo
    ref: main

hooks:
  build_base:
    inputs:
      - web-repo/package.json
      - web-repo/package-lock.json
      - api-repo/requirements.txt
    run: |
      (cd /sandbox/web-repo && npm ci)
      (cd /sandbox/api-repo && python -m venv .venv)
      /sandbox/api-repo/.venv/bin/pip install -r /sandbox/api-repo/requirements.txt

compute:
  cpu: 4
  memory: 16GB
```

Each repository is checked out at `/sandbox/<name>`. A repository's `owner` defaults to your account.

## Add environment variables and secrets

Set a plain value with `value`. For a secret, [store it](/docs/secrets) first, then list its name without a `value`:

```yaml title=".ellipsis/environments/private-packages.yaml"
ellipsis:
  kind: environment
  name: private-packages

repositories:
  - name: web-repo

variables:
  - name: NPM_TOKEN
  - name: NODE_ENV
    value: test

hooks:
  build_base:
    inputs: [web-repo/package.json, web-repo/package-lock.json, web-repo/.npmrc]
    run: |
      cd /sandbox/web-repo
      npm ci
```

`NODE_ENV` is `test`, and `NPM_TOKEN` comes from the stored secret, so its value never appears in git. Both are available to setup scripts and the agent.

- Names use letters, digits, and underscores, and can't start with a digit.
- A missing secret fails the session.
- Changing a variable reruns all setup scripts.
- Names starting with `ANTHROPIC_`, `OPENAI_`, `CODEX_`, `GEMINI_`, `GOOGLE_`, or `CLAUDE_CODE_USE_`, and `CLAUDE_CODE_OAUTH_TOKEN`, `CLAUDE_CONFIG_DIR`, and `ELLIPSIS_LLM_PROXY_URL`, are rejected.

## Install system tools

```yaml title=".ellipsis/environments/system-tools.yaml"
ellipsis:
  kind: environment
  name: system-tools

repositories:
  - name: api-repo

hooks:
  build_base:
    inputs: [api-repo/package.json, api-repo/package-lock.json]
    run: |
      sudo apt-get update
      sudo apt-get install -y jq
      cd /sandbox/api-repo
      npm ci
  validate: |
    command -v jq
    command -v gh
```

The agent can run `jq`. Install system packages in `build_base` with `sudo`. `validate` fails the session before the agent starts if a tool is missing, and fails the pull request's environment check before the change merges.

## Add an MCP server

List the MCP servers every session in an environment gets under `mcp`. A server started by a command belongs here, beside the hook that installs it.

```yaml title=".ellipsis/environments/design-tools.yaml"
ellipsis:
  kind: environment
  name: design-tools

repositories:
  - name: web-repo

hooks:
  build_base: |
    sudo npm install -g figma-developer-mcp

mcp:
  - name: figma
    command: figma-developer-mcp
    args: [--stdio]
    env:
      FIGMA_API_KEY: ${FIGMA_TOKEN}
```

Every session in `design-tools` gets the tools of the `figma` server.

- A server with `command` runs inside the environment, with optional `args` and `env`. Install anything it needs in `build_base`.
- `${NAME}` in `env` or `headers` reads the [secret](/docs/secrets) `NAME` when the session starts. A missing secret fails the session.
- An environment takes the same entries as an agent's [`session.mcp`](/docs/agents/schema#add-an-mcp-server), and a session gets both lists.
- A server the session lists under the same name replaces the environment's server for that session.

## Label an environment

Tag an environment for your own use with `labels` and `annotations` under `ellipsis.metadata`. An [agent](/docs/agents/schema#fields) takes the same block, and so does a session's `metadata`.

```yaml title=".ellipsis/environments/api-environment.yaml"
ellipsis:
  kind: environment
  name: api-environment
  metadata:
    labels: [python, team-api]
    annotations:
      owner: priya-shah
      runbook: https://wiki.example.com/api-environment

repositories:
  - name: api-repo
```

`GET /v1/environments/{id}` returns the labels and annotations in `environment.ellipsis.metadata`. Metadata doesn't change how sessions run, so editing it reruns no setup scripts.

`GET /v1/environments?label=python` lists only environments with that label, and `annotation=owner:priya-shah` only those with that annotation. Repeat either to require every one. `GET /v1/agents` and `GET /v1/sessions` take the same filters.

## Inline environments

An agent can define its environment in `session.environment` instead of naming a saved one. Use the same fields without the `ellipsis` block:

```yaml fragment
session:
  claude_code:
    model: claude-opus-5-5
  environment:
    repositories:
      - name: api-repo
    hooks:
      build_base:
        inputs: [api-repo/package.json, api-repo/package-lock.json]
        run: |
          cd /sandbox/api-repo
          npm ci
    compute:
      memory: 8GB
```

## Fields

| Field | Type | Meaning |
| --- | --- | --- |
| `ellipsis` | `object`, required | Identifies the file. |
| `ellipsis.kind` | `string`, required | `environment`. One of `environment`. |
| `ellipsis.name` | `string` | Unique environment name. |
| `ellipsis.description` | `string` | Description shown in the dashboard. |
| `ellipsis.metadata` | `object` | `labels` and `annotations` for your own use. |
| `ellipsis.metadata.labels` | `list of string` | Short tags. |
| `ellipsis.metadata.annotations` | `map of string` | Free text values by key. |
| `repositories` | `list of object` | Each repository is checked out at `/sandbox/<name>`. |
| `repositories[].name` | `string`, required | The repository name, without the owner. |
| `repositories[].owner` | `string` | The GitHub owner. Default your account. |
| `repositories[].ref` | `string` | Branch, tag, or commit. Default the default branch. |
| `variables` | `list of object` | Environment variables for setup scripts and the agent. Changing a variable reruns all setup scripts. |
| `variables[].name` | `string`, required | Letters, digits, and underscores; can't start with a digit. Names starting with `ANTHROPIC_`, `OPENAI_`, `CODEX_`, or `CLAUDE_CODE_USE_` are rejected. |
| `variables[].value` | `string` | A plain value; omit it to use the stored [secret](/docs/secrets) of the same name. A missing secret fails the session. |
| `hooks` | `object` | Setup scripts; see [Setup and hooks](/docs/environments#setup-and-hooks). |
| `hooks.build_base` | `string or object` | Script or `{run, inputs}`; installs dependencies. A string reruns on any source change. |
| `hooks.build_base.run` | `string`, required | The script. |
| `hooks.build_base.inputs` | `list of string` | Exact files, starting with the repository name; omit for all source, or `[]` for none. |
| `hooks.after_checkout` | `string or object` | Script or `{run}`; prepares each new commit. |
| `hooks.after_checkout.run` | `string`, required | The script. |
| `hooks.before_start` | `string or object` | Script or `{run}`; runs whenever a session starts or resumes. |
| `hooks.before_start.run` | `string`, required | The script. |
| `hooks.validate` | `string or object` | Script or `{run}`; runs last and checks the environment has what the agent needs. |
| `hooks.validate.run` | `string`, required | The script. |
| `compute` | `object` | The size of the environment. |
| `compute.cpu` | `integer` | 2 to 32 vCPUs. Default `2`. |
| `compute.memory` | `string` | 4096MB to 64GB. Accepts `MB` or `GB`. Default `4096MB`. |
| `compute.timeout` | `string` | The longest one message's work may run before it is stopped, 1 minute to 22 hours. Accepts `s`, `m`, and `h`, including combinations such as `1h30m`. Default `4h`. |
| `compute.idle` | `string` | How long the environment stays awake after the agent finishes with no message waiting, 10 seconds to 1 hour. Then it pauses, and the next message resumes it. Accepts `s`, `m`, and `h`. Default `10m`. |
| `mcp` | `list of string or object` | Servers every session in this environment gets, with the same entries as an agent's `session.mcp`; see [Add an MCP server](/docs/environments/schema#add-an-mcp-server). |
| `mcp[].name` | `string`, required | The server name. `slack` or `linear` attaches a connected integration. |
| `mcp[].url` | `string` | A remote server that speaks streamable HTTP. |
| `mcp[].headers` | `map of string` | Sent with every request. `${NAME}` reads the [secret](/docs/secrets) `NAME` when the session starts. |
| `mcp[].command` | `string` | A local server run inside the environment. Install anything it needs in `build_base`. |
| `mcp[].args` | `list of string` | Arguments for `command`. |
| `mcp[].env` | `map of string` | Environment variables for `command`. `${NAME}` reads the [secret](/docs/secrets) `NAME` when the session starts. |

Memory accepts `MB` or `GB`. `timeout` and `idle` accept `s`, `m`, and `h`, including combinations such as `1h30m`, within the allowed range. `timeout` caps one message's work, 1 minute to 22 hours, default 4 hours, and a message that reaches it ends `stopped` with reason `timeout`. `idle` is how long the environment stays awake after the agent finishes with no message waiting, 10 seconds to 1 hour, default 10 minutes. Then it pauses, and the next message resumes it with its files and processes. A session started with `interactive: false` ends when its message ends and never pauses.
