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.
- Install:
curl https://cursor.com/install -fsS | bash. The binary isagent. - It runs the same agent as the editor, minus Tab and the native diff view.
agent -pis print mode; add--output-format jsonfor scripts.- Without
--force, a print-mode run proposes changes and applies nothing. - The sandbox denies network by default;
-wgives each run its own worktree.
Installing it
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
irm 'https://cursor.com/install?win32=true' | iex
Subcommands from the published CLI reference, checked August 2026.
| Command | What it does |
|---|---|
agent | Start an interactive session in the current directory |
agent "fix the failing test in user.test.ts" | Start with an opening prompt |
agent login / agent logout | Browser sign-in, or clear stored credentials |
agent status or agent whoami | Check auth state. Add --format json for scripts |
agent about | Version, system, and account information |
agent models or --list-models | List the models available to your account |
agent ls / agent resume | List past chats, or reopen one |
agent mcp | Manage MCP servers: list, list-tools, enable, disable, login |
agent sandbox | Manage the sandbox: enable, disable, reset, run |
agent generate-rule | Write a valid .cursor/rules file rather than hand-editing frontmatter |
agent update | Upgrade to the latest version |
agent install-shell-integration | Add shell integration; uninstall-shell-integration removes it |
The flags that matter
Selected from the published parameter reference, August 2026.
| Flag | What it does |
|---|---|
-p, --print | Print responses to the console, for scripts and non-interactive use |
--output-format <fmt> | text, json, or stream-json. Defaults to text |
--stream-partial-output | Stream text deltas as they arrive, alongside print and stream-json |
--model <model> | Pick the model for the run |
--mode plan or --mode ask | Plan first, or ask questions without editing. --plan is shorthand |
-f, --force | Allow commands unless explicitly denied. --yolo is an alias |
--sandbox <mode> | Set sandbox mode for command execution |
--trust | Trust the workspace without prompting |
--approve-mcps | Automatically approve all MCP servers |
--workspace <path> | Set the working directory |
--resume [chatId] / --continue | Resume 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-setup | Skip 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.
# 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.
- 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.
| Setting | What it controls | Default |
|---|---|---|
networkPolicy.default | Baseline outbound network access | deny, blocking all traffic unless allowed |
networkPolicy.allow / .deny | Exact domains, wildcards, or CIDR ranges | Empty |
additionalReadwritePaths | Extra paths the agent may write to | Empty |
additionalReadonlyPaths | Paths it may read but not write | Empty |
disableTmpWrite | Removes the default /tmp write access | false |
{
"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.
# 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"
{
"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 editor | Cursor CLI | |
|---|---|---|
| Tab prediction | Yes | No |
| Native diff review | Yes | Terminal diff |
| Selection as context | Yes | No |
| Several sessions at once | Agents Window | One terminal each, trivially |
| Remote over SSH | Via a remote extension | Native |
| Scriptable and pipeable | No | Yes |
| Configurable sandbox | Limited | Yes, network denied by default |
| Runs in CI | No | Yes, with an API key |
Against the other terminal agents
Checked August 2026.
| Cursor CLI | Claude Code | Codex | |
|---|---|---|---|
| Maturity in the terminal | Newer, moving fast | Mature | Mature |
| Headless flag | agent -p | claude -p | codex exec |
| Sandbox | Configurable, network denied by default | Permission patterns | Seatbelt and Landlock |
| Built-in worktree flag | Yes, -w | No, you create them | No, you create them |
| CI recipe in the docs | Yes, GitHub Actions | Yes | Yes |
| Sign-in | Cursor account, or an API key | Your Claude plan | Your ChatGPT plan |
| Editor integration | Best in class | Good | Good |
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.