TL;DR
- The judge reads the transcript and nothing else. After each turn, a small fast model reads your condition and the conversation. It runs no commands and opens no files, so a goal only finishes if Claude's own output can show the condition is true.
- A condition that finishes has four parts. One measurable end state, a stated check, the constraints that matter, and a turn or time clause. It can run to 4,000 characters, so there is room to be exact.
- The turn clause is judged, not counted. The docs say the judge reads Claude's progress against it from the conversation. In
claude -p,--max-budget-usdadds a spending cap outside the goal. Spend can pass it, so leave headroom. - Only some failures end a goal. An error you have to fix clears it. An overloaded server retries and a rate limit pauses it. Most print a notice you can match to a row below. Background work goes quiet until a check-in.
What does Claude Code /goal do?
Claude Code /goal keeps a session working until a condition you wrote is true. After every turn, a small fast model reads the condition and the conversation so far, then answers: not yet met, met, or impossible. "Not yet" means Claude starts another turn instead of returning control to you. That judge can't run a command or open a file, so a goal finishes when the condition describes something Claude's own output can show, and wanders when it doesn't.
This guide follows the official docs and changelog as they stood on 15 November 2026. /goal arrived in 2.1.139 on 11 May 2026, and the changelog runs to 2.1.325, dated 13 November 2026. We did not run a goal for this post. What we ran ourselves is claude --version and claude --help on 2.1.319, plus a Stop hook script and a grep check of our own, by hand. Everything else comes from the pages linked.
You set a goal by typing /goal and the condition:
/goal all tests in test/auth pass and the lint step is cleanSetting a goal starts a turn immediately, with the condition as the directive, so you don't send a separate prompt. One goal can be active per session, and a new one replaces the old one.
How is /goal different from /loop and a Stop hook?
Three approaches keep a session running between prompts. The official page compares them by what starts the next turn and what ends the run:
| Approach | Next turn starts when | Stops when |
|---|---|---|
/goal | The previous turn finishes (in an interactive session, also when a check-in or retry comes due) | A model confirms the condition, a model judges it impossible, an error you have to fix clears it, or you run /goal clear |
/loop | A time interval elapses | You stop it, or Claude decides the work is done |
| Stop hook | The previous turn finishes | Your own script or prompt decides |
Two differences matter in practice. /goal is a session-scoped shortcut, while a Stop hook lives in your settings file and applies to every session in its scope. And a Stop hook can run a script, which is a check the /goal judge can't do. We come back to that below.
Auto mode is a separate axis. On its own it approves tool calls within a turn but doesn't start a new one. The docs' summary is that auto mode removes per-tool prompts, and /goal removes per-turn prompts. Steve Kinney's course puts the split about as short as it goes: /loop is for waiting; /goal is for working.
How does the /goal evaluator decide? What can it see?

Each turn ends at the judge. It sees the condition and the conversation. It does not see your disk, and it does not run anything.
/goal is a wrapper around a session-scoped prompt-based Stop hook. When Claude finishes a turn, Claude Code sends the condition and the conversation so far to your configured small fast model, which returns one of three verdicts with a short reason:
- Not yet met. Claude keeps working and takes the reason as guidance for the next turn.
- Met. Claude Code clears the goal and records an achieved entry in the transcript.
- Impossible. The judge decided the condition can never be satisfied. Claude Code clears the goal and records a failed entry with the reason.
You can watch it. The transcript shows each verdict, and Ctrl+O shows the reason behind one. /goal with no argument prints the condition, how long it has run, how many turns were evaluated, the token spend and the judge's latest reason.
The rule that shapes everything else is in one sentence of the docs: the evaluator doesn't run commands or read files independently, so you write the condition as something Claude's own output can demonstrate. Three things follow.
Evidence has to be in the transcript. "All tests in test/auth pass" works because Claude runs the tests and the result appears in the conversation. A condition about a file Claude never opened, or a page it never loaded, has nothing for the judge to read.
A claim and a proof look alike unless the proof is printed. This is our reading, not a line from the docs. "The tests pass" and the last lines of a test run are both text in the transcript, and only the second is evidence. So put the proof into the condition: "and show the last lines of npm test". Kinney's course calls the judge a weaker oracle than a test suite's exit code, because it judges only the evidence that gets surfaced.
The worker doesn't grade itself. The docs make this the point of the design: completion is decided by a fresh model rather than the one doing the work. Some guides describe it differently. MindStudio's guide says that Claude checks its progress against the success condition you define. The docs describe a separate evaluator, and the difference decides how you write the condition.
Which model? The docs say "your configured small fast model". To use a different one, set ANTHROPIC_DEFAULT_HAIKU_MODEL. That variable has a side effect: Claude Code reads it everywhere it uses the small fast model, so it also moves session title generation and some other background tasks. Evaluation tokens are billed on that small model and are typically negligible next to main-turn spend.
How do you write a /goal condition that finishes?

The same task twice. The strong version names a state, a command whose output proves it, what must not change, and when to stop.
The docs say a condition that holds up across many turns usually has three parts: one measurable end state, a stated check, and constraints that matter. The same page says to bound a goal with a turn or time clause such as or stop after 20 turns. That makes four. Here they are in one condition:
/goal npm test exits 0 and npm run lint prints no errors, and you have shown
the last lines of both runs. No file under test/ is modified. Or stop after
20 turns and list what is left.The end state is two exit conditions. The check is "show the last lines", so the evidence lands where the judge can read it. The constraint closes the easiest shortcut. The clause ends the run and asks for a report if it comes to that.
The failures are as instructive as the pattern. These are the ones we'd expect from the rule above, with the source that names each one:
| Weak condition | What goes wrong | Rewrite |
|---|---|---|
/goal make the app production-ready | No command's output proves "production-ready", so the judge has nothing concrete to check | /goal npm run build, npm test and npm run lint all exit 0, last lines shown. Or stop after 25 turns. |
/goal refactor the auth module | It describes work to do rather than a state to reach, so Claude might stop after one pass or never | /goal every function in src/auth/ is under 40 lines, npm test exits 0 and no file under test/ is modified. Or stop after 20 turns. |
/goal make all tests pass | Nothing forbids touching the tests. The docs' own constraint example is "no other test file is modified" | /goal npm test exits 0 and git diff --name-only lists no file under test/. Or stop after 15 turns. |
/goal redesign auth, add OAuth, write tests, update docs | Compound objectives overwhelm it. A separate report describes a stale multi-part goal re-firing at least 21 times | One goal per end state, set one after another |
/goal read plans/auth.md and proceed, I'm asleep, finish what you can | That's an instruction, not a condition. One reporter saw about nine interruptions and a final "unachievable" | /goal every task in plans/auth.md is ticked and npm test exits 0. Or stop after 30 turns. |
Two cautions on that table. The rewrites are ours, written from the docs' rules, and we haven't run them. And the two issue reports are users' accounts, each from one setup. We couldn't confirm either from Anthropic's side when we read them on 15 November 2026.
Keep the last step off your plate. The judge has three verdicts, and none of them means "waiting for the user". One commenter on a GitHub report notes that a goal whose last step needs the user's own action gets "not yet met" on every check. Their workaround is to write every goal condition so it never resolves on a step the user has to take. Our version: end the condition at something Claude can do, such as "the branch is pushed and the PR description is written", not "I have approved the PR".
Length is not the problem. The docs allow up to 4,000 characters. The reply that closed a "Prompt is too long" report says a 3,900-character /goal was evaluated fine on 2.1.233 and that a longer one is rejected up front. It says the error came from long transcripts overflowing the small model, fixed in 2.1.154. Keep a condition short because a short one is easier to read as yes or no, not because 4,000 characters will break it.
How do you cap what a /goal costs?
Start inside the condition. The docs' bound is a turn or time clause, and Claude reports progress against that clause each turn while the evaluator judges it from the conversation. Our reading: that makes it a request that a model checks, not a counter in the harness. Kinney's course says the same from the other side: the goal text doesn't enforce a budget or a blocker clause, the evaluator can read them, and nothing makes the agent stop at them. So write the clause so the bad outcome is a report, not silence: "or stop after 20 turns and list what is left".
His course also suggests a clause worth copying: a no-progress limit, such as stop after three attempts that don't change the result. The built-in stall guard, he notes, only notices the agent going quiet.
Then watch the meter. /goal shows the turns evaluated and the current token spend. The judge itself is cheap, as above. The bill is the main turns, and subagents add to it, because a subagent's own requests still draw on your usage. For more on subagent spend, see our post on what background agents really cost.
For a hard limit, add a flag that lives outside the goal. --max-budget-usd is in claude --help on 2.1.319, marked as print mode only. The CLI reference says it stops the run once estimated spend on API calls reaches the amount, that subagent spend counts toward it, and that spend can pass the cap, so you leave headroom. --max-turns is in the same reference, though 2.1.319's --help didn't list it. The goal page doesn't say how either flag interacts with a goal, so check that on a throwaway branch before you rely on it. Our post on unattended claude -p runs covers the launch side.
How do you run /goal unattended?
The first surprise is that a goal doesn't change your permission mode. In Manual mode, Claude still asks before tool calls your settings don't already allow, and the docs' own example is the test command. A goal that needs you to click Allow isn't unattended.
Which mode a session starts in depends on how you launch it:
- Interactive sessions. Auto mode is the built-in starting mode from v2.1.283 for terminal and VS Code. Before that, only on Pro, Max, Ultra and Team plans.
claude -p. From v2.1.302, runs with no mode set start in Manual, and calls that need approval are denied unless a rule, hook or flag approves them.
So an unattended -p goal needs one of two things: allow rules for the commands the check uses, or --permission-mode auto. The goal docs show the bare form, claude -p "/goal CHANGELOG.md has an entry for every PR merged this week", which runs the loop to completion in a single invocation. A fuller version:
claude -p "/goal npm test exits 0 and git status shows changes only under src/, or stop after 20 turns" \
--permission-mode auto \
--max-budget-usd 5 \
--output-format stream-json --verboseEvery flag there appears in claude --help on 2.1.319, which we checked. We did not run this command. Test it on a disposable branch first.
Why stream-json? With the default text output, Claude's final response prints when the loop ends, so a goal that runs many turns can look stuck. --output-format stream-json --verbose emits each message as the loop runs. Ctrl+C stops a non-interactive goal before it resolves.
Two habits make unattended runs safer. Run on a branch or worktree, and read the diff afterward the way you'd read a colleague's, because the judge read a transcript, not your code. Our code review setup covers that step. And if the end state is a web page, give Claude a check it can run and print. Browser tests turn "the checkout works" into output the judge can read.
When should you write your own Stop hook instead?
Use /goal when "done" is something Claude's output can show and you want it for one session. Use a Stop hook when "done" is a script's exit code, or when the rule should hold in every session.
A Stop hook can be the same judge as /goal, made permanent. The hooks guide's example is a type: "prompt" hook that asks a model whether all tasks are complete, and feeds the reason back to Claude if not. But a hook can also be a command, and a command can run the check itself. Here is a script of ours that refuses to let Claude stop while the tests fail:
#!/bin/bash
# .claude/hooks/tests-must-pass.sh
out=$(npm test 2>&1) && exit 0
{
echo "npm test is failing. Last lines of its output:"
printf '%s\n' "$out" | tail -n 15
} >&2
exit 2{
"hooks": {
"Stop": [
{
"hooks": [
{ "type": "command", "command": ".claude/hooks/tests-must-pass.sh" }
]
}
]
}
}A hook that blocks by exiting 2 sends its stderr to Claude as the reason to continue. We ran the script by hand with a stand-in npm. With one that prints a failing test and exits 1, our script printed the failure and exited 2. With one that exits 0, it exited 0. We did not run it inside Claude Code.
Hooks have a loop guard. Claude Code overrides a Stop hook after it blocks eight times in a row with no tool call from Claude in between, and the count resets each time Claude calls a tool. The stop_hook_active field in the hook's input is true when Claude Code is already continuing because of a stop hook, and CLAUDE_CODE_STOP_HOOK_BLOCK_CAP sets the cap (default 8, and 0 disables it).
Our script doesn't read stop_hook_active. It keeps blocking until the tests pass, and the cap only ends a run of blocks with no tool call between them. If your check might never pass, read the field or keep your own counter.
The goal page sends you to this section of the hooks guide for the mechanism behind its own stop on a no-progress loop.
If you want a model to read files, agent hooks spawn a subagent that can read files, search code, and inspect the codebase to verify a condition. The hooks guide marks them experimental, so we'd start with a command hook.
Why did my /goal stop, pause or clear?

Only the errors you have to fix clear a goal. Everything else leaves it set, then retries or pauses.
Most of the time the notice tells you. Match it to a row:
| What you see | What happened | What to do |
|---|---|---|
| An achieved entry in the transcript | The judge said met, and the goal cleared | Read the diff before you merge |
| A failed entry with a reason | The judge said impossible, and the goal cleared | Read the reason, then fix the condition or the blocker |
Goal cleared after an unrecoverable error | An auth failure, a disk too full to renew your login, an exhausted credit balance, a context overflow that auto-compaction couldn't clear, or an unavailable model | Fix the cause, then run /goal again |
Goal still active with a wait | A failure that tends to clear, such as an overloaded server or a dropped connection. Claude Code retries, and pauses after three automatic retries | Wait, or send a message to start the next turn now |
Goal paused | A failure a retry would repeat: an API rate limit, a usage limit, or a hook that ended the turn | If the session waits for a usage limit to reset, Claude resumes then |
| A warning, and control returned with the goal still set | Claude answered the judge without using a tool for several turns in a row | Send your next prompt. Evaluation resumes. Check the condition is reachable |
| Silence for a long time | A subagent or background shell command is still running, so the turn's evaluation was skipped | Wait for the check-in, or see below |
/goal is unavailable | /goal follows the workspace trust rule for hooks, and disableAllHooks being true or allowManagedHooksOnly being set also turns it off | Check the trust dialog and those two settings |
The retry and pause notices are printed in interactive sessions on v2.1.269 or later.
Background work. If a subagent or a background shell command is still running when a turn ends, Claude Code skips that turn's evaluation and evaluates at the end of the next turn that finishes with nothing running. After 30 minutes of waiting, a check-in is due. It lists the running tasks and asks Claude to read their output, keep waiting if they are progressing, and fix or stop any that are stuck. Later check-ins come at twice the interval, up to four times the first: one hour after the first check-in, then every two hours. CLAUDE_CODE_GOAL_CHECKIN_MINUTES changes the first interval, and 0 turns off check-ins and automatic retries.
A goal can behave differently by version, and guides from earlier this year predate several changes. These are the ones that bite, from the changelog:
| Version | Date | What changed |
|---|---|---|
| 2.1.139 | 11 May 2026 | /goal added, for interactive, -p and Remote Control |
| 2.1.143 | 15 May 2026 | The evaluator no longer fires while background shells or subagents are running |
| 2.1.234 | 17 August 2026 | A goal clears itself on an unrecoverable error, and check-ins start after 30 minutes of background work |
| 2.1.239 | 21 August 2026 | Repeat check-ins back off (30 minutes, then 1 hour, then every 2 hours), and the --resume picker restores the goal |
| 2.1.246 | 25 August 2026 | Idle sessions start at most three check-ins per goal |
| 2.1.269 | 11 September 2026 | After API errors, network drops or token limits, the goal retries with backoff or pauses and says why |
| 2.1.274 | 17 September 2026 | A goal is no longer lost when you resume a session that had compacted |
Resuming restores a goal that was still active, but resets the turn count, the timer and the token baseline. It doesn't restore a goal that was already achieved or cleared.
One more thing to know before you trust a long unattended run. One report on GitHub describes a goal that re-fired at least 21 consecutive times quoting a stale multi-part goal, until the built-in repeated-block safety valve stepped in. It comes from builds at 2.1.258 or later, it is one user's account, and we can't say whether it applies to your build. The practical response is the same as for the table above: one end state per goal, evidence in the transcript, a turn clause.
Exercise: turn a vague task into a condition the judge can read
Pick a task you'd normally prompt in pieces. We'll use "clean up the date helpers" and work it through.
- Name a state you can count. "No file in
src/still importsmoment." A count is better than a feeling. - Pick the check and make it honest, then make it print. The judge trusts whatever check you name, so test the check itself. On four scratch files, three of which import
momentin three different ways,grep -rl "from 'moment'" src | wc -lprinted1, whilegrep -rlE "(from|require\()[[:space:]]*['\"]moment['\"]" src | wc -lprinted3. A narrow pattern reports0too early. Ask for the wider check's output to be shown. - Add the constraints that matter. The public function signatures stay the same, and
npm teststill exits 0. - Add the clause. Twenty turns, and a list of what is left if it gets there.
- Read it as the judge. You see only the condition and the transcript. Could you say yes or no? If the answer needs a file Claude never printed, rewrite it.
The result:
/goal No file in src/ imports moment: the output of
grep -rlE "(from|require\()[[:space:]]*['\"]moment['\"]" src | wc -l is 0
and shown. npm test exits 0 with its last lines shown. No exported function
signature changes. Or stop after 20 turns and list the files still importing
moment.Run it on a throwaway branch. After two or three turns, type /goal for the status and press Ctrl+O on a verdict. If the judge's reason says it is waiting for evidence it hasn't seen, your condition is missing a check. Add the check and set the goal again.
FAQ
What version of Claude Code do I need for /goal?
2.1.139 or later, the release the changelog dates to 11 May 2026. Run claude --version to check. Several behaviors in this post need later versions: check-ins need 2.1.234, idle check-ins 2.1.236, and the retry and pause notices 2.1.269.
Which model judges the condition?
Your configured small fast model, which ANTHROPIC_DEFAULT_HAIKU_MODEL can change. That variable also affects session titles and some other background tasks, so set it deliberately.
Can I have more than one goal at a time?
No. One goal can be active per session, and setting a new one replaces it. Split big work into goals you set one after another.
How do I stop a goal?
Run /goal clear. stop, off, reset, none and cancel also work, and so does /clear, which starts a new conversation. In a claude -p run, press Ctrl+C.
Is it the same as Codex's /goal?
The name is the same and the design isn't. Kinney's course notes that in Codex the model doing the work audits itself, while Claude Code hands the decision to a separate judge.
Our field guide goes further on hooks and runners, and lessons 1 to 3 are open to everyone: start lesson 1. To put a setup around what you've learned, build your Claude Code setup.
Sources
- code.claude.com/docs/en/goal
- code.claude.com/docs/en/hooks-guide
- code.claude.com/docs/en/hooks
- code.claude.com/docs/en/permission-modes
- code.claude.com/docs/en/cli-reference
- code.claude.com/docs/en/env-vars
- code.claude.com/docs/en/costs
- code.claude.com/docs/en/changelog
- blog.dailydoseofds.com/p/claude-codes-goal-command
- www.mindstudio.ai/blog/claude-code-goal-command-autonomous-agent-loops
- stevekinney.com/courses/ai-development-setup/goals-and-loops
- github.com/anthropics/claude-code/issues/58192
- github.com/anthropics/claude-code/issues/93744
- github.com/anthropics/claude-code/issues/94041
- skillmanifest.co/learn/home



