Guide
Cursor CLI: Headless, Terminal-Native Coding (2026)
The Cursor CLI brings Cursor's agent to your terminal so you can run it scriptably and headlessly: in CI, over SSH or piped into other tools. Reach for it when work is automation-shaped rather than interactive editing. It proposes changes under permissions you set, and merging stays your call.
On this page
What the Cursor CLI is
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. The graphical editor is still the place for interactive editing and visual diff review; the CLI is the place for automation and long, unattended runs.
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 complements the editor; it does not replace it.
This is covered hands-on in CLI, Headless and ACP — 5 short modules, free to read.
The commands that matter
Type agent in any shell to open the Cursor agent. From there a slash-command menu is your control surface: it exposes 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 wired up. A few prefixes change how a turn runs rather than naming a command, and those are where most of the power hides.
& is a distinct mode. Prefix your message with it and the CLI spins up a cloud agent that opens its own branch and works async, so you can keep typing locally while it runs somewhere else. ! drops to a shell command from inside the agent without leaving the session. /cursor jumps from the terminal into the Cursor IDE and ports the conversation across, so you can hand a started task to the editor for visual review.
- 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
- Cloud-agent mode: opens its own branch, runs async
- Type this
- ! command
- What it does
- Run a shell command from inside the agent
- Type this
- /worktree
- What it does
- Give this session an isolated git worktree
- Type this
- /cursor
- What it does
- Jump into the Cursor IDE, carrying the conversation
- 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 | Cloud-agent mode: opens its own branch, runs async |
| ! command | Run a shell command from inside the agent |
| /worktree | Give this session an isolated git worktree |
| /cursor | Jump into the Cursor IDE, carrying the conversation |
| agent -p "..." | Run headlessly for CI and scripts, no interactive UI |
Slash commands name actions; the &, ! and -p prefixes change how a turn runs.
Shift+Tab cycles the run mode without leaving the prompt. It rotates through auto-run-all-commands, plan mode, ask mode, debug mode and plain agent mode, so you can drop into plan before a big change or flip to ask when you only want answers. The same terminal also exposes 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. to create rules, skills and sub-agents on the spot, plus the 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. login flow.
When more than one agent touches the same repo, give each session its own checkout with /worktree. Each gets an isolated git worktree, so concurrent runs stop fighting over the same working tree and uncommitted edits. It is the simplest way to keep parallel work from stepping on itself.
Can I run several models on the same task at once?
Yes, and the CLI makes it cheap to do. Open a terminal tab per model, start an agent in each, and point all of them at the same directory. One runs on 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 on a flagship model like GPT-5.x, a third on Opus 4.x. Give every tab the same brief and you have fanned out parallel agents producing competing implementations of the same thing.
You switch a tab's model from the slash menu (or by typing agent then model), and you can set its reasoning level there too. It is a fast way to A/B the models on real work instead of arguing about which is best in the abstract: name the outputs, let all three run, then read the diffs side by side and keep the one you trust. The editor can do the same through separate chats, but the terminal makes the parallelism obvious.
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.
Headless runs and other editors
agent -p "..." runs the agent headlessly: no interactive UI, just a prompt in and a result out. That is the form you drop into CI jobs, git hooks and shell scripts where nothing is sitting at a keyboard to approve steps. Pair it with tight permissions and a review gate, the same way you would any unattended automation.
The Cursor agent is not bound 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, carrying the same modes and models you use in the terminal and in Cursor itself. If your team lives in JetBrains, the agent meets them there rather than asking them to switch 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. The Cursor side of that is 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 wearing 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 all behave the same way. Learn the CLI once and you know the ACP surface.
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.
Android Studio is the clearest example. 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., install the 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. locally (it runs the bridge, so you need the binary), then in the IDE's AI chat install the Cursor agent 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 and authenticate either in the chat or via the CLI. Auth and the model you set in the CLI propagate up. You get the full Cursor agent experience inside Android Studio without leaving the IDE.
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 are not yet 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., for example, is available in the CLI terminal but has not landed in the JetBrains ACP integration. If a mode you rely on is missing inside the IDE, drop to the terminal for that run.
Which CLI reference pages matter for automation?
Treat the CLI reference docs as the contract when you wire Cursor into CI or a custom tool. The high-level guide explains when the CLI is useful; the reference pages pin down install commands, print mode, output formats, auth, config, permissions and the shell shortcuts that tend to break scripts when they drift.
- 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.
Watch the context budget
The CLI shows per-agent context consumption as a running figure at the bottom of the session. As a session fills its window, quality starts to slip well before the window is technically full.
Compact the conversation at roughly 50-60% of the context window, before performance begins to degrade rather than after. Switching models mid-session breaks the cache, so an unplanned model swap can cost you both the cached context and a chunk of throughput. Decide on a model up front when you can.
When to reach for it
Good fits: failure triage in CI, and longer refactors you want to start from a script and walk away from. Because it is terminal-native, it slots into existing automation, but keep a human review gate. The CLI raises what arrives at review, and merging stays a deliberate, human step.
Permissions and review
Scope what the agent may do before you let it run unattended: confine it to a branch, set permissions and shell access deliberately and require review on its output. Treat higher autonomy as something earned with evidence on your codebase, not the starting point. 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; use the CLI for headless, CI and automation work. Most teams use both.
Can the Cursor CLI merge code on its own?
Treat merging as a human gate. The CLI proposes changes within the permissions you set; keep review and merge as deliberate steps rather than handing it unattended write access to your main branch.
What does the & prefix do in the CLI?
It is a distinct cloud-agent mode. Prefix your message with & and the CLI spins up a cloud agent that opens its own branch and works async, so you can keep working locally while it runs. Use /cursor to jump into the Cursor IDE and carry the conversation over for review.
How do I run several agents on the same repo without conflicts?
Give each session an isolated git worktree with /worktree. That keeps concurrent agents from fighting over one working tree, which is the recommended setup when multiple agents touch the same repo.
When should I compact the CLI context?
Compact at roughly 50-60% of the context window, before performance starts to degrade. The CLI shows per-agent context consumption so you can see when you are close. Avoid switching models mid-session unless you need to, since that breaks the cache.
Can I use the Cursor agent in JetBrains?
Yes. Through ACP the Cursor agent runs inside JetBrains IDEs such as IntelliJ and PyCharm, with the same modes and models you get in the terminal and in Cursor. For CI and scripts, run it headlessly with agent -p "...".
How do I get Cursor inside Android Studio?
Install the JetBrains AI Assistant plugin, install the Cursor CLI locally (it runs the Agent Client Protocol bridge), then in Android Studio's AI chat install the Cursor agent from the ACP registry and authenticate in the chat or via the CLI. The model you set in the CLI propagates up. ACP is an open standard, so this is the same CLI engine behind a different IDE front-end.
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 ships frequently. Last updated June 30, 2026.
Keep reading
Rather do it than read about it? Run 11 interactive Cursor walkthroughs in a simulated editor. Free, no account needed.