Claude Corner

Claude Keeps Stopping Before the Tests Pass? Give Claude Code a /goal.

By ยท 19 Nov 2026

A macro view of one blank mechanical key pressed down on a bright powder blue keyboard, seen from a low angle with the other keys softly blurred, with no hands or text.

At a glance

  • One /goal line 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.
  • /goal with no argument shows progress, and /goal clear stops 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.

  1. Run claude --version. The retry and pause notices below need v2.1.269 or later in an interactive session.
  2. Write the condition with one measurable end state, a stated check such as "npm test exits 0", and the constraints that matter. Add a clause such as "or stop after 20 turns" to bound it.
  3. In Claude Code, type /goal followed by that condition. It starts a turn right away, so you need no separate prompt.
  4. Watch the /goal active indicator. Press Ctrl+O on a verdict to see the reason.
  5. Run /goal clear if 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 /goal starts 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 a Goal paused notice 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 /goal replaces the old one, and /clear also removes it. Resuming restores an active goal but resets the turn count, timer and token spend. /goal is 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.

Prompt

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.