Hero Background

Next-Gen App & Browser Testing Cloud

Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Next-Gen App & Browser Testing Cloud
AIAgent TestingCoding

Running Cursor CLI: Install, Modes, and CI Automation

Installing Cursor CLI on every platform, the three modes, the full command reference, a real CI example, and how to verify what it actually did.

Author

Mythili Raju

Author

Author

Salman Khan

Reviewer

Published on: August 27, 2026

Run agent -p "fix the login bug" --force in a terminal with no display attached, and the only feedback you get back is text: a summary of what changed, and an exit code. Nothing in that output ever rendered a page.

That is Cursor CLI working exactly as designed. Cursor built its reputation as an editor-first tool, and the CLI is the terminal half of the same product: same account, same models, none of the diff view.

This covers installation, the three modes, the complete current command reference, a real CI example, and what to do about the part the CLI cannot see for itself.

TL;DR

Cursor CLI is Cursor's agent running as a terminal program: one install command, the same account and model access as the editor, and three modes (Agent, Plan, Ask) usable interactively or headlessly for scripts and CI. It has no GUI of its own, so anything it reports about a rendered page has to be checked somewhere else.

  • One binary, three modes: Agent edits by default, Plan proposes without touching files, Ask stays read-only.
  • Headless by design: the -p flag switches to non-interactive mode with text, JSON, or streamed JSON output, built for scripts and CI from the start.
  • Model choice per session: the --model flag picks the model for that run rather than locking you to one family.
  • Verification: a headless run confirms the code changed, not that a page renders. TestMu AI's Kane CLI closes that specific gap with a real Chrome browser and a pass or fail exit code.

What Cursor CLI Actually Is

Cursor's own CLI documentation defines it in one sentence: it "lets you interact with AI agents directly from your terminal to write, review, and modify code."

The relationship to the editor matters more than the definition. Cursor built its identity as an editor-first tool, and the CLI is not a separate product bolted on afterward; it shares the same account, the same model access, and the same underlying agent as the IDE. What it does not share is the diff view, the inline suggestions, or any of the visual surface that makes the editor an editor.

  • Same account, same models - sign in once and both surfaces draw on the same plan and model access.
  • Runs anywhere a terminal does - SSH sessions, containers, CI runners, anywhere the editor cannot follow.
  • No GUI dependency - every interaction is text in, text out, which is exactly what makes it scriptable.

Installing and Signing In

One command per platform, both downloading and adding the binary to your PATH.

# macOS, Linux, or WSL
curl https://cursor.com/install -fsS | bash

# Windows PowerShell
irm 'https://cursor.com/install?win32=true' | iex

Interactive use signs in through the CLI's own login flow against your existing Cursor account. Headless and CI use skip that flow entirely and authenticate with an API key instead:

ContextAuth method
Interactive, local terminalThe CLI's own sign-in flow, same Cursor account as the editor
Headless, CI, or scriptedCURSOR_API_KEY environment variable, typically set from a repository secret

The Three Modes

Every session runs in one of three modes, and the mode decides how much the agent is allowed to touch.

ModeTriggerWhat it does
Agent (default)No flag neededReads, writes, and modifies files to complete the task
Plan/plan, --plan, or --mode=planProposes an approach without editing anything, for review before committing to it
Ask/ask or --mode=askRead-only question answering, no file changes possible

Plan mode is the one worth defaulting to on anything you have not scoped tightly. It costs one extra round trip to review the proposal, and that round trip is cheaper than an Agent-mode run that touched the wrong files.

The Full Command Reference

The flags that actually get used, gathered from Cursor's separate overview and headless documentation pages into one table.

Flag or commandWhat it does
-p "prompt"Triggers non-interactive mode: runs once, prints a result, exits
--forceAuto-approves file modifications instead of pausing for confirmation
--output-format textClean, final-answer-only output, the default for a human reading the terminal
--output-format jsonA single structured JSON object, built for a script to parse
--output-format stream-jsonOne JSON object per message, for message-level progress tracking
--stream-partial-outputStreams incremental deltas within stream-json mode
--model <name>Selects the model for that session (Cursor's own docs use gpt-5 as the example)
--mode=plan / --mode=askSets Plan or Ask mode from the command line instead of the in-session slash command
& (prefix on a message)Hands the request to a Cloud Agent instead of running it locally
/sandboxSandbox controls for the local run, inside an interactive session
-w / --worktreeRuns the session in an isolated Git worktree instead of the current checkout

A complete headless invocation combines several of these in one line:

agent -p --force --output-format json \
  "Add input validation to the login form in auth.ts" \
  --model gpt-5
Note

Note: TestMu AI's Kane CLI takes the same plain-English objective and runs it against a real Chrome browser instead of source code. Try TestMu AI free!

Running It in CI

Cursor's GitHub Actions documentation gives the working shape: install the CLI, export the API key from a repository secret, then call the agent in a run step.

- name: Install Cursor CLI
  run: |
    curl https://cursor.com/install -fsS | bash
    echo "$HOME/.cursor/bin" >> $GITHUB_PATH

- name: Run Cursor Agent
  env:
    CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}
  run: |
    agent -p "Your prompt here" --model gpt-5

That example stops at running the agent. It does not gate the pipeline on whether the change actually worked, because the CLI has no way to check that from inside a terminal. The verification section below covers the step this workflow is missing.

The same pattern generalizes past GitHub Actions: any CI system that can export an environment variable and run a shell command can call agent -p the same way.

Cursor CLI vs Other Terminal Agents

Several coding agents now ship a terminal mode. What differs is which product came first.

DimensionCursor CLIClaude Code
Where it startedTerminal counterpart added to an editor-first productTerminal-first from launch
Delegation to smaller unitsCloud Agent handoff via the & prefixNamed subagents with their own frontmatter, context window, and tool scope
Lifecycle hooksNot part of the CLI's documented surfacePreToolUse, PostToolUse, Stop, and more, each with defined exit-code semantics
Headless outputtext, json, or stream-json via --output-formatNewline-delimited JSON in agent mode
Model choice--model per sessionPer-subagent model field, including cheaper models for narrow tasks

Neither difference makes one strictly better; they reflect different starting points. A team already living in the Cursor editor gets a terminal mode with zero account switching. A team that wants fine-grained control over delegated work gets more surface in Claude Code's subagent system. Our breakdown of OpenCode vs Claude Code covers a third point on the same map for teams weighing an open-source terminal agent instead, and our Windsurf vs Cursor comparison covers the editor-level choice one level up from the terminal.

Can You Trust What It Says

For code-level claims, usually yes. A -p run that says it added a function, or that a test command exited 0, is reporting something it can actually check: the file on disk, the process exit code.

Delegating a bounded research task and trusting a compressed answer back is a real pattern, and it is worth showing rather than describing. Writing this article required confirming that today's sibling piece on testing AI coding tools did not already cover Cursor CLI specifically, so we spawned a subagent to read it and report back. It returned exactly this:

2) "Cursor CLI" mentioned? No. The term "Cursor CLI" never appears. All
references are to the Cursor editor/IDE and its rules system (.mdc files,
.cursor/rules, chat sessions) - not the terminal/headless cursor.com/cli
product.

3) Covers Cursor CLI installation/flags/modes/CI? No. Zero mention of
Cursor CLI installation, CLI flags, Agent/Plan/Ask modes, or CI/CD usage
of the terminal product. This is entirely open territory for your new
article.

That subagent read a 650-line file and returned seven lines. The compression is trustworthy precisely because the claim it is making, whether a specific string appears in a specific file, is a claim its own tools (Read, Grep) can actually verify.

A UI claim is a different kind of claim. When agent -p "fix the login bug" --force reports success, it is reporting that the diff compiles and, at best, that a test command exited 0. Nothing in that toolchain opened a browser, so nothing confirms the login form actually renders or the fixed field actually accepts input. Kane CLI from TestMu AI is built for that specific gap: a plain-English objective, a real Chrome browser, and a standard exit code (0 passed, 1 failed, 2 environment error, 3 timeout) that a CI step can check the same way it checks any other command's exit status.

npm install -g @testmuai/kane-cli
kane-cli login --username "$LT_USERNAME" --access-key "$LT_ACCESS_KEY"

kane-cli run --agent --headless \
  "sign in with the test account, open the dashboard, assert the page
   shows the account name" \
  --url https://www.testmuai.com/selenium-playground/

Dropped into the same CI job right after the Cursor CLI step, that command is the piece the official GitHub Actions example above stops short of. The Kane CLI introduction documentation covers authentication and the full command reference.

Get Kane CLI certified for free with TestMu AI

Where the Terminal Half Falls Short

Three limits worth planning around before wiring it into a workflow.

  • No visual review surface - the editor's diff view, inline suggestions, and hover previews have no terminal equivalent; --force means the agent edits without you seeing anything but the eventual text summary.
  • UI correctness is structurally invisible - covered above, and it is the single most consequential gap for anyone shipping rendered features from a headless run.
  • No documented hook or subagent system - Cursor's own CLI documentation does not describe lifecycle hooks or named delegated agents the way Claude Code's does, so fine-grained control over a multi-step run is more limited today.

None of these rule out headless use. They rule out treating a text summary as proof of anything the summary cannot actually see.

Getting Started Checklist

Four steps cover a working setup end to end.

  • Install with the platform-specific command above, then sign in interactively once to confirm the account and model access are what you expect.
  • Default to Plan mode on anything you have not scoped tightly; drop to Agent mode once the proposal looks right.
  • Wire agent -p into one CI job using the GitHub Actions pattern above, with CURSOR_API_KEY as a repository secret.
  • Add a browser-verification step immediately after it for any change that touches rendered UI, so the pipeline checks the one thing the agent cannot.

The terminal half of Cursor is genuinely useful for exactly what it is built for: running the same agent somewhere the editor cannot go. Start with the Kane CLI documentation to close the one gap it was never built to cover.

Author

...

Mythili Raju

Blogs: 51

  • Twitter
  • Linkedin

Mythili is a Community Contributor at TestMu AI with 3+ years of experience in software testing and marketing. She holds certifications in Automation Testing, KaneAI, Selenium, Appium, Playwright, and Cypress. At TestMu AI, she leads go-to-market (GTM) strategies, collaborates on feature launches, and creates SEO optimized content that bridges technical depth with business relevance. A graduate of St. Joseph’s University, Bangalore, Mythili has authored 35+ blogs and learning hubs on AI-driven test automation and quality engineering. Her work focuses on making complex QA topics accessible while aligning content strategy with product and business goals.

Reviewer

...

Salman Khan

Reviewer

  • Linkedin

Salman is a Test Automation Evangelist and Community Contributor at TestMu AI, with over 6 years of hands-on experience in software testing and automation. He has completed his Master of Technology in Computer Science and Engineering, demonstrating strong technical expertise in software development, testing, AI agents and LLMs. He is certified in KaneAI, Automation Testing, Selenium, Cypress, Playwright, and Appium, with deep experience in CI/CD pipelines, cross-browser testing, AI in testing, and mobile automation. Salman works closely with engineering teams to convert complex testing concepts into actionable, developer-first content. Salman has authored 120+ technical tutorials, guides, and documentation on test automation, web development, and related domains, making him a strong voice in the QA and testing community.

Add to Google preferred sources

Summarise with AI

Copied to Clipboard!
...

3000+ Browsers. One Platform.

See exactly how your site performs everywhere.

Try it free
...

Write Tests in Plain English with KaneAI

Create, debug, and evolve tests using natural language.

Try for free

Cursor CLI FAQs

Did you find this page helpful?

More Related Blogs

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests