Guide
Cursor CLI: Headless, Terminal-Native Coding (2026)
The Cursor CLI runs Cursor's agent in your terminal, so you can script it or run it headlessly: in CI, over SSH or piped into other tools. Use it when the work is automation rather than interactive editing. It edits files and runs commands within the permissions you set, and merging stays your call.

On this page
- What is the Cursor CLI?
- Which Cursor CLI commands matter most?
- Can I run several models on the same task at once?
- How do I run the Cursor agent headlessly or in another editor?
- How do I get the Cursor agent in Android Studio?
- Which CLI reference pages matter for automation?
- How do I manage the CLI's context budget?
- When should I use the Cursor CLI, and with what guardrails?
What is the Cursor CLI?
The CLI is Cursor's coding agent without the editor window. It runs in a terminal, so you can script it or run it headlessly in CI. Interactive editing and visual diff review still belong in the editor. Reach for the CLI for automation and for long runs that nobody watches.
Pick plan or ask from the agent CLI
0:27 · narratedRead this demo as text
- agent --help names the modes the CLI shares with the editor. --mode plan stays read-only; --mode ask is Q and A. --print and --resume are the script path — this is help bytes, not a live TUI session.
Practice next: Practice this yourself in the hands-on module.
Simulated Cursor 3.12 (macOS, light) — beta educational reconstruction, not the real product.
- Use the editor when
- You are actively editing and reviewing diffs
- Use the CLI when
- The task is scriptable or runs in CI
- Use the editor when
- You want visual, in-line review
- Use the CLI when
- You are headless (SSH, container, pipeline)
- Use the editor when
- You are exploring interactively
- Use the CLI when
- You are triaging failures or batching work
| Use the editor when | Use the CLI when |
|---|---|
| You are actively editing and reviewing diffs | The task is scriptable or runs in CI |
| You want visual, in-line review | You are headless (SSH, container, pipeline) |
| You are exploring interactively | You are triaging failures or batching work |
The CLI works alongside the editor. Pick the surface by the shape of the task.
This exact topic is a hands-on Lesson: Run Cursor CLI in scripts — about 7 minutes, free to read.
Rather do it than read about it? Run 11 interactive Cursor walkthroughs in a simulated editor. Free, no account needed.
Which Cursor CLI commands matter most?
Type agent in any shell to open the Cursor agent. The slash-command menu is your control surface from there: it lists the models you can switch to, your skills, the built-in commands and any MCPModel Context Protocol. A standard that lets an AI agent pull in context from outside the repo, like Jira tickets or internal docs. Press Enter for the full definition. servers you have set up.
Prefix a message with & to hand the conversation to the cloud. The CLI starts a cloud agent that works on its own branch, asynchronously, so you can keep typing locally while it runs elsewhere. To run a shell command without leaving the session, enter Shell Mode with /shell.
/open opens the repository's Git root in the Cursor editor, where you can review the agent's changes visually, and /cursor is an alias for it. Cursor's docs describe it as opening the repository and don't say the conversation moves with it.
- Type this
- agent
- What it does
- Open the Cursor agent in your current shell
- Type this
- / (slash menu)
- What it does
- Pick a model, skill, built-in command or MCPModel Context Protocol. A standard that lets an AI agent pull in context from outside the repo, like Jira tickets or internal docs. Press Enter for the full definition. server
- Type this
- & your message
- What it does
- Hand off to a cloud agent: works on its own branch, runs async
- Type this
- /shell command
- What it does
- Run a shell command in Shell Mode without leaving the session
- Type this
- agent --worktree
- What it does
- Run the session in an isolated git worktree
- Type this
- /open (alias /cursor)
- What it does
- Open the repository's Git root in the Cursor editor
- Type this
- agent -p "..."
- What it does
- Run headlessly for CI and scripts, no interactive UI
| Type this | What it does |
|---|---|
| agent | Open the Cursor agent in your current shell |
| / (slash menu) | Pick a model, skill, built-in command or MCPModel Context Protocol. A standard that lets an AI agent pull in context from outside the repo, like Jira tickets or internal docs. Press Enter for the full definition. server |
| & your message | Hand off to a cloud agent: works on its own branch, runs async |
| /shell command | Run a shell command in Shell Mode without leaving the session |
| agent --worktree | Run the session in an isolated git worktree |
| /open (alias /cursor) | Open the repository's Git root in the Cursor editor |
| agent -p "..." | Run headlessly for CI and scripts, no interactive UI |
Slash commands name actions. The & prefix and the --worktree and -p flags change how a session runs.
Shift+Tab rotates between the Agent, Plan and Ask modes without leaving the prompt, so you can drop into Plan before a big change or switch to Ask when you only want answers. Debug modeA mode that diagnoses a failure: it reproduces the issue, adds instrumentation and watches the logs, rather than reviewing a pull request. Press Enter for the full definition. and Run Everything, which runs every tool call without asking, sit outside that cycle, and each has its own slash command.
The slash menu also handles MCPModel Context Protocol. A standard that lets an AI agent pull in context from outside the repo, like Jira tickets or internal docs. Press Enter for the full definition. servers, including the MCP login flow.
When more than one agent works in the same repo, give each session its own checkout. Start the CLI with --worktree, and the agent runs in a new git worktree, so concurrent runs stop fighting over one working tree and its uncommitted edits. In the IDE, the /worktree command does the same.
Can I run several models on the same task at once?
Yes, and the CLI makes it easy. Open a terminal tab per model, start an agent in each and point them all at the same directory. One tab runs Cursor's in-house ComposerCursor's own fast coding model, tuned for the editor and priced well below frontier models; the recommended day-to-day model for executing a plan. Press Enter for the full definition. model, another a flagship model such as GPT-5.x, and a third an Opus model. Give every tab the same brief, and you have parallel agents producing competing implementations of the same thing.
Switch a tab's model from the slash menu, where you can also set its reasoning level. It's a fast way to compare models on real work instead of arguing about which is best in the abstract. Name each tab's output so the runs don't overwrite each other, or give each run its own worktree. Let all three finish, then read the diffs side by side and keep the one you trust.
Interactive diagram. Step through it with the Next and Previous controls below, or Tab to a region to read its detail.
Same directory, same brief, a different model per terminal tab, then compare the diffs.
How do I run the Cursor agent headlessly or in another editor?
agent -p "..." runs the agent headlessly: a prompt goes in and a result comes out, with no interactive UI. Use that form in CI jobs, git hooks and shell scripts, where nobody sits at a keyboard to approve steps. Pair it with tight permissions and a review gate, as you would any unattended automation. Cursor's docs disagree on whether it edits files by default: the headless guide says changes are only proposed unless you add --force, and the usage page says the agent has full write access in non-interactive mode. Test it on a throwaway branch before a pipeline depends on either behavior.
The Cursor agent isn't tied to one editor. Through ACPAgent Client Protocol. An open standard that lets any IDE host any coding agent; Cursor uses it to run inside JetBrains/IntelliJ and Android Studio. Press Enter for the full definition. it runs inside JetBrains IDEs such as IntelliJ and PyCharm, with the CLI's core Agent, Plan and Ask modes and the same models. A team that works in JetBrains IDEs can use the Cursor agent without switching editors.
ACPAgent Client Protocol. An open standard that lets any IDE host any coding agent; Cursor uses it to run inside JetBrains/IntelliJ and Android Studio. Press Enter for the full definition. is the Agent Client ProtocolAn open standard that lets any IDE host any coding agent; Cursor uses it to run inside JetBrains/IntelliJ and Android Studio via the Cursor CLI bridge. Press Enter for the full definition., an open standard for coding agents: any IDE that implements it can host any agent that implements it. On the Cursor side, ACP runs through the CLI. The same binary that runs agent in your terminal also runs the ACP bridge, so the JetBrains and Android Studio integrations are the CLI with a different front end.
MCPModel Context Protocol. A standard that lets an AI agent pull in context from outside the repo, like Jira tickets or internal docs. Press Enter for the full definition. config, slash commandsSaved multi-step prompts you trigger from the / menu, such as run tests, fix CI or open a pull request. Press Enter for the full definition., rules, skills, sub-agents and model selection mostly work the same way, so learning the CLI teaches you most of the ACPAgent Client Protocol. An open standard that lets any IDE host any coding agent; Cursor uses it to run inside JetBrains/IntelliJ and Android Studio. Press Enter for the full definition. surface. Cursor's ACP docs show where it differs: sessions support the three core modes, which leaves out Debug modeA mode that diagnoses a failure: it reproduces the issue, adds instrumentation and watches the logs, rather than reviewing a pull request. Press Enter for the full definition., and team-level MCP servers configured in the Cursor dashboard aren't supported in ACP mode.
The ACPAgent Client Protocol. An open standard that lets any IDE host any coding agent; Cursor uses it to run inside JetBrains/IntelliJ and Android Studio. Press Enter for the full definition. integration is powered by that CLI. A lot of it is similar or the exact same to the CLI.
How do I get the Cursor agent in Android Studio?
Install the JetBrains AI Assistant pluginA Cursor marketplace package that bundles MCP servers and skills (sometimes sub-agents and hooks); one click installs all of it into your Cursor instance. Press Enter for the full definition., then add Cursor from the ACPAgent Client Protocol. An open standard that lets any IDE host any coding agent; Cursor uses it to run inside JetBrains/IntelliJ and Android Studio. Press Enter for the full definition. registry in the IDE's AI chat. Cursor's JetBrains guide gives the steps: open the agent provider list, choose Add Agent from Registry, search for Cursor, install it and select it as your agent provider. The guide lists a paid Cursor plan as a prerequisite and doesn't list a separate CLI install. It names JetBrains IDEs such as IntelliJ and PyCharm, and it doesn't mention Android Studio by name.
The ACPAgent Client Protocol. An open standard that lets any IDE host any coding agent; Cursor uses it to run inside JetBrains/IntelliJ and Android Studio. Press Enter for the full definition. integrations track the CLI closely, but they aren't at parity. Debug modeA mode that diagnoses a failure: it reproduces the issue, adds instrumentation and watches the logs, rather than reviewing a pull request. Press Enter for the full definition. works in the CLI but isn't one of the ACP modes, so JetBrains IDEs and Android Studio don't have it. If a task needs Debug mode, run it from the terminal.
Which CLI reference pages matter for automation?
When you wire Cursor into CI or a custom tool, treat the CLI reference pages as the contract. The overview explains when the CLI is useful. The reference pages pin down what a script depends on: install commands, print mode, output formats, authentication, configuration and permissions.
- Reference
- Installation
- Use it when
- You need a repeatable install step for macOS, Linux, WSL or native Windows.
- Reference
- Headless CLI
- Use it when
- A script or CI job should send one prompt and collect a result without an interactive session.
- Reference
- GitHub Actions
- Use it when
- You want Cursor CLICursor's command line: the full agent, all modes and models, in the terminal and pipeable into scripts and CI. Press Enter for the full definition. inside a workflow file with install, path and secret handling in one place.
- Reference
- Authentication + configuration
- Use it when
- You need browser login locally, API keys in automation or
cli-config.jsonchecked before a run.
- Reference
- Output format + parameters
- Use it when
- A caller needs text, JSON or streamed JSON output and stable command flags.
- Reference
- Permissions
- Use it when
- A headless run needs an explicit allow or deny policy for shell commands and tools.
- Reference
- Slash commands + shell mode
- Use it when
- A human operator needs quick model switching, setup and shell execution from inside the session.
- Reference
- ACPAgent Client Protocol. An open standard that lets any IDE host any coding agent; Cursor uses it to run inside JetBrains/IntelliJ and Android Studio. Press Enter for the full definition.
- Use it when
- A custom client or editor wants to connect to the agent over Agent Client ProtocolAn open standard that lets any IDE host any coding agent; Cursor uses it to run inside JetBrains/IntelliJ and Android Studio via the Cursor CLI bridge. Press Enter for the full definition..
| Reference | Use it when |
|---|---|
| Installation | You need a repeatable install step for macOS, Linux, WSL or native Windows. |
| Headless CLI | A script or CI job should send one prompt and collect a result without an interactive session. |
| GitHub Actions | You want Cursor CLICursor's command line: the full agent, all modes and models, in the terminal and pipeable into scripts and CI. Press Enter for the full definition. inside a workflow file with install, path and secret handling in one place. |
| Authentication + configuration | You need browser login locally, API keys in automation or cli-config.json checked before a run. |
| Output format + parameters | A caller needs text, JSON or streamed JSON output and stable command flags. |
| Permissions | A headless run needs an explicit allow or deny policy for shell commands and tools. |
| Slash commands + shell mode | A human operator needs quick model switching, setup and shell execution from inside the session. |
| ACPAgent Client Protocol. An open standard that lets any IDE host any coding agent; Cursor uses it to run inside JetBrains/IntelliJ and Android Studio. Press Enter for the full definition. | A custom client or editor wants to connect to the agent over Agent Client ProtocolAn open standard that lets any IDE host any coding agent; Cursor uses it to run inside JetBrains/IntelliJ and Android Studio via the Cursor CLI bridge. Press Enter for the full definition.. |
Use the exact Cursor reference page for the behavior your automation depends on.
How do I manage the CLI's context budget?
Run /context to see what is using the context window, broken down by category. Check it as a session grows, because quality starts to slip well before the window is technically full.
Run /summarize to compact the conversation at roughly 50 to 60% of the context window, before performance starts to degrade. Switching models mid-session breaks the cache, so an unplanned switch can cost you both the cached context and some throughput. Decide on a model up front when you can.
When should I use the Cursor CLI, and with what guardrails?
Good fits are failure triage in CI and longer refactors that you start from a script and walk away from. Because the CLI is terminal-native, it slots into existing automation, but keep a human review gate. The CLI produces the changes that reach review, and merging them stays a deliberate, human step.
Scope what the agent may do before you let it run unattended: confine it to a branch, set permissions and shell access on purpose, and require review of its output. Give it more autonomy only once your own codebase gives you evidence that it's safe. Check the official CLI docs for the current commands, flags and permission model before you wire it into a pipeline.
Frequently asked questions
Is the Cursor CLI a replacement for the editor?
No. It is the same agent in a terminal-native, scriptable form. Use the editor for interactive editing and visual review, and the CLI for headless, CI and automation work.
Can the Cursor CLI merge code on its own?
Treat merging as a human gate. The CLI edits files and runs commands within the permissions you set. Keep review and merge as deliberate steps instead of giving it unattended write access to your main branch.
What does the & prefix do in the CLI?
It hands the conversation to a cloud agent. Prefix your message with & and the CLI starts a cloud agent that works on its own branch, asynchronously, so you can keep working locally while it runs. To review changes in the editor instead, /open (or its alias /cursor) opens the repository's Git root in Cursor.
How do I run several agents on the same repo without conflicts?
Start each session with agent --worktree so it runs in its own git worktree. That keeps concurrent agents from fighting over one working tree, and Cursor's worktree docs suggest worktrees for exactly that case. In the IDE, the /worktree command does the same.
When should I compact the CLI context?
At roughly 50 to 60% of the context window, before performance starts to degrade. Run /context to see what is filling the window and /summarize to compact it. Avoid switching models mid-session unless you need to, because that breaks the cache.
Can I use the Cursor agent in JetBrains or Android Studio?
Yes. Through ACP, the Cursor agent runs inside JetBrains IDEs such as IntelliJ and PyCharm, with the CLI's Agent, Plan and Ask modes and the same models. Install the JetBrains AI Assistant plugin, then in the IDE's AI chat choose Add Agent from Registry, install Cursor and select it as your agent provider. Android Studio uses the same plugin and registry flow. Cursor's guide lists a paid Cursor plan as a prerequisite and no separate CLI install.
Sources & last verified
- Cursor CLI overview
- Cursor CLI installation
- Cursor CLI headless
- Cursor CLI GitHub Actions
- Cursor CLI ACP
- Cursor CLI changelog
- Cursor CLI authentication
- Cursor CLI configuration
- Cursor CLI output format
- Cursor CLI parameters
- Cursor CLI permissions
- Cursor CLI slash commands
- Cursor CLI terminal setup
- Cursor CLI shell mode
- Cursor CLI: using Agent (modes and worktrees)
- Cursor docs: Worktrees (the IDE's /worktree command)
Cursor ships frequently. Last updated October 28, 2026.