TUTORIAL
Installing Cursor CLI: a basic guide
Install Cursor CLI (cursor-agent), the terminal coding agent from Cursor, on macOS, Linux, or Windows, sign in, and run your first session.
Goal
By the end you'll have Cursor CLI installed, authenticated with your Cursor account, and a first agent session running against a real project, both interactively and in headless mode.
Cursor CLI brings Cursor's agent to the terminal. It's the same model access and agent behavior as the editor, callable from a shell: interactive sessions, headless runs for scripts and CI, plan/ask/agent modes, and a configurable sandbox. The installed binary is cursor-agent (the docs also refer to it as agent).
Prerequisites
- macOS, Linux, WSL, or Windows (PowerShell).
- A terminal with permission to install binaries onto your
PATH. - A Cursor account (the CLI shares your Cursor plan and pricing).
- A local project to work on.
This guide covers Cursor CLI as of September 2026.
Steps
1. Install the binary
macOS / Linux / WSL:
curl https://cursor.com/install -fsS | bashWindows (PowerShell):
irm 'https://cursor.com/install?win32=true' | iexThe installer places cursor-agent on your PATH. If it isn't found afterward, open a new terminal.
2. Verify the install
cursor-agent --versionExpected check: it prints the installed version. If the shell says "command not found", open a new session so it picks up the updated PATH.
3. Sign in
cursor-agent loginThis opens your browser to authenticate with your Cursor account. If the browser won't launch (for example over SSH), set NO_OPEN_BROWSER=1 and open the printed URL manually.
Check the result:
cursor-agent statusExpected check: it shows your account and endpoint. Use cursor-agent logout to sign out.
For CI or automation, skip the browser and use an API key from the Cursor dashboard:
export CURSOR_API_KEY=your_api_key_here
cursor-agent "run the test suite and fix failures"4. Start an interactive session
cd path/to/your/project
cursor-agentOr start with a prompt directly:
cursor-agent "explain the auth flow in this project"Switch modes inside the session: Agent (full access), Plan (design first, no edits), Ask (read-only). Control file-system and command access with /sandbox or the --sandbox <mode> flag. Pick a model with --model (for example --model "gpt-5").
The CLI reads .cursor/rules, plus AGENTS.md and CLAUDE.md at the repo root, and auto-detects mcp.json.
5. Run it headless
For scripts and pipelines:
cursor-agent -p "summarize the changes in the last commit" --output-format textUse --output-format json for structured output you can parse.
6. Resume and update
cursor-agent ls # list previous chats
cursor-agent resume # resume the most recent
cursor-agent update # update to the latest versionExpected result
cursor-agent --versionprints a version.cursor-agent statusshows you're signed in.cursor-agentopens an interactive session on your project.cursor-agent -p "..." --output-format textreturns an answer without an interactive prompt.
Troubleshooting
Common issues
cursor-agent: command not foundafter installing: the installer updated yourPATHbut the current shell didn't reload it. Open a new terminal orsourceyour shell profile.- Browser doesn't open on
login: setNO_OPEN_BROWSER=1, runcursor-agent loginagain, and open the URL it prints. - Authentication errors in CI: confirm
CURSOR_API_KEYis exported in the job environment, or pass--api-keyexplicitly. - Agent edits when you only wanted a plan: switch to Plan or Ask mode, or tighten
--sandbox. sudoprompts inside a run: the CLI masks the password so the model never sees it; type it at the prompt.
Next step
Add project rules under .cursor/rules so every session starts with the right context, and wire Cursor CLI into GitHub Actions for automated review and fix workflows.