cursor-subagent

Offload a command's implementation work to the Cursor agent CLI (`agent -p`, stream-json, `--resume` to keep one conversation) on Composer (`#composer`) or `glm-5p3-flash` (`#glm`), with the smallest allowed subagent as its driver (Sonnet · low on Claude Code; GLM · low on Cursor — on Cursor only the GLM and Composer model families may be used, and `-flash` variants are preferred wherever a family offers them): it starts turns, follows and judges the agent's stream, and resumes until the stage is really done. Applies to the implementation commands — `/green`, `/pr-wrap`, `/fix-pr`, the rows `/yolo` runs, and `/yolo-pr-stack`'s `[G]`/`[W]`/`[F]` stages. Planning always stays with the session's own model. Runs on this machine. The main agent checks the Cursor agent is installed and logged in and guides the user through both when not. Use ONLY when the user asks for it — `#cursor-subagent` (or `#composer`), `#glm`, or words like "let Composer do it" / "offload to Cursor". Never choose ...

¿Qué es cursor-subagent?

cursor-subagent is a Claude Code agent skill that offload a command's implementation work to the Cursor agent CLI (`agent -p`, stream-json, `--resume` to keep one conversation) on Composer (`#composer`) or `glm-5p3-flash` (`#glm`), with the smallest allowed subagent as its driver (Sonnet · low on Claude Code; GLM · low on Cursor — on Cursor only the GLM and Composer model families may be used, and `-flash` variants are preferred wherever a family offers them): it starts turns, follows and judges the agent's stream, and resumes until the stage is really done. Applies to the implementation commands — `/green`, `/pr-wrap`, `/fix-pr`, the rows `/yolo` runs, and `/yolo-pr-stack`'s `[G]`/`[W]`/`[F]` stages. Planning always stays with the session's own model. Runs on this machine. The main agent checks the Cursor agent is installed and logged in and guides the user through both when not. Use ONLY when the user asks for it — `#cursor-subagent` (or `#composer`), `#glm`, or words like "let Composer do it" / "offload to Cursor". Never choose ...

Compatible con✓Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/mantasindrasius/skills/tree/HEAD/skills/cursor-subagent

Installed? Explore more Productividad y colaboración skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

Preguntar en tu IA favorita

Abre un nuevo chat con esta habilidad de agente ya precargada.

Documentación

cursor-subagent — Cursor agent -p does the stage, a driver subagent watches it

main agent (this session)                  driver subagent                  this machine
─────────────────────────                  ───────────────                  ────────────
$CA ensure · fix logins ──────►                                             Cursor agent CLI, logged in
brief (references/driver-brief.md) ───►    run ──────────────────────────►  agent -p in <WORKTREE>
                                                                              └─► ~/.composer-runs/<name>/stream.jsonl
                                           wait · progress · summary ◄───
                                           not done? run --resume <sid>
◄── ✅ done | 🔴 stop (⛔ row) ───────────
report the halt in the end-of-turn summary

The session's own model keeps everything that decides what to build. The Cursor agent gets a stage whose plan and failing tests already exist, and does the typing. The driver writes no code: it starts turns, reads the stream, verifies what the agent claims against git and the PR, and resumes the same Cursor session until the stage's done condition holds.

The tags

TagExecutor model
#cursor-subagent (or #composer)newest Composer (COMPOSER_MODEL from $CA ensure)
#glmglm-5p3-flash (GLM_MODEL from $CA ensure)

Opt-in only: the tag or the user's words. A tagged request never lapses into doing the stage locally on the session's own model because the offload is hard — stop and say why instead. On Cursor the session already runs Composer, so #cursor-subagent changes nothing there; run the command as it runs on Cursor.

What is offloaded, per command

CommandStages Composer runsStays with the main agent
/greenGpreflight; a final re-run of the changeset's tests
/pr-wrapWpreflight; reporting a ⛔ Wrap row
/fix-prF (a fresh session)preflight; reporting a ⛔ halt (a retrigger, a third red push) — post-wrap, so no row
/yoloeach implementation row: G, W, F (W and F one session)preflight, re-reading the changeset between rows, planning rows, any stack cascade a split needs, the post-wrap Approve and Land
/yolo-pr-stackevery node's G, W, Fall of planning, dispatch, the ledger, the sweep plan, the TODO gate (yolo-pr-stack.md § Cursor agent offload)

Every stage takes the same row consent (driver-brief.md): step commands never ask, so the Cursor agent follows the command's file, and where the command halts its ## Workflow row it writes the row ⛔ (reason and options in Result), commits and pushes the changeset, and ends with STATUS: stopped — stage F (/fix-pr, post-wrap) has no row, so it only reports the ⛔ and ends STATUS: stopped. The main agent reports that halt in its end-of-turn summary; the developer answers by re-invoking the command. Under /yolo-pr-stack, stage W adds one override: a file other stack PRs also modify is not split (yolo-pr-stack.md § Stage W).

Never offloaded: the interview, PRDs, changesets, red commits, stack landing (/merge-pr-stack, /squash-pr). Anything that needs the developer comes back as a ⛔ halt; a stage that turns out to need a planning decision halts the same way, and the decision comes back here.

The script

Every step goes through .agents/skills/cursor-subagent/scripts/cursor-agent.sh (call it $CA, and use its absolute path, since a subagent's shell does not keep a cd). Never hand-roll agent -p lines.

Take $CA from an up-to-date checkout — the main session's worktree on main, never the node's worktree: a stack branch can predate the script (or the #glm model line). When no worktree is on a current main, export the skill: git archive origin/main .agents/skills/cursor-subagent | tar -x -C <scratchpad>/skills.

CommandWhoWhat
ensuremainjq; the Cursor agent; its login; prints COMPOSER_MODEL, GLM_MODEL, READY=yes
run --name --dir --prompt-file --model [--resume <sid>]driverstart a turn detached and return at once (TURN=<n>, WATCH=…)
wait <name> [secs=170]driverblock until the turn ends (WAIT=turn-ended, RUN_EXIT=) or secs pass (WAIT=still-running)
progress <name> [n]driverthe current turn's last n tool calls and messages
summary <name>driver, mainSESSION_ID, TURNS, LAST_TURN_STATE (finished · error · interrupted · running), RESULT, RESULT_EMPTY, LAST_THOUGHT
cancel <name>driver, mainkill the current turn and its children (RUN_EXIT=130)
exec <dir> <cmd…>drivera shell command in a dir — the driver uses it only to read state

Exit codes the caller must act on: 10 Cursor not logged in · 12 the account has no Composer model · 14 busy — a turn of that <name> is still running, or another agent holds the worktree · 19 Cursor agent CLI not installed · 20 jq missing. RUN_EXIT=16 is a turn killed by a machine stop or reboot: resume its session.

How a turn lives. Every turn of a <name> appends to ~/.composer-runs/<name>/stream.jsonl, between composer-agent turn-start and turn-end markers. One <name> is one Cursor session, continued with --resume, and that stream is what drivers judge from and what the main agent re-reads after a context reset. A turn is a detached process in its own process group, so it outlives the Claude Code session that started it; watch it with tail -f ~/.composer-runs/<name>/stream.jsonl. A session carries a long conversation: an 8-turn test resumed one session throughout and recalled facts from turns 1–5 at turn 7 without re-reading anything.

Main agent

1. Make the machine ready

$CA ensure, and on a stop guide the user. Never install or log in for them: it is their machine and their account. Suggest the ! prefix so the output lands in the conversation, ask with AskUserQuestion when it is available, and re-run ensure after the answer.

ExitTell the user
19 no Cursor agent CLI"The Cursor agent CLI isn't installed. Run ! curl https://cursor.com/install -fsS | bash, then tell me." (It installs agent into ~/.local/bin, which must be on PATH.)
10 not logged in"The Cursor agent isn't logged in. Run ! agent login (with NO_OPEN_BROWSER=1 it prints a URL to open), then tell me." agent status shows the result
20 no jq"Run ! brew install jq."
12 no Composer modelthe account cannot use the family. Report it; do not pick another model unasked

Which model for every turn (from $CA ensure, passed to $CA run --model …):

ModifierModel
#composer / #cursor-subagentCOMPOSER_MODEL — the newest composer-* in agent --list-models (e.g. composer-2.5)
#glmGLM_MODEL — glm-5p3-flash (agent --model glm-5p3-flash)

glm-5p3-flash is unlisted. agent --list-models does not show it (it lists other GLM models, such as glm-5.2-high), but the CLI accepts it. Always pass it explicitly as --model glm-5p3-flash. Never look it up in --list-models, never treat its absence there as "not available", and never replace it with a listed GLM model. $CA ensure prints it as a fixed value for this reason.

Under /yolo-pr-stack and /yolo the chosen model is mandatory for the run. Never swap families without the developer naming a different modifier.

2. Preflight stays here

Run the invoked command's own preflight first — the branch, a clean tree, the PR state, stack detection (green.md step 0, yolo.md § Halts — a dirty start). A preflight stop is reported as the command reports it; no driver starts.

Only the user's own work. The Cursor agent runs with --trust --force: it executes every shell command without approval, with the reach of the account it runs under — the same reach this session has when it does the stage itself, and print mode has nobody to approve commands. So the worktree's content must be the user's own: a branch they created or planned in this session, or a PR whose author is them (gh pr view <PR> --json author --jq .author.login equals gh api user --jq .login). A PR or branch authored by anyone else is not offloaded — run the command without the tag, or ask.

The worktree. Standalone, the stage runs in this session's worktree. Under /yolo-pr-stack each node gets its own worktree as usual (yolo-pr-stack.md step 0). While a driver runs, the main agent does not edit, commit, check out or rebase in that worktree — the Cursor agent owns it until the driver reports.

3. Brief the driver

Spawn one Claude Code subagent per stage with references/driver-brief.md as its prompt: placeholders filled, the row consent block and the stage's prompt pasted in. The driver writes no code, so it runs on the smallest allowed subagent — Sonnet · low on Claude Code, GLM · low on Cursor (only the GLM and Composer model families may be used there; -flash variants preferred) — passed explicitly; anything more is wasted, and a smaller tier misjudges "done". Announce it in one line before the Agent call:

▶ #3301 [G] /green → glm-5p3-flash, driven by sonnet · low — #glm

Tag every driver. Fill the brief's <TAG> with the node and stage — #<slug> n<k> [<G|W|F>] in a stack, #<PR> [<G|W|F>] outside one — and start the Agent call's description with the same tag (#arduino n5 [G] driver). The brief makes the driver begin every Bash description with it and a status (turn 2: running — fixing board_gen), so the host's list of running subagents reads as a per-node status board. When the main agent continues a driver into another stage ([W] → [F]), its SendMessage names the new tag.

Names. One <name> per Cursor session, reused only to continue it, unique on this machine: <command>-<branch>-<yyyymmddHHMM> standalone (green-pr-3-foo-202610141130); under /yolo, G is yolo-<branch>-G, and W and F share yolo-<branch>-W; under /yolo-pr-stack, yolo-<slug>-n<k>-G and yolo-<slug>-n<k>-W.

4. Own restarts

  • 🔴 stopped is a ⛔ row, already committed and pushed: report it in the end-of-turn summary with the row's reason and options, and end the turn. Never answer it for the developer.
  • RUN_EXIT=16 is the driver's to resume.
  • After a context reset, re-derive each stage from $CA summary <name>. Never re-run a turn whose session is still running.
  • A driver that returns mid-stage — an interim message ("still waiting", "waiting on its own background work") with no Report — has lost its loop, not its stage. Hold the wait yourself: one background Bash call that repeats $CA wait <name> 170 until it prints WAIT=turn-ended, then SendMessage the driver to continue from step 5 of its loop. Never start a second driver or a second turn for that <name>.

5. Verify, then carry on

A driver's ✅ is a claim. Before the next stage, or before reporting: the head SHA is the one the driver reported, pushed where the done condition says so, and the tree is clean of tracked changes. After a standalone G, re-run the changeset's planned tests once in the worktree (AGENTS.md § Toolchain, "The PR's tests"). Then continue the invoked command at the step after the offloaded stage (its report, /yolo's next row or its post-wrap step, the next pipeline stage).

Rules

  • Opt-in only: #cursor-subagent, #composer, #glm, or the user's words.
  • Executor model per modifier — #composer → COMPOSER_MODEL; #glm → GLM_MODEL (glm-5p3-flash). Both come from $CA ensure.
  • Planning never leaves the session. Composer gets stages with a plan and red tests, nothing else.
  • The user's machine and accounts are the user's: guide installs and logins, never run them.
  • Only the user's own branches and PRs. The agent runs every command unapproved (--trust --force); never point it at a worktree holding someone else's code.
  • One <name> per Cursor session, continued with --resume. A stage that continues another (F after W) uses the same name and session.
  • One agent per worktree. The main agent stays out of a worktree a driver is running in; run refuses a second agent there with 14.
  • Verify, don't trust: "done" means git and the PR checks say so. A dry run caught the agent claiming STATUS: done with half the task left.
  • Kill only what you started. Stop a turn with $CA cancel <name> — it ends that name's own process group, nothing else. Never pkill/killall by pattern, and never a process or terminal that belongs to the user or to another agent — not even in cleanup. Not sure it is yours? Leave it and ask.
  • Never --no-verify, never amend, never force-push. The same rules as local work, and every stage prompt gives them to the Cursor agent.

Related

/yolo-pr-stack § Cursor agent offload · /yolo § Halts no invocation can pre-approve (the halts every stage honours) · pr-stack skill (worktree and branch rules)

Individual skills in this repo

This repo contains 2 individual skills — each has its own dedicated page.

Skills relacionados