cursor-agent
Skill0 starsChanged 5 months agoMITView on GitHub
Drive Cursor's CLI agent non-interactively via `cursor-agent -p` (headless print mode) to delegate coding work to a second, independent agent. Use this skill when the user wants a second opinion on a design or bug, an independent implementation plan, an independent code review of a diff or PR, a self-contained implementation task run headlessly, isolated work in a git worktree, or cross-checking your own work against another model. Also use when the user explicitly mentions "cursor-agent", "cursor agent", "cursor CLI", or asks to "have cursor plan / look at / build / review" something.
- Reads credentials
6 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- AlekseiUL/heisenberg-team-GPTtheir own version, first seen Nov 1, 2026
- AlekseiUL/heisenberg-teamtheir own version, first seen Nov 1, 2026
- ejarmand/skillstheir own version, first seen Sep 23, 2026
- payne0420/claude-ultracode-agentsedited, first seen Jun 8, 2026
- Vesely/skillstheir own version, first seen May 1, 2026
- kunwl123456/zeroclaw-skills-collectiontheir own version, first seen Feb 19, 2026
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- payne0420/claude-ultracode-agents★ 099% same
Wrote their own version · 5
- Vesely/skills★ 28same name
- kunwl123456/zeroclaw-skills-collection★ 27same name
- AlekseiUL/heisenberg-team★ 17same name
- AlekseiUL/heisenberg-team-GPT★ 9same name
- ejarmand/skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository11 other files it gives its agents.
- codex-execSkill
- eval-loopSkill
- find-docsSkill
- forgejoSkill
- harness-usageSkill
- llm-endpointSkill
- loopifySkill
- opencodeSkill
- scope-to-shipSkill
- track-usageSkill
- ultracode-external-agentsSkill
The file
We split this skill into the rules it gives an agent
6 rules. 0 are common, 3 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 25
Verify it is available and authenticated before relying on it:
- Distinctive: line 114
Use this to challenge your own conclusion, then reconcile the two answers for the user — calling out where they agree or diverge.
- Very specific: line 126
If you need a *hard* guarantee it won't touch files while planning, use --mode ask instead of --plan (ask has no write tools) and just ask …
- Distinctive: line 185
Run a delegated task in a separate worktree so it never touches your working tree — ideal for background or parallel work.
- Very specific: line 230
&withoutwait→ orphaned children: If the parent shell exits before the children finish, they die mid-flight and make no edits. - Very specific: line 250
Add --stream-partial-output for finer text deltas.
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
cursor-agent (headless)
cursor-agent -p runs Cursor's coding agent non-interactively (headless print
mode): one prompt in, the agent works autonomously, output to stdout. It is a
separate coding agent from you — useful as an independent implementer, reviewer,
or second opinion. Treat it like delegating to a capable peer in another terminal.
Verify it is available and authenticated before relying on it:
cursor-agent --version # e.g. 2026.05.28-a70ca7c
cursor-agent status # "Logged in as ..." — else run `cursor-agent login`Auth can also come from CURSOR_API_KEY or --api-key <key>. If missing, tell the
user — do not silently do the work yourself without saying so.
Core invocation
# Headless: -p / --print is REQUIRED for non-interactive use.
# --trust is needed for the agent to act in the dir (safe here: ask can't write).
cursor-agent -p --trust --mode ask "summarize what this repo does"
# Pick output format and model
cursor-agent -p --trust --mode ask "explain the auth flow" --output-format text --model composer-2.5The prompt is a positional argument. Without -p, cursor-agent launches its
interactive TUI — always pass -p when scripting. The directory must be trusted
(--trust) for the agent to do anything — even read-only ask runs.
Safety & permissions — read this first
Critical difference from codex: cursor-agent has no hard OS-level read-only
sandbox like codex's -s read-only. In -p mode the agent "has access to all
tools, including write and shell" by default. Read-only is controlled by mode,
and the two modes are NOT equally safe (verified empirically):
| Mode | Write capability | Use for |
--mode ask | Reliably read-only — has no write/edit tools. Even with --trust/--yolo it refuses to edit (it prints the shell command instead). In testing it wrote 0/4 times when pushed. | analysis, second opinions, code review — anything that must not change files |
--mode plan / --plan | Soft read-only only. Planning-focused, but it retains write tools and will make edits if pushed — it wrote 2/4 times when explicitly told to. Treat as "usually read-only," NOT a guarantee. | producing a plan you'll review — not as a write guard |
| (default mode) | Full write + shell | implementation |
So: for a true read-only run, use --mode ask (or run in a disposable
worktree). Do not rely on --plan to prevent edits.
Trust & approvals (these gate whether it can act, not the mode's read/write nature):
| Goal | How |
| Let it act at all | the directory must be trusted. Pass --trust (headless only); trust then persists per-directory. An untrusted dir refuses everything, even --mode ask. |
| Auto-approve commands | -f / --force / --yolo (allow commands unless explicitly denied) |
| OS sandbox toggle | --sandbox enabled / disabled (overrides config) |
| Isolate writes from your tree | -w / --worktree (separate git worktree) |
Note --trust/--yolo do not turn ask into a writer — ask stayed
read-only in every test. But combining --trust with --plan does let plan's
soft mode make edits. Default to --mode ask for analysis; for write tasks use
default mode with --trust, and tell the user.
⚠️ stdin is ignored. Unlike codex, cursor-agent does not read a piped diff
or file from stdin (git diff | cursor-agent -p "review this" → it sees nothing).
Verified: it replied NO_STDIN_RECEIVED. Put context in the prompt, use $(...)
substitution, or have the agent run the command itself (e.g. "run git diff").
Key flags
| Flag | Purpose |
-p, --print | headless / non-interactive (required for scripting) |
--output-format <fmt> | text (answer only) | json (final result object) | stream-json (NDJSON events) |
--stream-partial-output | stream text deltas (with --print + stream-json) |
--mode <mode> | ask (reliably read-only Q&A) | plan (planning; soft read-only — can still edit) |
--plan | shorthand for --mode plan (soft read-only — see Safety) |
-m, --model <model> | e.g. sonnet-4, gpt-5, opus-4-8-thinking; default is Composer 2.5. --list-models to see all |
--trust | trust the workspace so it can edit/run (headless only) |
-f, --force / --yolo | allow all commands unless explicitly denied |
--sandbox <mode> | enabled | disabled |
--resume [chatId] / --continue | resume a specific / the previous session |
-w, --worktree [name] | run in an isolated git worktree (--worktree-base <branch> to pick its base) |
--workspace <path> | set the workspace directory |
Workflows
1. Second opinion / pair programming
Get an independent take without letting it touch files — use --mode ask.
cursor-agent -p --trust --mode ask "We're choosing optimistic locking vs a queue for X. Trade-offs?"
# Cross-check a bug hypothesis (let the agent read the files itself)
cursor-agent -p --trust --mode ask "Why might test/worker.test.ts be flaky? Inspect src/worker.ts."Use this to challenge your own conclusion, then reconcile the two answers for the user — calling out where they agree or diverge.
2. Planning
Cursor has a plan mode that investigates and proposes an implementation plan. It's planning-focused but only soft read-only (it can still edit if pushed — see Safety), so use it to get a plan, not as a write guard.
cursor-agent -p --trust --plan "Plan how to add OAuth login: files to touch, ordered steps, risks, tests. Do not edit anything."If you need a hard guarantee it won't touch files while planning, use --mode ask
instead of --plan (ask has no write tools) and just ask it to produce the plan.
Plan-as-second-opinion: have cursor plan independently and reconcile with your own. Plan→execute: feed the plan into a fresh write-enabled run (don't rely on resume to flip modes):
cursor-agent -p --trust "Implement this plan step by step: $(cat plan.md)"3. Code review
There's no dedicated review subcommand. Use --mode ask (reliably read-only)
and have the agent inspect the diff itself — it can run git diff in ask mode.
Remember stdin is ignored, so tell it to run git rather than piping the diff in:
cursor-agent -p --trust --mode ask "Review the uncommitted changes for correctness bugs and risky edge cases. Run git diff yourself. Reference file:line and quote each buggy line."
# Or against a base branch:
cursor-agent -p --trust --mode ask "Review the diff between HEAD and origin/main. Run the git command yourself. Flag bugs by file:line."Verified: on a repo with a planted operator bug + an unguarded division, composer-2.5
in ask mode ran git diff and reported both, with a file:line table. Relay findings
to the user; offer to fix, but don't auto-apply unless asked.
4. Delegated implementation (headless)
Hand off a self-contained task. Needs --trust (and --yolo if it must run build/
test commands unattended).
cursor-agent -p --trust "Add input validation to the /signup handler and a unit test for it."Then review what it changed (git diff) before trusting it — inspect it like any
other diff. For risky tasks, isolate the changes in a worktree (workflow 7).
5. Structured / scriptable output
--output-format json emits a single final result object you can parse:
cursor-agent -p --trust --mode ask "One-line summary of this repo" --output-format json | jq -r .resultThe JSON object includes result (the answer), session_id, and usage. Verified:
jq -r .result cleanly extracts just the answer.
6. Multi-turn (resume / continue)
Continue a prior session with its context retained.
cursor-agent -p --continue "now also add the migration"
cursor-agent -p --resume <chatId> "address the review comments"
cursor-agent ls # list resumable sessions
ID=$(cursor-agent create-chat) # pre-create a session id for scripting7. Isolated / parallel work (git worktree)
Run a delegated task in a separate worktree so it never touches your working tree — ideal for background or parallel work.
cursor-agent -p --trust -w feature-x "Implement feature X end to end."
# Lands in ~/.cursor/worktrees/<repo>/feature-x ; review and merge when done.For long tasks, launch it in the background (in this harness, run_in_background:
true) and capture output to a file.
8. Headless parallel fan-out (one agent spawns many)
cursor-agent -p can spawn child cursor-agent -p processes and run them in
parallel — either you script the loop, or a --force parent does it through its
own shell tool (in -p it "has access to all tools, including write and shell").
There is no native fan-out/join subcommand and no recursion guard
(CURSOR_AGENT=1 is set in children but nothing blocks on it — verified nesting
runs fine), so you hand-roll it. The canonical pattern:
# One worktree per child (no write collisions) + --force (headless approval) + json (mergeable)
for task in A B C; do
( cursor-agent -p --force -w "wt-$task" \
"<fully self-contained prompt — stdin is ignored, inline ALL context>" \
--output-format json > "out-$task.json" 2>&1 ) &
done
wait # MANDATORY — see trap 3
# merge: read out-*.json (.result, .usage), then `git -C <worktree>` to collect editsVerified empirically: 3 children in separate worktrees ran truly concurrently
(~37s wall, staggered finishes, each worktree held only its own edit, main tree
untouched); 6 concurrent ask children = 6/6 success, no rate-limiting; a single
--force parent, told to isolate per-child, autonomously created the right
worktrees and captured each child's stdout. Three silent failure modes — each
produces no error, just wrong/empty results:
- No
--force→ children never run. In-pthere's no human to approve the spawn command, so the parent's shell calls are rejected outright.--force/--yolois mandatory for the parent. (Verified: without it, "every attempt to execute it via the Shell tool was rejected.") - Shared tree → silent lost update. Two concurrent writers on the same file
with no worktree → one edit silently vanished (no error, no
index.lock). Give every child its own-w/--worktree; isolation was perfect in every test. &withoutwait→ orphaned children. If the parent shell exits before the children finish, they die mid-flight and make no edits. Alwayswait(ornohup/disownfor true fire-and-forget). (Verified: the parent's first attempts lost their children exactly this way until it addedwait.)
Auth rides on the on-disk login (no CURSOR_API_KEY needed locally; set it for CI);
--trust is sticky per-dir so children inherit it. Latency stacks ~20-30s per
nesting layer, so keep nests shallow. Tell the agent to isolate explicitly — it
self-isolates correctly when instructed but won't reliably infer it; for determinism,
script the loop yourself rather than asking one -p agent to orchestrate.
Output / event format
--output-format text→ just the final answer text.--output-format json→ one final object:{"type":"result","result":"...","session_id":"...","usage":{...}}. Extract the answer with| jq -r .result.--output-format stream-json→ NDJSON event stream (verified types):system(init: model, cwd,permissionMode),user,assistant,text/word(incremental text),tool_call(one per file edit / shell command),connection/retry(network-drop recovery, withattemptcounter), thenresult. Add--stream-partial-outputfor finer text deltas.
# Watch progress as a stream
cursor-agent -p "build the feature" --trust --output-format stream-jsonMonitoring a running instance (liveness)
Tell a backgrounded / orchestrator-owned run's state apart — finished, still working, or wedged — without killing anything. All checks are read-only.
pgrep -fl cursor-agent # alive? (also matches wrapper shells of other runs)
ls -l out.txt # the redirected-stdout file
find ~/.cursor/chats -type f -mmin -2 # session store (store.db-wal) touched = an agent is working
find ~/.cursor/projects/*/agent-transcripts -name '*.jsonl' -mmin -2 # transcript appended during multi-step runs- Finished: process gone + stdout file non-empty. ⚠️ With
--output-format textthe file stays 0 bytes until the very end (verified) — file growth is a progress signal only withstream-json, which appends events every few seconds mid-run (verified). - Still working: process alive + a file under
~/.cursor/chats/<hash>/<chat-id>/or~/.cursor/projects/<cwd-slug>/agent-transcripts/<id>/<id>.jsonlfresh within ~2 min. Both dirs are shared by all runs — match<cwd-slug>(the run's cwd with/→-, e.g.Users-payne-Github-myrepo) to your run before trusting it. - Wedged: process alive but its session files untouched for 10+ min (heuristic). On slow networks a turn can legitimately take minutes — check twice before judging.
- Network drops (verified by cutting the connection mid-stream): it reconnects
with exponential backoff and resumes cleanly when the network returns (15 s outage
→ exit 0, intact answer); if it never returns, it gives up after ~10 attempts /
~7 min with exit 1 and
Connection failed repeatedlyon stderr — it does not wedge. Instream-json, each attempt is visible as a{"type":"connection","subtype":"reconnecting","attempt":N}+{"type":"retry"}event pair, so a watcher can tell "retrying" from "dead".
Context files
Cursor reads AGENTS.md and .cursor/rules/* for project/user conventions. For a
one-off run that should follow specific rules without editing those files, put the
rules directly in the prompt. cursor-agent generate-rule scaffolds a new rule.
Gotchas
- No hard read-only sandbox. Unlike codex's
-s read-only, safety is by mode.--mode askis reliably read-only (no write tools);--planis only soft read-only and wrote 2/4 times when pushed — don't trust it as a write guard. - stdin is ignored — piping
git diffin does nothing. Embed context in the prompt or have the agent run the command itself. - Untrusted dirs refuse to act — pass
--trust(trust persists per-dir).--trust/--yolodon't makeaskwrite, but they do let--planedit. -pis mandatory for scripting — without it you get the interactive TUI.- Review before trusting writes — inspect
git diff; consider-wworktree isolation for risky tasks. - It's a different model (Cursor's Composer by default, or
--model sonnet-4/gpt-5/etc.) — when used as a second opinion, surface both views rather than assuming cursor is right. - Don't leak secrets into prompts sent to an external model.
- Parallel fan-out has three silent traps (see workflow 8): no
--force→ children silently never run; shared tree → silent lost-update (use one-wworktree per child);&withoutwait→ parent exit orphans the children.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

