Claude Code

Claude Code /loop vs /goal

Use /goal for outcome-based completion. Use /loop for cadence-based repetition. Wrap both with budget, evidence, and approval gates.

Abstract Claude Code loop and goal workflow with hooks schedules and verifier checkpoint

Answer-first comparison

PrimitiveNext turn starts whenStops whenBest for
/goalThe previous turn finishesA model confirms the condition is met, or you clear/stop itSubstantial work with a verifiable end state
/loopA time interval elapsesYou stop it, or Claude decides the work is donePolling, recurring checks, periodic maintenance
Stop hookThe previous turn finishesYour script or prompt decidesCustom deterministic or model-evaluated checks
Scheduled taskA schedule fires outside the sessionThe scheduled run finishes or is disabledWork that should run after your laptop/session closes

Safe examples

Use casePreferWhy
Fix auth tests until `npm test -- auth` passes/goalThe end condition is verifiable.
Check an issue queue every 30 minutes/loop or scheduled taskThe trigger is cadence, not completion.
Run nightly docs freshness checksScheduled taskIt should run without an open session.
Keep refactoring until a file is under 300 lines/goalThe condition is measurable and bounded.

Do not skip the wrapper

Harness control and multi-agent phases

Claude Code's model is effectively stateless between API calls. The harness reassembles tools, system context, environment, project instructions, skill names, and the message history every turn, so durable loop state still belongs in files, permissions, and verifiers, not in model memory.

Treat permissions (allow / ask / deny) as part of the approval boundary: dangerous side effects stay behind ask or deny, not behind hope. For larger rebuilds, prefer an explicit multi-agent shape: specialized builders in parallel, then sequential integrate, review, and verify, instead of one unbounded agent thrashing the tree. Save a repeating multi-phase pattern only after it has earned a real stop condition and proof step.

Source notes: Anthropic Claude Code team walkthrough of prompt assembly and permissions; community demo of intent-driven builds and draft-PR verification (Source Library: Lydia Haley + YK Sugi / Agent Factory clip, X status 2077720293729091888).

Related

FAQ

What is the difference between /loop and /goal in Claude Code?

In Claude Code docs, /goal keeps the current session working toward a verifiable condition after each turn, while /loop reruns a prompt on a time interval.

When should I use /goal?

Use /goal when there is a measurable end state such as tests passing, a queue emptying, or acceptance criteria being proven.

When should I use /loop?

Use /loop when the next turn should start on cadence: polling, checking, triage, or periodic maintenance.