Cloud Agents
environment.json for Cursor Cloud Agents: Full Reference
.cursor/environment.json is a JSON file you commit to define a Cloud Agent environment in code. Cursor runs its install command while preparing a Build, and runs start and terminals when an agent begins. Personal and team saved environments take precedence, and a saved environment uses the file only when its environment.json location points at it.

On this page
What is .cursor/environment.json?
It is the config-as-code option for Cloud Agent environments: a JSON file you commit at .cursor/environment.json to describe the agent's machine. Cursor checks it last. For each repository or repo group, Cursor uses the first match in this order:
- 1A personal saved environment.
- 2A team saved environment.
- 3
.cursor/environment.jsonin the repository, for single-repo runs only.
A saved environment runs the configuration saved in it. It reads .cursor/environment.json only when its environment.json location points at the file, and environments you create start with that location set to None (skip environment.json). To use a committed file, pick its repository when you create the environment. When starting an agent creates the first saved environment for a single repository, Cursor checks that repository for a committed file and, if the file is valid, points the new environment at it.
Builds use the configuration on the environment's default branch. To try a change on a feature branch, commit and push it, then start an agent on that branch. Cursor checks out the branch on top of the active Build, so the run reuses that Build's prepared disk, and the agent can rerun install if the branch changes dependencies. The setup guide covers the two setup paths; this page is the field-by-field reference.
- Location
.cursor/environment.jsonin the repository- Precedence
- Checked after personal and team saved environments, and only for single-repo runs. A saved environment can point at it.
- Versioning
- Builds read it from the environment's default branch
- Syntax
- JSON with comments allowed; trailing commas rejected; unknown fields rejected
Cursor's docs give the personal saved environment a specific job: it lets one person try a configuration before the whole team gets it. Because Cursor checks it first, it overrides both the team's saved environment and a committed file for that person's runs.
This is covered hands-on in Agent Mode Foundations — 6 short Units, free to read.
Rather do it than read about it? Run 11 interactive Cursor walkthroughs in a simulated editor. Free, no account needed.
What fields does environment.json support?
The published schema separates the fields that build the base machine from the fields that configure what runs on it. It rejects unknown properties, so a typo like startup fails validation instead of being silently ignored. These fields define the machine and its processes:
- Field
name- Type
- string
- What it does
- Names the environment.
- Field
user- Type
- string
- What it does
- The user the environment runs as.
- Field
install- Type
- string
- What it does
- The install script, formerly called the update script. Runs to completion during each Build after Cursor clones the repositories; use it for dependencies, generated code, compiled artifacts and disk caches.
- Field
start- Type
- string
- What it does
- Runs when an agent boots from a Build; for processes that stay alive during the run, like
sudo service docker start.
- Field
terminals- Type
- array
- What it does
- Terminals started for the run, each
{ name, command, description }. They run in atmuxsession shared by you and the agent.
- Field
ports- Type
- array
- What it does
- Ports to expose from the container, each
{ name, port }. The schema compares it to devcontainer port forwarding.
- Field
repositoryDependencies- Type
- array
- What it does
- Extra repos, as
github.com/org/repo, that must be included in the GitHub access token generated for the environment.
- Field
snapshot- Type
- string
- What it does
- A snapshot ID to use as the base environment, from the environments page of the dashboard. Takes precedence over
buildandimage.
- Field
image- Type
- string
- What it does
- A container image reference from a registry, used as the base.
- Field
agentCanUpdateSnapshot- Type
- boolean
- What it does
- Whether the agent may update the snapshot. Defaults to true for snapshot-based and default-base environments, and is always false when the base is
buildorimage.
- Field
build- Type
- object
- What it does
- Docker build options:
dockerfileordockerfileContents(one is required) andcontext. Paths are relative to the repository's.cursorfolder.
| Field | Type | What it does |
|---|---|---|
name | string | Names the environment. |
user | string | The user the environment runs as. |
install | string | The install script, formerly called the update script. Runs to completion during each Build after Cursor clones the repositories; use it for dependencies, generated code, compiled artifacts and disk caches. |
start | string | Runs when an agent boots from a Build; for processes that stay alive during the run, like sudo service docker start. |
terminals | array | Terminals started for the run, each { name, command, description }. They run in a tmux session shared by you and the agent. |
ports | array | Ports to expose from the container, each { name, port }. The schema compares it to devcontainer port forwarding. |
repositoryDependencies | array | Extra repos, as github.com/org/repo, that must be included in the GitHub access token generated for the environment. |
snapshot | string | A snapshot ID to use as the base environment, from the environments page of the dashboard. Takes precedence over build and image. |
image | string | A container image reference from a registry, used as the base. |
agentCanUpdateSnapshot | boolean | Whether the agent may update the snapshot. Defaults to true for snapshot-based and default-base environments, and is always false when the base is build or image. |
build | object | Docker build options: dockerfile or dockerfileContents (one is required) and context. Paths are relative to the repository's .cursor folder. |
Checked against Cursor's published schema and setup docs, October 2026. One of snapshot, build or image usually defines the base, and snapshot wins when set.
Both samples in Cursor's setup docs are two fields long: a base plus an install. Start there, and add a field when a problem calls for it: ports when something outside the container has to reach the dev server, and start when a run needs the Docker daemon up.
Two schema descriptions carry detail that is easy to miss. A terminal's description is displayed to the agent, so it works as a prompt: a terminal described as 'Next.js dev server on port 3000' tells the agent what is already running and where. And repositoryDependencies is about access, not cloning. It lists repos that must be in the environment's GitHub token, which matters when your build pulls a private sibling repo.
Inside build, dockerfile is a path and dockerfileContents is an inline Dockerfile, and the schema requires one of them. Inline contents aren't available to every team: a Build that sets build.dockerfileContents where it isn't enabled fails with dockerfile_contents_not_enabled.
No top-level field is required, so an empty {} validates. You get Cursor's default base image and no install step.
Which environment.json fields set network, MCP and testing rules?
The schema also lets an environment set its own network, MCPModel Context Protocol. A standard that lets an AI agent pull in context from outside the repo, like Jira tickets or internal docs. Press Enter for the full definition. and testing rules. Like the rest of the file, they apply to Cursor-hosted Cloud AgentsAgents that run in a Cursor-managed virtual machine, check out the repo, do the work and open a pull request, then shut down, with no load on your laptop. Press Enter for the full definition.: a run on Self-Hosted Machines never reads .cursor/environment.json.
- Field
egressMode- Type
- string
- What it does
- How the environment's allowlist combines with team and user network settings:
allow_all,parent_plus_network_settings,default_with_network_settingsornetwork_settings_only.
- Field
egressAllowlist- Type
- array
- What it does
- Extra outbound domains, such as
registry.npmjs.org. WithoutegressMode, they are added to the inherited user or team allowlist.
- Field
disableAllMcpServers- Type
- boolean
- What it does
- When true, blocks every user and team MCPModel Context Protocol. A standard that lets an AI agent pull in context from outside the repo, like Jira tickets or internal docs. Press Enter for the full definition. server for agents in this environment. Cursor's built-in MCP servers are never restricted.
- Field
mcpServerAllowlist- Type
- array
- What it does
- The MCPModel Context Protocol. A standard that lets an AI agent pull in context from outside the repo, like Jira tickets or internal docs. Press Enter for the full definition. servers the environment allows, matched by
serverUrlfor HTTP servers orcommandfor stdio servers, with an optionaltoolAllowlist. Empty or omitted, it inherits the team and user MCP policy.
- Field
chromeExecutablePath- Type
- string
- What it does
- Path to a Chrome or Chromium executable in the environment, for browser-based testing.
- Field
enable_testing- Type
- boolean or string
- What it does
- Whether agents may run cloud testing, such as computer use, in this environment. Defaults to true.
| Field | Type | What it does |
|---|---|---|
egressMode | string | How the environment's allowlist combines with team and user network settings: allow_all, parent_plus_network_settings, default_with_network_settings or network_settings_only. |
egressAllowlist | array | Extra outbound domains, such as registry.npmjs.org. Without egressMode, they are added to the inherited user or team allowlist. |
disableAllMcpServers | boolean | When true, blocks every user and team MCPModel Context Protocol. A standard that lets an AI agent pull in context from outside the repo, like Jira tickets or internal docs. Press Enter for the full definition. server for agents in this environment. Cursor's built-in MCP servers are never restricted. |
mcpServerAllowlist | array | The MCPModel Context Protocol. A standard that lets an AI agent pull in context from outside the repo, like Jira tickets or internal docs. Press Enter for the full definition. servers the environment allows, matched by serverUrl for HTTP servers or command for stdio servers, with an optional toolAllowlist. Empty or omitted, it inherits the team and user MCP policy. |
chromeExecutablePath | string | Path to a Chrome or Chromium executable in the environment, for browser-based testing. |
enable_testing | boolean or string | Whether agents may run cloud testing, such as computer use, in this environment. Defaults to true. |
Network, MCP and testing fields in Cursor's published schema, October 2026.
The schema defines each egressMode value. allow_all turns off egress restrictions, subject to team policy. parent_plus_network_settings adds egressAllowlist to the inherited user or team allowlist. default_with_network_settings allows the default domains plus the list, and network_settings_only allows only required domains plus the list.
An empty mcpServerAllowlist does not turn MCPModel Context Protocol. A standard that lets an AI agent pull in context from outside the repo, like Jira tickets or internal docs. Press Enter for the full definition. off. To block user and team servers, set disableAllMcpServers to true. The security and network guide covers the dashboard's network modes and how environment, user and team settings combine.
How do Builds run install, start and terminals?
Builds separate durable preparation from live services, and that split decides where each command belongs. A Build prepares disk state ahead of agent runs, and services and shared terminals start only when an agent begins:
- 1Cursor starts from the configured base, clones every repository at its default branch, and runs
installto completion. - 2A successful Build saves the disk state with each repository's commit and becomes the active Build. A failed Build doesn't replace it.
- 3A new agent starts from the active Build, and Cursor runs
startfor services that must be fresh. - 4Cursor then launches each configured terminal in the
tmuxsession shared by you and the agent.
Make install complete and idempotent. It runs for every Build and may run on disk state an earlier Build prepared, so a script written as though the machine were always new can behave differently the second time through. Keep destructive database setup out of it.
Builds keep disk state only. Installed packages, generated files and warmed disk caches survive, while processes, shell exports and in-memory caches stop at the snapshot. Start Docker, databases and tunnels in start instead. Before you change a config that looks stale, check the Build's logs and the exact commit it used.
Put reusable dependency and artifact preparation in install. Put services that must be running in start, and leave task-specific build or test choices in a 'Cursor Cloud specific instructions' section of AGENTS.md.
What does a complete environment.json look like?
This Dockerfile-based config builds a custom image, runs an idempotent install, starts Docker for the run, opens a dev server the agent can see, and exposes the server's port.
{
"name": "web-app",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"install": "pnpm install",
"start": "sudo service docker start",
"terminals": [
{
"name": "dev",
"command": "pnpm dev",
"description": "Next.js dev server on port 3000"
}
],
"ports": [{ "name": "web", "port": 3000 }]
}dockerfile points at .cursor/Dockerfile, because build paths are relative to the .cursor folder, and context is .., a value Cursor treats as the repository root. Write a Dockerfile for the reasons the docs give: system-level dependencies, specific compiler versions, debuggers, or a different base OS image. If your repo needs none of those, guided setup can get it to a working environment in less than 10 minutes.
The snapshot-based variant is shorter, because the base is a saved machine instead of a build. Cursor's docs suggest committing your configuration after agent-driven setup so the whole team benefits. A saved environment picks the file up only when its environment.json location points at it.
{
"snapshot": "snapshot-20260212-00000000-0000-0000-0000-000000000000",
"install": "npm install",
"agentCanUpdateSnapshot": true
}The last line restates the default: the schema sets agentCanUpdateSnapshot to true for snapshot-based environments. If several people run agents on the same snapshot and you don't want an agent changing it, set the field to false.
What are the gotchas?
Check these documented behaviors before you start debugging individual fields.
- A committed file doesn't change a saved environment by itself. The environment reads
.cursor/environment.jsononly when its environment.json location points at the file. build.dockerfileandbuild.contextare relative to the repository's.cursorfolder, andcontextdefaults to.cursor. The values.,./and..mean the repository root. Theinstallcommand runs from the project root.- Don't
COPYthe full project in your Dockerfile. Cursor manages the workspace and checks out the correct commit itself, and aCOPY . .bakes a stale tree into the image. - The schema has no secrets field. Credentials go in the dashboard's Secrets tab and arrive as environment variables. If your agent can't read one, follow its own fix path.
- Snapshots expire. Cursor deletes an environment snapshot after 30 days without a start or resume, and the current docs don't say what a Build does when its base snapshot is gone. To go back to an earlier configuration, restore it from version history in the dashboard settings.
- A failed Build stays inactive. Agents keep using the latest successful Build while you inspect the failed one's events, logs and commit SHAs.
- You configure a Dockerfile-based environment through the Dockerfile. Cursor's docs say you don't get direct access to the remote machine.
- Dockerfile builds use layer caching, so changing a Dockerfile rebuilds only the changed layers. Put slow steps first and volatile steps last.
A failed Build can fall back only to an earlier successful one. Until an environment has its first successful Build, agents start on Cursor's default image, without the environment's snapshot, Dockerfile or install command.
Diagnose either state in the Builds tab, which shows each Build's status, logs and repository commits. The Cloud AgentsAgents that run in a Cursor-managed virtual machine, check out the repo, do the work and open a pull request, then shut down, with no load on your laptop. Press Enter for the full definition. dashboard also shows which Build each agent used.
If a run behaves like a config you no longer have, check which Build it started from and that Build's commits before you check the file. A fix you push to the default branch reaches new agents once a Build that includes it succeeds.
Frequently asked questions
Does install run every time a Cloud Agent starts?
No. Cursor runs install while it prepares a Build, and new agents start from the active Build. When an agent starts, Cursor runs start and then terminals. On a feature branch that changes dependencies, the agent can rerun install before testing.
Does environment.json override my saved dashboard environment?
No. Cursor checks a personal saved environment first, then a team saved environment, and falls back to .cursor/environment.json only for single-repo runs. A saved environment reads the file only when its environment.json location points at it.
Where do I find a snapshot ID for environment.json?
On the environments page of the Cloud Agents dashboard. After agent-driven setup you can save a snapshot of the machine, and the resulting ID is what the snapshot field references. Cursor deletes a snapshot after 30 days without use.
How do I test a new environment.json without breaking the team?
Save it as a personal environment, which Cursor checks before the team's, so only your runs use it. Or commit it to a branch and start an agent on that branch. Cursor checks out the branch on top of the active Build, while Builds keep using the default branch.
Can environment.json hold API keys or database credentials?
No. The schema has no field for secrets, and the file is committed to your repo as plaintext. Store credentials in the Cloud Agents dashboard's Secrets tab, where Cursor encrypts them and passes them to the agent as environment variables.
Sources & last verified
- Cursor - environment.json schema
- Cursor Docs - Cloud Agent Setup
- Cursor Docs - Cloud Agent Settings
- Cursor Docs - Cloud Agent Builds
- Cursor Docs - Cloud Agents API: environment Build failure codes
- Cursor Docs - Secrets & Network: data retention
Cursor ships frequently. Last updated October 28, 2026.