How to run Claude Code's /goal in auto mode until a completion condition is met
Claude Code's /goal sets a completion condition, and Claude keeps starting new turns on its own until the condition holds. After each turn a separate model checks the condition and, if it isn't met yet, starts another turn. Use it for substantial work with a verifiable end state, such as moving every call site to a new API or emptying an issue backlog.
- Switch to auto mode and write the condition. Setting a goal starts the first turn right away, so you don't need a separate prompt. A goal doesn't change your permission mode, so in Manual mode Claude still asks before tool calls your settings don't allow.
/goal all tests in test/auth pass and the lint step is clean
-
Write the condition as something Claude's own output can demonstrate. The evaluator doesn't run commands or read files; it only judges what appears in the conversation. One measurable end state (a test result, an exit code, an empty queue), a stated check (
npm testexits 0) and the constraints that matter (no other test file is modified) keep it holding up across many turns. To bound the run, add a turn or time clause such asor stop after 20 turns. The condition can be up to 4,000 characters. -
Check status or clear the goal. With no arguments,
/goalshows the condition, elapsed time, turns evaluated, token spend and the evaluator's most recent reason.
/goal
/goal clear
- To run it in one shot without the interactive UI, pass it to
-p. The default text output prints only when the loop ends, so a long goal can look stuck; add stream-json output.
claude -p "/goal CHANGELOG.md has an entry for every PR merged this week" --output-format stream-json --verbose
Evaluation runs on your configured small fast model (Haiku by default). To use a different model, set ANTHROPIC_DEFAULT_HAIKU_MODEL; it also applies to background work such as conversation summarization and to the haiku alias. A "Sonnet builds, Haiku judges every turn, Opus signs off" setup is going around on X, but /goal has no Opus sign-off step (add the advisor separately if you want one).
If a turn fails on an error you have to fix (an authentication failure, an exhausted credit balance, a context overflow auto-compaction couldn't clear, or an unavailable model), the goal clears with a warning ending in Run /goal again to continue. Fix the cause and set it again. Because /goal runs on the hooks system, it isn't available in untrusted folders, when disableAllHooks is true, or when managed settings set allowManagedHooksOnly.
Get notified when a new tip lands
Tip alerts only go out in the app. Install it and turn notifications on.