Skip to main content
The /goal command sets a completion condition and Claude keeps working toward it without you prompting each step. After each turn, a small fast model checks whether the condition holds. If the model judges it not yet met, Claude starts another turn instead of returning control to you. The goal clears automatically once the condition is met, if the model judges the condition impossible to satisfy, or if a turn fails on an error you have to fix. Use a goal for substantial work with a verifiable end state:
  • Migrating a module to a new API until every call site compiles and tests pass
  • Implementing a design doc until all acceptance criteria hold
  • Splitting a large file into focused modules until each is under a size budget
  • Working through a labeled issue backlog until the queue is empty

Compare ways to keep a session running

Three approaches keep the current session running between prompts. Pick based on what should start the next turn: /goal and a Stop hook both fire after every turn. /goal is a session-scoped shortcut: you type a condition and it’s active for the current session only. A Stop hook lives in your settings file, applies to every session in its scope, and can run a script for deterministic checks or a prompt for model-evaluated ones. Auto mode on its own approves tool calls within a single turn but doesn’t start a new one. Claude stops when it judges the work done. /goal adds a separate evaluator that checks your condition after every turn, so completion is decided by a fresh model rather than the one doing the work. The two are complementary: auto mode removes per-tool prompts, and /goal removes per-turn prompts.
The approaches above keep the current session running. You can also schedule work that runs independent of any open session, such as nightly tests or morning triage. See scheduling options for cloud routines and desktop scheduled tasks.

Use /goal

One goal can be active per session. The same command sets, checks, and clears it depending on the argument.

Set a goal

Run /goal followed by the condition you want satisfied. If a goal is already active, the new one replaces it.
Setting a goal starts a turn immediately, with the condition itself as the directive. You don’t need to send a separate prompt. While the goal is active, a ◎ /goal active indicator shows how long the goal has been running. A goal doesn’t change your permission mode. To let goal turns run unattended, run /goal in auto mode. In Manual mode, Claude still asks before tool calls that your settings don’t already allow, such as the test command above. While the goal is active, the transcript shows each verdict the evaluator returns, and you can press Ctrl+O to see the reason behind it. The status view also shows the most recent reason, so you can see what Claude is working toward next.

Write an effective condition

The evaluator judges your condition against what Claude has surfaced in the conversation. It doesn’t run commands or read files independently, so write the condition as something Claude’s own output can demonstrate. “All tests in test/auth pass” works because Claude runs the tests and the result lands in the transcript for the evaluator to read. A condition that holds up across many turns usually has:
  • One measurable end state: a test result, a build exit code, a file count, an empty queue
  • A stated check: how Claude should prove it, such as “npm test exits 0” or “git status is clean”
  • Constraints that matter: anything that must not change on the way there, such as “no other test file is modified”
The condition can be up to 4,000 characters. To bound how long a goal runs, include a turn or time clause in the condition, such as or stop after 20 turns. Claude reports progress against that clause each turn and the evaluator judges it from the conversation.

Check status

Run /goal with no arguments to see the current state.
If a goal is active, the status shows:
  • The condition
  • How long it has been running
  • How many turns have been evaluated
  • The current token spend
  • The evaluator’s most recent reason
The turn count and the most recent reason appear after the first evaluation has run. If no goal is active but one was achieved earlier in the session, the status shows the achieved condition along with its duration, turn count, and token spend.

Clear a goal

Run /goal clear to remove an active goal before it resolves.
Claude prints Goal cleared: followed by the condition to confirm, or No goal set if nothing was active. stop, off, reset, none, and cancel are accepted as aliases for clear. Running /clear to start a new conversation also removes any active goal.

Resume with an active goal

A goal that was still active when a session ended is restored when you resume that session with --resume or --continue. The condition carries over, but the turn count, timer, and token-spend baseline all reset on resume. A goal that was already achieved or cleared is not restored.

Run non-interactively

/goal works in non-interactive mode, in the desktop app, and through Remote Control. Setting a goal with -p runs the loop to completion in a single invocation:
With the default text output, nothing prints until the run ends, so a goal that runs many turns can look stuck. Add --output-format stream-json --verbose to emit each message as the loop runs. Interrupt the process with Ctrl+C to stop a non-interactive goal before it resolves.

How evaluation works

/goal is a wrapper around a session-scoped prompt-based Stop hook. Each time Claude finishes a turn, Claude Code sends the condition and the conversation so far to your configured small fast model, which defaults to Haiku on the Claude API; on a third-party provider, check your provider page for the platform’s default. The model returns one of three verdicts, each 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 evaluator judged that the condition can never be satisfied. Claude Code clears the goal and records a failed entry in the transcript along with the reason. You don’t need to clear it yourself.
If Claude keeps answering the evaluator without making progress (no tool use for several turns in a row), Claude Code stops the loop, prints a warning, and returns control to you with the goal still set. Evaluation resumes after your next prompt. The hooks guide explains the underlying mechanism.

Errors you have to fix clear the goal

If a turn fails on an error that won’t clear until you fix it, Claude Code clears the goal and prints a warning naming the cause. The warning starts with Goal cleared after an unrecoverable error and ends with Run /goal again to continue. Fix the cause, then set the goal again with /goal <condition>. Four kinds of failure clear the goal:
  • An authentication failure, when Claude Code manages its own credentials. When a host manages them for you, such as the desktop app, the VS Code extension, or a cloud session, Claude Code leaves the goal active because the host restores access on its own.
  • An exhausted credit balance
  • A context overflow that auto-compaction couldn’t clear
  • A model that isn’t available
After any other failure, including transient errors such as rate limits and overloaded servers, Claude Code leaves the goal active.

Background work defers evaluation

If a subagent or a background shell command is still running when a turn ends, Claude Code skips the evaluation for that turn. It evaluates at the end of the next turn that finishes with no background work running. When the background work finishes, Claude Code delivers the result to Claude as a new turn, so you don’t have to prompt. When a turn ends and background work has kept the goal waiting for 30 minutes or more, Claude Code asks Claude to check on that work. Claude Code lists the running tasks and asks Claude to read their output, keep waiting if they’re progressing, and fix or stop any that are stuck. After each further 30 minutes of waiting, Claude Code asks again at the next turn end. To change the interval, set CLAUDE_CODE_GOAL_CHECKIN_MINUTES; set it to 0 to turn check-ins off. Check-ins require Claude Code v2.1.234 or later.

Evaluation model and cost

To evaluate on a different model, set ANTHROPIC_DEFAULT_HAIKU_MODEL.
Claude Code reads ANTHROPIC_DEFAULT_HAIKU_MODEL everywhere it uses the small fast model, not only for /goal evaluation. When you set it, Claude Code also resolves the haiku alias to that model and runs background functionality, such as conversation summarization, on it.
The evaluator runs on whichever provider your session is configured for. It does not call tools, so it can only judge what Claude has already surfaced in the conversation.
Evaluation tokens are billed on the small fast model configured for your provider and are typically negligible compared to main-turn spend.

Requirements

Claude Code makes /goal available under the same workspace trust rule as hooks in settings files, because the evaluator is part of the hooks system. /goal is also unavailable when