Skip to content

The /goal command gives a coding agent an objective with a verifiable finish line and keeps it working turn after turn until the objective holds, a budget or limit stops it, or you clear it. Claude Code, Codex and Cursor all ship /goal, but they differ on who decides the work is done, and that difference decides how far you can trust the result.

This page is for developers who run long agent sessions and for tech leads who want those runs to end in evidence. You are three hours into a migration. The agent finishes a turn, you skim the diff and type “keep going”, and it finishes another turn. The finish line is obvious (“every call site migrated, all tests green”), yet every step waits on you pressing Enter.

  • A side-by-side view of how /goal works in Claude Code, Codex and Cursor, and who judges “done” in each
  • The commands to start, inspect, pause and clear a goal run in each tool
  • Three copy-paste goals that terminate cleanly, plus an audit prompt for the finished run
  • A four-step check that proves the result without reading every changed line
  • A failure table: what stalls or fools a goal run, and how to recover

A normal agent turn ends when the model decides it has said enough. /goal replaces that with a condition and a loop: the agent plans a step, makes the change, runs your checks, and then something asks “does the condition hold?” If not, the next turn starts without you.

That “something” is the part that differs:

Claude CodeCodexCursor
Who judges doneA separate small fast model (Haiku by default on the Claude API) reads the transcript after every turnThe agent doing the work runs a built-in completion audit, then marks the goal complete itselfNot documented (checked 2026-08-28)
VerdictsNot yet met · met · impossibleComplete · blocked (agent); paused (you); stalled, usage-limited, budget-limited (runtime)—
Controls/goal <condition>, /goal, /goal clear/goal <objective>, /goal, /goal edit, /goal pause, /goal resume, /goal clear/goal [objective]
Stops on its own whenMet or judged impossible (goal cleared), an error you have to fix (goal cleared); stall detection or a rate/usage limit pauses it with the goal still setComplete, blocked after the same blocker in three consecutive turns, a usage limit, or a goal token budget—
Runs without approval promptsclaude -p "/goal …"Interactive session with --approve-for-me (no headless /goal form verified in codex exec 0.157.1)Check your build
Available sincev2.1.139goals stable and on by default in 0.157.12026-08-19, marked “Rolling out” (still, checked 2026-10-12)

Sources: Claude Code goal docs (checked 2026-09-26, CLI 2.1.283); Codex codex features list and the goal prompts shipped in the codex-cli 0.157.1 binary (checked 2026-09-26); Cursor’s CLI slash-command reference (checked 2026-08-28).

Two consequences follow. In Claude Code, the evaluator does not run commands or read files: it judges only what the agent printed. In Codex, the judge and the worker are the same model, so a well-worded audit is still self-assessment. In Cursor, nothing documented checks the objective at all. In all three, the independent proof has to come from somewhere else: a test command, a hook, or CI. The proof section below shows how.

  1. Pick the permission mode first. A goal does not change your permission mode, so a Manual-mode session stops at the first unapproved npm test. Interactive sessions on v2.1.283 and later (both release channels on 2026-10-12) start in auto mode unless settings disable it or the model does not support it. claude -p starts in Manual mode, except on third-party providers or with telemetry off, where it starts in auto mode from v2.1.285. See permissions, sandboxes and approval modes.

  2. Set the goal. Type /goal followed by the condition (up to 4,000 characters). The first turn starts immediately; you do not send a separate prompt. One goal is active per session, and a new one replaces the old.

  3. Watch the verdicts. Each evaluator verdict appears in the transcript; press Ctrl+O for the reason. /goal with no argument shows the condition, elapsed time, evaluated turns, token spend and the latest reason.

  4. Stop or resume. /goal clear removes the goal. A goal still active when the session ends is restored by --continue or --resume, with the turn count, timer and token baseline reset.

For an unattended run on your own branch, allow only the tools the condition needs and cap the spend:

Terminal window
# Terminal, on a branch you own
claude -p "/goal every file under src/components imports useAppStore, not useStore; \
'npm run typecheck' exits 0 and 'npm test' shows 0 failed. Do not edit tests/. \
Stop after 25 turns." \
--allowedTools "Read,Edit,Bash(npm test *),Bash(npm run typecheck *)" \
--max-budget-usd 10 \
--output-format stream-json --verbose

--max-budget-usd works only with -p, and it is the hard ceiling the “stop after 25 turns” clause is not. Without stream-json, nothing prints until the run ends. /goal is part of the hooks system, so it is unavailable in an untrusted workspace or when disableAllHooks or managed allowManagedHooksOnly is set; the command says why. The full Claude Code reference is goal workflows with /goal in Claude Code.

How do you write a goal the agent can finish?

Section titled “How do you write a goal the agent can finish?”

The run is decided before it starts, in the condition. Five rules carry most of the weight:

  1. One objective, one finish line. “Migrate the API and improve coverage” gives the judge two targets, and the run thrashes between them. Split it into two goals.
  2. Make the finish line a command. “Looks good” is not checkable; “npm test shows 0 failed and 0 skipped” is. In Claude Code the evaluator only sees output, so ask for the summary line to be printed.
  3. Name what defines correct. Point to the spec, the migration guide and one already-migrated file. An agent that guesses the target wanders.
  4. State what must not change. “Do not edit tests/” and “Do not touch src/auth/” are the constraints a loop breaks first when a test is hard to satisfy.
  5. Bound the run. Add a turn or time clause (“stop after 25 turns”), and in Claude Code headless runs a --max-budget-usd cap.

Writing the criteria themselves is covered in acceptance criteria agents can verify.

A “met” or “complete” verdict is the agent’s claim, judged from its own transcript. Prove it with evidence the loop could not produce by itself:

  1. Re-run the gate outside the session. Push the branch and let CI run the same tests, type check and lint on a clean checkout. That run is the proof; the transcript is not.

  2. Check the constraints held. Run this in the terminal; adjust the paths to what the goal promised not to touch:

    Terminal window
    git diff --stat main...HEAD -- tests/ src/store/ package.json

    Empty output means the oracle and the protected code are untouched. Loops are good at making tests pass by weakening them; protecting the oracle adds deny rules and hooks that stop it at the source.

  3. Review by risk, not by line. Run a review agent on the branch, then read only what it flags and anything in authentication, payments or data deletion.

  4. Attach the evidence. Put the final goal status (condition, turns, token spend), the CI link and the git diff --stat output in the pull request. The evidence bundle defines the full contract.

The developer who set the goal signs off, because they own the condition and the judgement that it described the right outcome. A tech lead standardising goal runs reviews the condition templates and the gates, not every diff they produce.

Run the audit in a fresh session or a different tool, so the model that did the work is not the one grading it.

When should you use /goal instead of /loop or a framework?

Section titled “When should you use /goal instead of /loop or a framework?”
You needUseWhy
Work that converges on a checkable end state in one session/goalBuilt in, bounded, with a verdict per turn
The same prompt on a cadence: poll a deploy, watch a PR/loopRuns on an interval, with no single finish line
A deterministic check after every turn, in every sessionA Stop hook (hooks automation)A script decides, not a model
Overnight multi-session builds with state on diskAutonomous loops (Ralph, GSD Core)Survives many sessions; needs a sandbox
Work that runs with your laptop closedBackground and cloud agentsRoutines, Codex cloud and automations, Cursor Cloud Agents

A common pairing: a /goal run drives a feature to “tests green”, then a /loop watches the resulting pull request for CI failures and review comments.

What breaks in /goal runs, and how do you recover?

Section titled “What breaks in /goal runs, and how do you recover?”
SymptomCauseRecovery
The goal never completes although the work looks doneThe agent never printed the proof the condition namesPut the proof command in the condition and ask for its summary line
The run reports done after one green test fileThe condition accepts partial evidenceRequire totals: “0 failed and 0 skipped across the whole suite”
Tests pass because tests changedNothing protected the oracleAdd “do not edit tests/” plus deny rules; check with git diff --stat
Claude Code clears the goal as impossibleThe condition contradicts a constraint, or the proof command cannot succeed hereRead the recorded reason, run the command yourself, fix the conflict, set the goal again
Codex shows Goal stalled or marks the goal blockedThe same blocker repeated across turnsFix the blocker (a missing secret, a failing service), then /goal resume, or /goal edit to narrow the objective
The run waits at every commandManual permission mode, or no approval review in CodexUse auto mode in Claude Code or --approve-for-me in Codex, inside a sandbox
Token spend keeps climbingNo stop clause, or an unreachable end stateCheck /goal for spend, then /goal clear; always pass --max-budget-usd in claude -p runs
Cursor’s run stops early and says it is doneNo documented evaluator; the worker decidedRe-run the gate command and let CI decide