> cursor cli
Cursor's agent without the editor — cursor-agent runs interactive or headless, resumes sessions, follows your rules, and plugs into CI
// getting started
7 commandsInstall the Cursor CLI on macOS or Linux
$ curl https://cursor.com/install -fsS | bashInstall the Cursor CLI on Windows
$ irm 'https://cursor.com/install?win32=true' | iexAdd cursor-agent to your PATH
$ echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrcLog in and check your account status
$ cursor-agent loginAuthenticate with an API key for scripts
$ export CURSOR_API_KEY=key_your_token_hereUpdate the CLI to the latest version
$ cursor-agent updateSign out and clear stored credentials
$ cursor-agent logout// sessions
5 commands// modes & models
5 commandsPlan an approach before writing any code
$ cursor-agent --plan "refactor the payment module"Ask questions about code without edits
$ cursor-agent --mode=ask "how does caching work in this repo?"Switch modes and debug during a session
$ /debugChoose which model the agent uses
$ cursor-agent --list-modelsSwitch models from inside a chat
$ /model// print mode & automation
6 commandsGet a scriptable answer in print mode
$ cursor-agent -p "list all TODO comments in this repo"Pipe a diff or logs into the agent
$ git diff | cursor-agent -p "summarize these changes"Get structured JSON output for parsing
$ cursor-agent -p "review auth.ts for security issues" --output-format jsonStream the agent's output as it works
$ cursor-agent -p "add tests for utils.ts" --output-format stream-jsonLet the agent apply changes without prompts
$ cursor-agent -p "update CHANGELOG.md for the latest release" --forceRun the agent in a GitHub Actions workflow
$ curl https://cursor.com/install -fsS | bash// permissions & sandbox
4 commandsAllow or deny specific tools and commands
$ { "permissions": { "allow": ["Shell(npm)", "Shell(git)", "Read(src/**)"], "deny": ["Shell(rm)", "Read(.env*)", "Write(**/.env*)"] } }Run commands inside a sandbox
$ cursor-agent --sandbox enabled "run the build"Scope which paths the sandbox can touch
$ cursor-agent -p "refactor the module" --allow-paths "src,tests" --readonly-paths "config" --blocked-patterns "*.env"Skip trust and approval prompts in automation
$ cursor-agent -p "deploy the preview" --trust// worktrees & cloud
4 commandsWork in an isolated git worktree
$ cursor-agent -w feature-authBase a worktree on a specific branch
$ cursor-agent -w hotfix --worktree-base mainRun setup scripts when a worktree is created
$ { "setup": ["npm install", "cp .env.example .env"] }Hand a long task off to a Cloud Agent
$ & refactor the auth module and add comprehensive tests// rules & mcp
5 commandsGive the agent project rules and context
$ mkdir -p .cursor/rulesList configured MCP servers
$ cursor-agent mcp listInspect the tools an MCP server exposes
$ cursor-agent mcp list-tools linearEnable, disable, or log in to an MCP server
$ cursor-agent mcp login linearConfigure a new MCP server
$ { "mcpServers": { "linear": { "command": "npx", "args": ["-y", "linear-mcp-server"], "env": { "API_KEY": "value" } } } }// interface & shortcuts
6 commandsDiscover slash commands and get help
$ /helpAdd files and folders to the context
$ @src/auth.tsReview the agent's changes before accepting
Ctrl+R
Insert a newline and exit the CLI cleanly
$ /setup-terminalRun shell commands from inside a session
$ /shellTune the CLI with a config file
$ { "version": 1, "editor": { "vimMode": true }, "notifications": true }