Skip to content
Cursor Handbook

Cursor CLI

The same agent that runs in the editor, driven from a terminal. The command is `agent`, it signs in to your existing account, and it works over SSH where the desktop app cannot.

  • Command: agent
  • macOS, Linux, WSL, Windows
  • Included on every plan

Checked against cursor.com on 25 September 2026

Install it

macOS, Linux, WSL
$ curl https://cursor.com/install -fsS | bash
Verify
$ agent --version
$ agent login

Windows without WSL, PATH problems and the rest of the setup are covered on the install page.

What it is for

The CLI is not a cut-down companion to the editor. It runs the same agent against the same models with the same tool access, which makes three things possible that the desktop app cannot do.

  • Remote work. A session over SSH on a build box or a GPU host behaves like a local one. No display, no port forwarding, no remote-development extension.
  • Scripted work. With --print the agent becomes a normal Unix process: stdin, stdout, exit code. You can call it from a Makefile, a Git hook or a CI job.
  • Parallel work. Combined with --worktree, you can run several agents on the same repository at once without any of them stepping on each other's files.

Interactive mode

Typing agent in a repository opens a session scoped to that directory. From there the interface is driven by slash commands rather than menus, and the ones worth learning first are /model, /plan and /summarize.

An initial prompt can be passed as an argument, which saves a round trip:

agent "work out why the auth tests are flaky"

Sessions persist. agent ls lists recent chats and lets you pick one, and agent resume jumps straight back into the latest. That matters more on the CLI than in the editor, because a terminal tab is much easier to close by accident than a window.

Non-interactive mode

--print is the flag that turns the CLI into a component of some larger pipeline. It writes the response to stdout and exits.

agent -p "summarise the changes in the last commit" \
  --output-format json

Two details are easy to miss. First, the format flag only does anything alongside --print. Second, and more importantly, print mode is not read-only. Cursor's own reference states that it has access to all tools, including write and shell. Running it against a prompt you did not write, in a directory you care about, is a real risk.

The mitigation is the sandbox. --sandbox enabled confines shell execution, and agent sandbox run can wrap a single command with explicit read and write paths and network access off by default.

Running several agents at once

The worktree flags exist because the obvious approach, opening three terminals in the same folder, does not work. Three agents editing one working tree produce conflicts that none of them can see.

agent -w fix-auth "make the auth tests deterministic"
agent -w add-cache "add a redis cache to the session store"

Each run gets a directory under ~/.cursor/worktrees/<repo>/<name> with its own checkout. Setup scripts defined in .cursor/worktrees.json run automatically unless you pass --skip-worktree-setup, which is how dependency installation gets handled for the new directory.

Modes from the terminal

Plan, Ask and Debug are all reachable. --plan starts a session in Plan mode so the agent drafts an approach before editing anything; /ask flips to read-only questions; /debug switches to the mode that reproduces a failure before attempting a fix. There is also /goal, which hands the agent a long-lived objective to work towards across multiple turns rather than a single task.

Command tables transcribed from the parameters reference and the slash command reference on 25 September 2026.

Subcommands

Cursor CLI subcommands
CommandWhat it does
agentStart interactive agent mode. This is the default when no subcommand is given.
agent "fix the tests"Start with an initial prompt instead of an empty session.
agent loginAuthenticate with your Cursor account.
agent statusShow authentication status. `agent whoami` is an alias.
agent modelsList the models available to your account.
agent mcpManage MCP servers configured for the CLI.
agent worker startRun a private cloud worker that executes agents in your own environment.
agent updateUpdate to the latest version manually.
agent lsBrowse and resume a previous chat session.
agent resumeResume the most recent session.
agent create-chatCreate an empty chat and print its ID, for scripting.
agent generate-ruleGenerate a Cursor rule through interactive prompts.
agent install-shell-integrationAdd shell integration to ~/.zshrc.

Flags worth knowing

Cursor CLI flags
FlagEffect
-p, --printPrint responses to stdout for scripts and CI. Still has access to every tool, including write and shell.
--output-format <format>text, json or stream-json. Only applies with --print. Defaults to text.
--stream-partial-outputEmit individual text deltas. Requires --print and stream-json.
--model <model>Pin a model for the session instead of using Auto.
--mode <mode>plan or ask. Agent mode is used when no mode is given. --plan is shorthand for --mode=plan.
--resume [chatId]Resume a session. --continue is an alias for --resume=-1.
-f, --forceAllow commands unless explicitly denied. --yolo is an alias.
--sandbox <mode>enabled or disabled. Controls whether shell commands run inside the sandbox.
--trustTrust the workspace without prompting. Headless mode only.
--workspace <path>Run against a directory other than the current one.
-w, --worktree [name]Run inside a fresh Git worktree under ~/.cursor/worktrees/<repo>/<name>.
--worktree-base <branch>Base the new worktree on a branch or ref other than current HEAD.
--api-key <key>Authenticate with an API key. CURSOR_API_KEY works too.
--list-modelsPrint every model name the account can use, then exit.

Every command also accepts -h for its own help output.

Slash commands

Typed inside an interactive session. These are how you change model, switch mode, and recover a session that has drifted.

Mode

/model [filter]
Select a model. Press Tab to edit the filter.
/plan [prompt]
Switch to Plan mode, show the current plan, or send a prompt in Plan mode.
/ask
Toggle Ask mode for read-only questions.
/debug [prompt]
Toggle Debug mode or send a prompt in Debug mode.
/goal [objective]
Give the agent a long-lived objective to work towards until it is complete.
/max-mode
Toggle Max Mode on legacy request-based plans.

Session

/clear
Start a new chat session. /new, /new-chat and /newchat are aliases.
/resume
Open recent chats and resume one.
/fork
Fork the current chat into a new session.
/rename <name>
Rename the current chat session.
/rewind
Jump back to a previous message.

Context

/summarize
Compress the conversation to reclaim context. /compress is an alias.
/copy
Copy a previous user message to the clipboard.
/open
Open the repository's Git root in the Cursor editor. /cursor is an alias.

Tools

/run-everything [on|off|status]
Toggle Run Everything or show its status. /auto-run is an alias.
/shell [command]
Enter Shell Mode. /sh and /run are aliases.
/mcp [list|list-tools]
Manage MCP servers and list a server's tools.
/plugin [subcommand]
Manage plugins and marketplaces.
/sandbox
Configure sandbox mode and network access.

Display

/vim
Toggle Vim keys.
/line-numbers
Toggle line numbers in code blocks.
/show-thinking
Toggle display of the model's thinking blocks.
/status-indicators
Toggle status indicators in the terminal title.
/setup-terminal
Configure terminal newline keybindings.

Account

/about
Show CLI version, system and account info, and copy it to the clipboard.
/logs
Show the debug log path and copy it to the clipboard.
/copy-request-id
Copy the last request ID, which support will ask for.
/update
Update the CLI to the latest version.
/logout
Sign out from Cursor.

Frequently asked questions

What is the Cursor CLI command called?
The binary is `agent`. Running `agent` with no arguments opens an interactive session in the current directory, and every subcommand is prefixed with it, as in `agent login` or `agent update`. There is no `cursor` CLI for the agent; `cursor` is the separate command that opens the desktop editor.
How do I install the Cursor CLI?
On macOS, Linux and Windows under WSL, run `curl https://cursor.com/install -fsS | bash`. On native Windows, run `irm 'https://cursor.com/install?win32=true' | iex` in PowerShell. The binary lands in ~/.local/bin, which may need adding to your PATH.
Can the Cursor CLI run non-interactively in CI?
Yes. The `-p` or `--print` flag prints responses to stdout instead of opening the interactive interface, and `--output-format json` or `stream-json` makes the output machine readable. Note that print mode still has access to every tool, including file writes and shell execution, so pair it with `--sandbox enabled` when running untrusted work.
Does the Cursor CLI need a separate subscription?
No. It authenticates against the same Cursor account as the editor with `agent login`, and draws on the same included usage allowance. An API key set through `--api-key` or the CURSOR_API_KEY environment variable works for headless environments.
How do I update the Cursor CLI?
It auto-updates by default. To force an update, run `agent update` from the shell or `/update` inside an interactive session.
Can I run the CLI agent on a branch without touching my working tree?
Yes, that is what the `-w` or `--worktree` flag does. It creates a fresh Git worktree under ~/.cursor/worktrees/<repo>/<name> and runs there, so the agent's edits never appear in the directory you are working in. Use `--worktree-base <branch>` to branch from something other than current HEAD.
What is the difference between the CLI and the editor agent?
The same agent and the same models, with a different surface. The CLI has no diff view, so review happens in your own tooling, but it composes with shell pipelines, runs over SSH, and can be scripted. Plan, Ask and Debug modes are all available through slash commands.