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.

Answer-first comparison
| Primitive | Next turn starts when | Stops when | Best for |
|---|---|---|---|
| /goal | The previous turn finishes | A model confirms the condition is met, or you clear/stop it | Substantial work with a verifiable end state |
| /loop | A time interval elapses | You stop it, or Claude decides the work is done | Polling, recurring checks, periodic maintenance |
| Stop hook | The previous turn finishes | Your script or prompt decides | Custom deterministic or model-evaluated checks |
| Scheduled task | A schedule fires outside the session | The scheduled run finishes or is disabled | Work that should run after your laptop/session closes |
Safe examples
| Use case | Prefer | Why |
|---|---|---|
| Fix auth tests until `npm test -- auth` passes | /goal | The end condition is verifiable. |
| Check an issue queue every 30 minutes | /loop or scheduled task | The trigger is cadence, not completion. |
| Run nightly docs freshness checks | Scheduled task | It should run without an open session. |
| Keep refactoring until a file is under 300 lines | /goal | The condition is measurable and bounded. |
Do not skip the wrapper
- State the verifier in the condition or prompt.
- Add a turn/time/token budget.
- Make the approval boundary explicit before merge, deploy, publish, send, delete, or spend.
- Use a worktree or branch for repo-changing loops.
- Write progress to files or PR comments so the next turn has durable state.
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.