Anthropic · August 2026 · Feature Briefing

Loop and Goal

Two Claude Code commands that keep a session working without you — one driven by time, the other by state.

Time vs State Session Scoped Evaluator Model 7-Day Expiry Headless Escape Hatch

Time drives one. State drives the other.

Both commands answer the same question — what makes Claude take the next turn without you typing it — and they answer it differently. `/loop` fires a prompt when a time interval elapses. `/goal` continues the session when a separate model reads the transcript and decides the work isn't finished yet.

The documentation puts them side by side on purpose. They are not alternatives to pick between once; they are two axes. Reach for the clock when the outside world changes on its own schedule. Reach for the condition when the work has a finish line you can describe.

The One-Liner

`/loop` repeats on a timer. `/goal` repeats until a condition holds. Neither survives a closed session.

Analogy

A timer on the oven versus a thermometer in the meat. The timer knows nothing about the food — it just rings every ten minutes so you go look. The thermometer doesn't care how long it takes; it tells you when it's done.

Both die when the session dies

This is the constraint that decides everything else. Close the terminal, shut the laptop, and neither command survives. There is a third path for work that has to outlive the session, and it is not a Claude Code command at all.

Four pieces to hold in your head

The mechanics are simple once you separate what triggers the next turn from what ends the run. Two different questions, and each command answers them differently.

LOOP = The Alarm Clock

Converts your interval into a cron entry and fires the prompt on that cadence. Give it no interval and Claude picks one between 1 minute and 1 hour.

🎯
GOAL = The Finish Line

A condition written as plain text, up to 4,000 characters. Claude keeps taking turns until the condition reads as met.

⚖️
EVALUATOR = The Second Opinion

A small fast model — Haiku by default — reads the transcript after each turn and answers yes or no. It has no tools of its own.

🚪
SESSION = The Boundary

Both are scoped to the session. Both come back with --resume if unexpired. Neither runs on a machine that is asleep.

Why the evaluator is the interesting part

The evaluator only sees what Claude surfaced in the conversation. It cannot run a test or open a file to check for itself. So a condition is only as good as the evidence Claude puts on screen — write conditions that force the proof into the transcript, not conditions that assume it.

`/goal` does not grant permission

This trips people up. A goal keeps the turns coming; it does not approve tool calls. Claude will still stop and ask on anything not already permitted. Pair it with auto mode if you want it to run unattended.

Three ways to keep working, one boundary

The docs compare the first two directly. The third is not in the docs — it is what you use when the session boundary is the dealbreaker.

time /loop — the interval elapses

Next turn fires on a clock. Stops when you stop it, when Claude decides the work is done, or at the 7-day expiry.

state /goal — the condition holds

Next turn fires as soon as the previous one ends. Stops when the evaluator confirms the condition is met.

headless claude -p under a real scheduler

System cron or launchd calls Claude headless. Survives closed terminals and reboots. No session to lose.

The trade you are making

`/loop` and `/goal` cost nothing to set up and vanish with the session. Headless costs you a scheduler, a script, and somewhere for the output to land — and it runs whether you are there or not.

Using them without surprises

Most of the friction with these two commands comes from four documented behaviours that are easy to miss on first read.

1
Write the condition so the proof lands in the transcript

The evaluator reads the conversation, nothing else. "Tests pass" works only if Claude actually ran them and the output is on screen.

2
Bound the run inside the condition itself

There is no max-turns flag. Add the limit to the text: "...or stop after 20 turns." Claude reports progress against your clause.

3
Expect the interval to drift

Recurring tasks fire up to 30 minutes late by design — half the interval on sub-hourly jobs. The offset is deterministic, derived from the task ID.

4
Know which Esc works

Esc stops a `/loop` that is waiting for its next iteration. Tasks you scheduled by asking Claude in plain language are not stopped by Esc — those need deleting.

5
Check the exits before you walk away

Recurring loops self-delete after 7 days. A goal clears itself when met, on `/clear`, or with `/goal clear`. Fifty scheduled tasks per session is the ceiling.

When it looks stuck and isn't

Running `/goal` headless with `claude -p` prints nothing until the condition is met. Add `--output-format stream-json --verbose` to watch it work instead of staring at a blank terminal.

End-to-end: a fix that has to survive CI

A test file is failing and the fix needs to land, pass CI, and reach production. Three different waits, and each one wants a different mechanism.

🎯 Step 1 — State: get the suite green
/goal all tests in test/auth pass and the lint step is clean, or stop after 20 turns

There is no interval here — you have no idea how long it takes. You know what done looks like, so you describe it and let Claude keep going.

⚖️ Step 2 — The evaluator does its round
turn ends -> Haiku reads the transcript -> "not met: lint reported 2 errors" turn ends -> Haiku reads the transcript -> "met" ◎ goal achieved, cleared

The reason from each round feeds the next turn as guidance. Run `/goal` with no argument at any point to see the condition, the turn count, the spend, and the last reason.

Step 3 — Time: watch something you don't control
/loop 5m check if the deployment finished and tell me what happened

CI belongs to someone else's clock. There is no condition to evaluate locally — you just want to be told when the outside world changes.

🌙 Step 4 — Where both run out

You close the laptop. The loop stops firing and the goal freezes — both restore with --resume, but nothing happened while you were gone. If the work had to continue anyway, it never belonged in a session.

🗓 Step 5 — Hand it to a real scheduler
0 8 * * 1 cd ~/project && claude -p "$(cat weekly-check.md)" >> ~/logs/weekly.log 2>&1

The logic lives in a Markdown file, not in the crontab line. Edit the brief without touching the schedule — and give the output somewhere to land, or the run may as well not have happened.

The Payoff

Three waits, three mechanisms, one rule to remember: match the trigger to what you are actually waiting for. A finish line you can describe wants `/goal`. A clock you don't own wants `/loop`. Anything that has to happen while you sleep never belonged in a session at all.

Code Examples

The first two are commands you type inside a session. The third is the escape hatch — plain shell, no session required.

Setup
What Happens When You Run This
1.

`/loop` writes a cron entry scoped to your session and fires the prompt on that cadence, with deterministic jitter

2.

`/goal` installs a session-scoped Stop hook; after every turn a small fast model reads the transcript and votes yes or no

3.

On no, the evaluator's reason is handed to Claude as guidance and another turn begins; on yes, the goal clears itself

4.

Both restore on --resume while unexpired — the turn count and spend baseline reset, the clock does not rewind