Claude Corner
Claude Keeps Stopping Before the Tests Pass? Give Claude Code a /goal.
By Steven Sorensen ยท 19 Nov 2026

At a glance
- One
/goalline tells Claude Code what done looks like, and Claude keeps taking turns until a separate model agrees. - A good condition names one end state, the check that proves it and what must not change on the way.
/goalwith no argument shows progress, and/goal clearstops it whenever you want your session back.
You ask Claude to fix the failing auth tests, it fixes two and hands the prompt back. So you type "keep going", then again, while the third test is still red. Claude Code lets you write that finish line down once.
Why it matters
Anthropic's goal docs describe /goal as a completion condition for the current session. After each turn, a model checks whether the condition holds, and if it is not yet met Claude starts another turn. Completion is decided by a fresh model rather than the one doing the work. The goal clears itself once the condition is met, when the evaluator judges it impossible, or when a turn fails on an error you have to fix.
How to set a goal that finishes
We built these steps from Anthropic's docs and have not run them live.
- Run
claude --version. The retry and pause notices below need v2.1.269 or later in an interactive session. - Write the condition with one measurable end state, a stated check such as "
npm testexits 0", and the constraints that matter. Add a clause such as "or stop after 20 turns" to bound it. - In Claude Code, type
/goalfollowed by that condition. It starts a turn right away, so you need no separate prompt. - Watch the /goal active indicator. Press Ctrl+O on a verdict to see the reason.
- Run
/goal clearif you want to stop early.
# We have not run this script end to end on every platform.
# It prints your version and makes no model calls.
claude --version
# Then, in Claude Code, type these one at a time:
# /goal all tests in test/auth pass, shown by npm test exiting 0, and no other test file is modified, or stop after 20 turns
# /goal
# /goal clear
Gotchas
- The evaluator only reads the conversation. It does not run commands or read files, so phrase the condition as something Claude's own output can show, like a test run in the transcript.
- Auto mode is complementary. It covers tool approvals, while
/goalstarts each next turn. Use auto mode when you want goal turns to run unattended. In Manual mode, Claude still asks before tool calls your settings do not already allow, such as your test command. - Some errors clear the goal. An exhausted credit balance, a context overflow that compaction could not clear or a missing model prints
Goal cleared after an unrecoverable error. Fix the cause and set the goal again. In an interactive session on v2.1.269 or later, a claude.ai usage limit pauses it with aGoal pausednotice instead. - Spinning without progress stops the loop. If Claude answers without tool use for several turns in a row, Claude Code stops and keeps the goal set until your next prompt.
- One goal per session. A new
/goalreplaces the old one, and/clearalso removes it. Resuming restores an active goal but resets the turn count, timer and token spend./goalis unavailable when hooks are turned off.
If you want Claude to repeat a check on a clock instead of until a condition holds, see our Nov 9 Corner on letting /loop watch a pull request.
Sources:
Recommended AI prompt
Copy this paragraph into ChatGPT, Claude, Gemini, Grok, or whatever AI you use.
Using only Anthropic's Claude Code goal docs, help me write one /goal condition with a single measurable end state, the exact check to prove it, the files or behavior that must not change and a turn limit. Then give a short checklist for watching progress and clearing the goal if it drifts. Ask what my task, test command and constraints are first.