Intermediate 1 concept to know first

Goals (/goal)

Give /goal a completion condition and Claude keeps taking turns toward it, while a separate small model checks after every turn whether the condition is met.

The animation needs JavaScript; every step is described below.

0:15

Know these first

1 concept · basics first
  1. Context

    The context window is everything Claude can see in a session: your messages, the files it reads, tool output and auto-loaded instructions. It fills as you work, and Claude Code compacts it when it gets full.

  2. Goals (/goal) · you are here

Normally Claude Code works until it judges the job done, then hands control back to you. On a big job that means you keep coming back to type “keep going”. /goal changes who decides when to stop. You state a condition, and Claude keeps starting new turns until it holds:

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

Setting a goal starts work immediately, with the condition itself as the instruction. There’s one goal per session; setting a new one replaces it. It suits substantial work with a checkable end state: a migration until every call site compiles, a backlog until the queue is empty.

Who decides it’s done

Not the model doing the work. After every turn, Claude Code sends your condition and the conversation so far to a small fast model (Haiku by default on the Claude API). It returns one of three verdicts, each with a short reason:

  • Not yet met: Claude takes another turn, using the reason as guidance.
  • Met: the goal clears and is recorded as achieved.
  • Impossible: the goal clears and is recorded as failed, with the reason.

Under the hood, /goal is a session-scoped, prompt-based Stop hook. A Stop hook in your settings file does the same job for every session; /goal is the one-line version for this session only.

Write a condition it can check

The evaluator doesn’t run commands or read files. It judges only what has already appeared in the conversation. So write a condition Claude’s own output can prove: one measurable end state, the check that proves it (“npm test exits 0”), and anything that must not change on the way there. To bound the run, add a clause like “or stop after 20 turns”.

/goal on its own shows the status: the condition, how long it has run, turns evaluated, token spend and the latest reason. /goal clear stops it early. It also works headless: claude -p "/goal …" runs the loop to completion in one invocation.

The catch

A goal doesn’t change your permission mode. In Manual mode, Claude still asks before tool calls your settings don’t allow, so a goal you want to run unattended needs auto mode. Every extra turn also re-sends a growing context, so a long goal spends real tokens. If a subagent or background command is still running when a turn ends, evaluation waits for it. And errors you have to fix yourself, such as failed authentication or an exhausted credit balance, clear the goal with a warning rather than retrying forever.

Where it sits

Before this

Context
Goals (/goal)

Leads to

Nothing yet.

The ideas underneath · Field Guide

Sources

  1. Keep Claude working toward a goal . Claude Code docs: setting, checking and clearing goals; how evaluation works

Verified against the official Claude Code docs on October 1, 2026 · next review by January 1, 2027. Claude Code changes quickly; the docs are the source of truth.