The Cursor CLI: agent mode outside the editor

Cursor put its agent in a terminal, which is an interesting admission: the editor integration is the product, and yet a lot of valuable agent work happens somewhere you are not looking. The CLI is how you reach that work, on your existing Cursor account, without opening the editor at all.

By the Continuum team. We build a workbench that runs Claude Code, Codex, and their peers, so the model rates quoted here are the ones our own cost analytics ship with.

The short version

The Cursor CLI runs the Cursor agent from a terminal without the editor. Install it with one curl command on macOS, Linux, and WSL, or a PowerShell one-liner on Windows. The binary is called agent. It supports print mode for scripts, JSON and streaming JSON output, a configurable OS sandbox that denies network access by default, MCP servers, and built-in worktree flags for parallel runs. It is documented for GitHub Actions with a CURSOR_API_KEY secret.

What you need to know
  • Install: curl https://cursor.com/install -fsS | bash. The binary is agent.
  • It runs the same agent as the editor, minus Tab and the native diff view.
  • agent -p is print mode; add --output-format json for scripts.
  • Without --force, a print-mode run proposes changes and applies nothing.
  • The sandbox denies network by default; -w gives each run its own worktree.

Installing it

macOS, Linux, and WSL. The installer puts the binary in ~/.local/bin, which must be on your PATH.
curl https://cursor.com/install -fsS | bash

export PATH="$HOME/.local/bin:$PATH"   # add this to .zshrc or .bashrc

agent --version
agent login
agent status
Windows, native PowerShell.
irm 'https://cursor.com/install?win32=true' | iex

Subcommands from the published CLI reference, checked August 2026.

CommandWhat it does
agentStart an interactive session in the current directory
agent "fix the failing test in user.test.ts"Start with an opening prompt
agent login / agent logoutBrowser sign-in, or clear stored credentials
agent status or agent whoamiCheck auth state. Add --format json for scripts
agent aboutVersion, system, and account information
agent models or --list-modelsList the models available to your account
agent ls / agent resumeList past chats, or reopen one
agent mcpManage MCP servers: list, list-tools, enable, disable, login
agent sandboxManage the sandbox: enable, disable, reset, run
agent generate-ruleWrite a valid .cursor/rules file rather than hand-editing frontmatter
agent updateUpgrade to the latest version
agent install-shell-integrationAdd shell integration; uninstall-shell-integration removes it

The flags that matter

Selected from the published parameter reference, August 2026.

FlagWhat it does
-p, --printPrint responses to the console, for scripts and non-interactive use
--output-format <fmt>text, json, or stream-json. Defaults to text
--stream-partial-outputStream text deltas as they arrive, alongside print and stream-json
--model <model>Pick the model for the run
--mode plan or --mode askPlan first, or ask questions without editing. --plan is shorthand
-f, --forceAllow commands unless explicitly denied. --yolo is an alias
--sandbox <mode>Set sandbox mode for command execution
--trustTrust the workspace without prompting
--approve-mcpsAutomatically approve all MCP servers
--workspace <path>Set the working directory
--resume [chatId] / --continueResume a chat by id, or continue the previous session
--api-key <key>Supply credentials directly, or set CURSOR_API_KEY
-w, --worktree [name]Run in a fresh git worktree the CLI creates for you
--worktree-base <branch>Branch or ref to base the worktree on
--skip-worktree-setupSkip the setup scripts declared in .cursor/worktrees.json

Headless and scripted runs

This is the reason to have a CLI at all. Print mode turns the agent into something you can pipe, schedule, and put in a pipeline.

Three shapes of non-interactive run.
# plain text out
agent -p "summarise what changed in the last three commits"

# structured, for a script to parse
agent -p --output-format json "list every TODO in src/ with its file and line"

# actually apply changes, no confirmation prompts
agent -p --force "convert src/utils/*.js to TypeScript, keep behaviour identical"

For long or streaming runs, --output-format stream-json emits typed events as they happen: a system event with the model, assistant events carrying text, tool_call events with a started or completed subtype, and a final result with a duration. That is what you pipe into jq behind a progress indicator, rather than a job that appears frozen for four minutes.

GitHub Actions, following the recipe in Cursor documentation.
- name: Install Cursor CLI
  run: |
    curl https://cursor.com/install -fsS | bash
    echo "$HOME/.cursor/bin" >> $GITHUB_PATH

- name: Review the diff
  env:
    CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}
  run: |
    agent -p --output-format json \
      "review the changes in this PR for missing error handling" \
      > review.json

The sandbox, and why it is the best reason to use the CLI

The CLI has a sandbox of its own, which matters more here than in the editor because nobody is watching a terminal run inside a pipeline. It is configured with a sandbox.json file, and the defaults are the interesting part.

From the sandbox.json reference, checked August 2026.

SettingWhat it controlsDefault
networkPolicy.defaultBaseline outbound network accessdeny, blocking all traffic unless allowed
networkPolicy.allow / .denyExact domains, wildcards, or CIDR rangesEmpty
additionalReadwritePathsExtra paths the agent may write toEmpty
additionalReadonlyPathsPaths it may read but not writeEmpty
disableTmpWriteRemoves the default /tmp write accessfalse
~/.cursor/sandbox.json for all workspaces, or <workspace>/.cursor/sandbox.json which takes priority.
{
  "networkPolicy": {
    "default": "deny",
    "allow": ["registry.npmjs.org", "*.github.com"]
  },
  "additionalReadonlyPaths": ["~/.config/myapp"],
  "disableTmpWrite": false
}

Network denied by default is the setting worth appreciating. Most of what people fear from an autonomous agent needs an outbound connection, and a run that can read your repository but cannot phone anywhere is a much smaller risk surface than one that can do both. Allowlisting your package registry and your git host covers the majority of real work.

Separately, the CLI reads a config file at ~/.cursor/cli-config.json, with a project-level .cursor/cli.json for permissions only. It carries permissions.allow and permissions.deny arrays and an approvalMode of allowlist, auto-review, or unrestricted. Set the approval mode there rather than reaching for --yolo on every invocation.

Running several at once

The strongest reason to use a terminal agent at all is that it parallelises. That requires one working tree per agent, or they overwrite each other. The Cursor CLI has this built in rather than leaving it to you, which none of the other mainstream terminal agents do.

One worktree per agent, created by the CLI itself.
# each run gets its own isolated checkout
agent -w auth   "add JWT middleware under src/middleware, do not touch login"
agent -w search "add full-text search to the notes list"

# base a worktree on something other than the current HEAD
agent -w hotfix --worktree-base release/2.4 "patch the null deref in parser.ts"
.cursor/worktrees.json - what a fresh checkout needs before it is useful.
{
  "setup-worktree-unix": [
    "cp ../main-repo/.env .env",
    "pnpm install --frozen-lockfile"
  ],
  "setup-worktree-windows": "scripts/setup-worktree.ps1"
}

What you gain and lose against the editor

Cursor editorCursor CLI
Tab predictionYesNo
Native diff reviewYesTerminal diff
Selection as contextYesNo
Several sessions at onceAgents WindowOne terminal each, trivially
Remote over SSHVia a remote extensionNative
Scriptable and pipeableNoYes
Configurable sandboxLimitedYes, network denied by default
Runs in CINoYes, with an API key

Against the other terminal agents

Checked August 2026.

Cursor CLIClaude CodeCodex
Maturity in the terminalNewer, moving fastMatureMature
Headless flagagent -pclaude -pcodex exec
SandboxConfigurable, network denied by defaultPermission patternsSeatbelt and Landlock
Built-in worktree flagYes, -wNo, you create themNo, you create them
CI recipe in the docsYes, GitHub ActionsYesYes
Sign-inCursor account, or an API keyYour Claude planYour ChatGPT plan
Editor integrationBest in classGoodGood

The -w row is the genuine differentiator and is not talked about enough. Every terminal agent benefits from one worktree per session, and Cursor is the one that ships the flag instead of leaving you to write the shell around it.

Questions people ask

A terminal interface to the Cursor agent, running the same agent loop without the editor. It suits parallel sessions, remote machines, sandboxed runs, and scripted or CI work.

On macOS, Linux, and WSL run curl https://cursor.com/install -fsS | bash. On native Windows run irm 'https://cursor.com/install?win32=true' | iex. The installer places the binary in ~/.local/bin, so add that to your PATH, then check it with agent --version.

The installed binary is agent. Older articles and package listings often call the tool cursor-agent, which is why commands copied from them sometimes fail to resolve.

No. Tab prediction is an editor feature and is the main reason people pay for Cursor, so the CLI complements the editor rather than replacing it.

Install it in the job, add the CLI directory to the path, set CURSOR_API_KEY from a repository secret, and run agent -p with --output-format json. Add --force if the job is meant to apply changes, because print mode only proposes them by default.

Yes, configured through sandbox.json at ~/.cursor/sandbox.json or in the workspace, which takes priority. The network policy defaults to deny, and .cursor/*.json, .vscode/**, .git/hooks/** and .cursorignore are always write-blocked.

Yes. Pass -w to give each run its own git worktree, use --worktree-base to branch from something other than HEAD, and declare the install steps a fresh checkout needs in .cursor/worktrees.json.

Claude Code and Codex are further along in the terminal, particularly for long unattended runs. The Cursor CLI wins on the built-in worktree flag and the network-denied-by-default sandbox, and makes most sense if you already use Cursor and want terminal work on the account you have.

Sources

Every figure above was read from these pages on August 2026. Vendors reprice without notice; if you find a stale number, tell us.

  1. Cursor CLI overview
  2. Cursor CLI parameter reference
  3. Cursor CLI headless usage
  4. Cursor sandbox.json reference
Try it

Every agent,
every worktree.

Continuum creates the worktree, runs the agent in it, and shows every session in one sidebar.

free app · your subscriptions · local-first