Part of the AI Coding Harness Guide — environment design for coding agents in production.

Claude Code /goal: Keep Claude Working Until a Condition Is Met#

Published by

/goal <condition> sets a completion condition and Claude Code keeps working toward it without a prompt each turn. After every turn a separate model checks whether the condition holds and starts the next turn if it does not, so the session runs to the goal and stops there instead of asking "should I also fix this?". Clear an active goal with /goal clear. The command shipped in v2.1.143.[1]

What /goal does#

One goal can be active per session. Running /goal with a condition starts a turn at once, with the condition as the directive, so you do not send a separate prompt. While the goal runs, a ◎ /goal active indicator shows how long it has been going.

After each turn, Claude Code sends the condition and the conversation so far to the 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 evaluator judged the condition can never be satisfied. Claude Code clears the goal and records a failed entry with the reason. You do not clear it yourself.

The evaluator judges the condition against what Claude has put in the conversation. It does not run commands or read files on its own, so write a condition that Claude's own output can show, such as "all tests in test/auth pass" where the test result appears in the transcript. A condition can be up to 4,000 characters.

A goal does not change your permission mode. In Manual mode Claude still asks before tool calls your settings do not already allow. To let goal turns run unattended, set the goal while in auto mode.

Use the command#

CommandWhat it does
/goal <condition>Sets the goal and starts a turn. A new goal replaces an active one.
/goalShows status: the condition, how long it has run, turns evaluated, token spend, and the evaluator's most recent reason.
/goal clearRemoves an active goal. Prints Goal cleared: and the condition, or No goal set.

stop, off, reset, none, and cancel are accepted as aliases for clear. Running /clear to start a new conversation also removes an active goal. The turn count and the most recent reason appear in the status only after the first evaluation has run.

/goal all tests in test/auth pass and the lint step is clean

To bound how long a goal runs, put 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.

Stop at the goal instead of chasing every finding#

The scope-creep complaint in issue #112120 is that a session set to fix one thing keeps running, because at the end Claude asks "should I also fix this?" and each yes adds work. A goal changes what decides the end: a fresh model checks your stated condition after every turn, rather than the model doing the work deciding it is done. When the condition holds, Claude Code clears the goal and stops.

/goal keeps the session running between prompts; two other features do the same with a different trigger:

ApproachNext turn starts whenStops when
/goalThe previous turn finishes, or an idle check-in or a retry comes dueThe condition is met or judged impossible, a turn fails on an error you must fix, or you run /goal clear
/loopA time interval elapsesYou stop it, or the loop ends on its own
Stop hookThe previous turn finishesYour own script or prompt decides

/goal is session-scoped: you type a condition and it is 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. In fact /goal is a wrapper around a session-scoped prompt-based Stop hook. If Claude keeps answering the evaluator with 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.

Run it without supervision#

/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 one invocation:

claude -p "/goal CHANGELOG.md has an entry for every PR merged this week"

With the default text output, the final response prints only when the loop ends, so a long goal can look stuck. Add --output-format stream-json --verbose to emit each message as it runs. Interrupt with Ctrl+C to stop before the goal resolves.

When you resume a session, Claude Code restores a goal that was still active when the session ended, on every resume route from v2.1.239 (before that, every route except the claude --resume picker). It carries the condition over and resets the turn count, timer, and token-spend baseline. It does not restore a goal already achieved or cleared.

When a turn fails#

Some errors clear the goal and some leave it set.

Errors you have to fix clear the goal. Claude Code prints a warning that starts with Goal cleared after an unrecoverable error and ends with Run /goal again to continue. These are an authentication failure when Claude Code manages its own credentials, a disk too full to renew the login, an exhausted credit balance, a context overflow that auto-compaction could not clear, and a model that is not available. Fix the cause, then set the goal again. When a host manages credentials, such as the desktop app or a cloud session, an auth failure leaves the goal active because the host restores access on its own.

Other errors keep the goal set. From v2.1.269 in an interactive session, Claude Code also names the cause and either retries or pauses:

  • Retry, after a failure that tends to clear on its own such as an overloaded server or a dropped connection: a notice starting with Goal still active shows the wait before the next attempt. After three automatic retries the goal pauses instead.
  • Pause, after a failure a retry would only repeat such as an API rate limit, a usage limit, or a hook that ended the turn: a notice starting with Goal paused names the cause. If the session is set to continue when a usage limit resets, Claude resumes toward the goal then.

Send a message at any time to start the next turn immediately.

Check-ins while background work runs#

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 in the background. When the background work finishes, Claude Code delivers the result to Claude as a new turn.

Once background work has kept the goal waiting for 30 minutes, a check-in is due. The check-in 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. After the first check-in, Claude Code waits twice as long before each later one, up to four times the first interval: with the default, 1 hour after the first check-in, then every 2 hours.

A due check-in is delivered either at the end of the next turn that finishes with the work still running, or, in an interactive session, by Claude Code starting a turn on its own while the session is idle. Idle check-ins are capped at three per goal between your prompts from v2.1.246 (before that they were uncapped); in the third, Claude Code says idle check-ins are paused until you send another prompt. Check-ins require v2.1.234 or later, and idle check-ins require v2.1.236 or later.

CLAUDE_CODE_GOAL_CHECKIN_MINUTES#

Set CLAUDE_CODE_GOAL_CHECKIN_MINUTES to change the first check-in interval. Claude Code uses your value in place of 30 minutes and scales the later intervals with it.

{
  "env": {
    "CLAUDE_CODE_GOAL_CHECKIN_MINUTES": "15"
  }
}

Set it to 0 to turn off check-ins and the automatic retries above.

To evaluate on a different model, set ANTHROPIC_DEFAULT_HAIKU_MODEL. Claude Code reads that variable everywhere it uses the small fast model, not only for /goal, so it also resolves the haiku alias to that model and runs session title generation and some other background tasks on it. Evaluation tokens are billed in addition to the main-turn spend.

Requirements#

/goal is available under the same workspace trust rule as hooks in settings files, because the evaluator is part of the hooks system. It is unavailable when disableAllHooks is true after settings precedence applies, or when allowManagedHooksOnly is set in managed settings.

Timeline#

VersionPublishedChange
v2.1.1432026-05-15/goal ships: declare a completion condition, Claude works toward it and stops when a model judges it met.
v2.1.2342026-08-17Check-ins arrive, and /goal clears itself on an unrecoverable error. CLAUDE_CODE_GOAL_CHECKIN_MINUTES sets the first interval.
v2.1.2362026-08-19Idle check-ins: Claude Code starts a turn on its own to check in while the session is idle.
v2.1.2392026-08-21A goal is restored on every resume route, including the claude --resume picker. Turn-end check-ins back off like idle ones.
v2.1.2462026-08-25Idle check-ins capped at three per goal between prompts.
v2.1.2692026-09-11Automatic retry and pause on recoverable turn failures, with the Goal still active and Goal paused notices.

Should you use /goal?#

Use a goal for substantial work with a verifiable end state: migrating every call site to a new API until it compiles and tests pass, working a labeled issue backlog until the queue is empty, or splitting a large file until each piece is under a size budget. Pair it with auto mode so each turn runs without per-tool prompts. For a change that is one or two turns, or one where you want to review each step, a plain prompt is simpler. For work that should repeat on a clock rather than run to a condition, use /loop.


FAQ#

Q: What is the /goal command in Claude Code?

A: A slash command that sets a completion condition for the current session. Claude keeps working toward it, and after each turn a separate model checks the condition and starts the next turn until it is met, judged impossible, or cleared.

Q: How do I stop or clear a goal?

A: Run /goal clear. The aliases stop, off, reset, none, and cancel do the same, and starting a new conversation with /clear also removes an active goal.

Q: How do I stop Claude Code from asking "should I also fix this?"

A: Set a goal with /goal <condition>. A separate model decides when the condition is met, so the session ends at the goal rather than offering more work. Issue #112120 asks for this behavior.

Q: Does /goal run turns without asking for permission?

A: No. A goal does not change your permission mode. In Manual mode Claude still asks before tool calls your settings do not allow. Set the goal in auto mode to let turns run unattended.

Q: What is CLAUDE_CODE_GOAL_CHECKIN_MINUTES?

A: The first check-in interval while background work keeps a goal waiting, in minutes, in place of the default 30. Later intervals scale with it. Set it to 0 to turn off check-ins and automatic retries.

Q: Does a goal survive resuming a session?

A: Yes. From v2.1.239 Claude Code restores an active goal on every resume route and resets the turn count, timer, and token baseline. It does not restore a goal that was already achieved or cleared.

Q: Which version added /goal?

A: v2.1.143, published May 15, 2026. Check-ins and the unrecoverable-error clearing arrived in v2.1.234.


Sources: [1] Claude Code changelog | Issue #112120

Related: CLAUDE_CODE_GOAL_CHECKIN_MINUTES in the env-var glossary | Always-On Agents in Claude Code | Claude Code v2.1.143 analysis | Claude Code Version Tracker

Get the weekly digest

New Claude Code, Codex, Gemini CLI and OpenCode guides and release analyses, once a week, plus occasional notes.

One email a week plus occasional notes. Confirm by email; unsubscribe from any issue. Privacy