Goal mode
Condition-driven repetition inside an open session. /goal sets a completion
condition and Claude keeps working turn after turn until it holds — without you prompting each step.
After every turn a small fast model (Haiku by default) checks the condition; if it’s not met,
Claude starts another turn instead of returning to you. This is the productized “ralph loop.”
Analogy โ a finish-line judge. Claude keeps running laps; after each lap a separate referee (a fresh Haiku call) checks whether you’ve actually crossed the line you described, and only then calls the race. The runner doesn’t get to declare its own victory.
/goal is the session-scoped shortcut for the common
case. Auto mode removes per-tool prompts within a turn; /goal removes per-turn
prompts — they’re complementary.Mechanism โ a wrapper around a Stop hook
Setting a goal starts a turn immediately with the condition as the directive; you don’t send a separate prompt. Then each turn loops through:
evaluate
yes / no + reason
the transcript only
/goal all tests in test/auth pass and the lint step is clean # set it; a turn starts immediately /goal # status: turns, tokens, last reason /goal clear # stop early (aliases: stop/off/reset/none/cancel) claude -p "/goal CHANGELOG.md has an entry for every PR merged this week" # run to completion, non-interactive
Writing an effective condition
Because the evaluator only judges what’s in the transcript, write the condition as something Claude’s own
output can demonstrate. A durable condition has: one measurable end state (a test result,
a build exit code, an empty queue); a stated check (“npm test exits 0”); and
constraints that matter (“no other test file is modified”). Up to 4,000 characters. To bound
runtime, add a clause like or stop after 20 turns.
One goal is active per session. A goal still active at session end is restored on --resume (the condition
carries over; turn count, timer, and token baseline reset). An achieved or cleared goal is not restored. Running
/clear also removes it.
When to reach for it
When not to
Best practices
npm test exits 0”) so Claude surfaces evidence the evaluator can read./goal runs only in workspaces where you’ve accepted the trust dialog, because the
evaluator is part of the hooks system. It’s unavailable when disableAllHooks is set at any level or
allowManagedHooksOnly is set in managed settings (the command tells you why). And because completion is judged
only from the transcript, a condition Claude can’t demonstrate will never clear.