Skip to content
Claude Code's 4 Agent Loop Types: Turn, Goal, Time & Proactive Explained

Claude Code's 4 Agent Loop Types: Turn, Goal, Time & Proactive Explained

This guide from the Claude Code team defines four agent loop patterns—turn-based, goal-based, time-based, and proactive—detailing their triggers, stop conditions, ideal use cases, and token management strategies, with practical examples like SKILL.md verification and /goal commands for iterative coding tasks.

ThinkInAI Community
ThinkInAI Community
ThinkInAI Community

The Claude Code team defines a loop as an agent repeatedly executing a work cycle until a stop condition is met. Loops are classified by how they are triggered, how they stop, which Claude Code primitive they use, and which tasks they suit best. Not every task needs a complex loop; start with the simplest solution and adopt patterns selectively.

Turn‑Based Loops (Manual Rounds)

Trigger: User prompt.

Stop condition: Claude judges the task complete or needs more context.

Best for: Shorter, ad‑hoc tasks outside a routine or schedule.

Usage management: Write specific prompts and use skills to improve verification, reducing rounds.

Every prompt you send starts a manual loop where you direct each round. Claude gathers context, acts, checks its work, repeats if needed, then replies. Example: ask Claude to create a like button; it reads code, edits, runs tests, and delivers what it thinks works. You then manually review and write the next prompt.

You can encode manual verification steps into a SKILL.md file so Claude can self‑verify end‑to‑end. Include tools or connectors that let Claude see , measure , or interact with results. The more quantitative the checks, the easier self‑verification becomes.

---
name: verify-frontend-change
description: Verify any UI change end-to-end before declaring it done.

# Verifying frontend changes
Never report a UI change as complete based on a successful edit alone. Verify it the way a human reviewer would:

1. Start the dev server and open the edited page in the browser.

2. Interact with the change directly. For a new control (button, input, toggle): click it, confirm the expected state change, and screenshot before/after.

3. Check the browser console: zero new errors or warnings.

4. Use the Chrome Devtools MCP, run a performance trace and audit Core Web Vitals.

If any step fails, fix the issue and rerun from step 1 — do not hand back partially verified work.

Goal‑Based Loops (/goal)

Trigger: Live manual prompt.

Stop criteria: Goal achieved or max round limit reached.

Best for: Tasks with verifiable exit criteria.

Usage management: Set concrete done criteria and explicit round caps, e.g., “stop after 5 tries”.

For complex tasks, a single turn isn’t enough. Agents perform better when they can iterate. Use /goal to define what “done” looks like, extending Claude’s iteration. Once success criteria are defined, an evaluator model checks conditions each time Claude tries to stop, forcing continuation until the goal is met or the round limit hits. Deterministic criteria (passing test count, score threshold) work best.

/goal get the homepage Lighthouse score to 90 or above, stop after 5 tries.

Time‑Based Loops (/loop and /schedule)

Trigger: Specified time interval.

Stop condition: You cancel it, or work finishes (PR merged, queue empty).

Best for: Recurring work or interaction with external environments/systems.

Usage management: Set longer intervals or respond to events instead of time.

Some agent work is periodic: the task stays the same, only inputs change (e.g., daily Slack summary). Other work depends on external systems; a simple interaction is polling at intervals and reacting to changes (e.g., a PR receiving reviews or CI failures). Use /loop to re‑run a prompt at a fixed interval.

/loop 5m check my PR, address review comments, and fix failing CI
/loop

runs on your machine, so it stops if you shut down. Move the loop to the cloud with /schedule to create a routine.

Proactive Loops

Trigger: Event or schedule, no live human intervention.

Stop condition: Each task exits when its goal is met; the routine runs until you shut it down.

Best for: Recurring, well‑defined workflows: bug reports, issue triage, migrations, dependency upgrades.

Usage management: Route routine to smaller, faster models; use the most capable model only when judgment is needed.

Combine primitives— /schedule (research preview) to run a routine that checks for new reports, /goal to define done state and skills to codify verification, dynamic workflows to orchestrate agents that triage, fix, and review each report, and auto‑mode so the routine runs without pausing for permission.

/schedule every hour: check the project-feedback channel for bug reports. /goal: don't stop until every report found this run is triaged, actioned, and responded to. When fixing a bug, use a workflow to explore three solutions in parallel worktrees and have a judge adversarially review them.

Maintaining Code Quality

Keep the codebase clean: Claude follows existing patterns and conventions in your repo.

Give Claude a way to verify its own work: Use skills to codify your team’s definition of “good”. (Reference: https://code.claude.com/docs/en/skills)

Make documentation accessible: Framework and library docs contain up‑to‑date best practices.

Use a second agent for code review: A reviewer with fresh context has less bias and isn’t anchored to the primary agent’s reasoning. Use the built‑in /code-review skill or Code Review for GitHub. (Reference: https://code.claude.com/docs/en/code-review)

When a single result falls short, don’t just fix that instance—encode the fix into the system to improve all future iterations.

Managing Token Usage

Pick the right primitive and model for the task: Small tasks don’t need multiple agents or loops; some tasks can use cheaper, faster models.

Define clear success and stop criteria: Be specific about what “done” looks like so Claude reaches a solution faster (but doesn’t stop too early).

Pilot before scaling: Dynamic workflows can spawn hundreds of agents; evaluate usage on a smaller scope first.

Script deterministic work: Running a script is cheaper than reasoning step‑by‑step. Example: a PDF skill can include a form‑filling script that Claude runs each time instead of re‑deriving code.

Don’t run routine tasks more often than needed: Match the run interval to the change cadence of what you’re monitoring.

Review usage: /usage breaks down recent usage by skill, sub‑agent, and MCP; /goal without arguments shows current round and token usage; /workflows shows per‑agent token usage and lets you stop any agent.

Getting Started

Summary of loop types and when to use them:

Turn‑based – you’re exploring or deciding – use custom verification skills.

Goal‑based – you know what done looks like – use /goal.

Time‑based – work happens on a schedule outside your project – use /loop, /schedule.

Proactive – work is repetitive and well‑defined – use all of the above plus dynamic workflows.

Identify a task where you are the bottleneck. Ask what part you can hand off: can you write a verification check? Is the goal clear enough? Does the work arrive on a schedule? Run the loop, observe where it gets stuck or goes off track, and iterate.

For more, read the Claude Code docs on running agents in parallel ( https://code.claude.com/docs/en/agents), /loop, /schedule ( https://code.claude.com/docs/en/routines), /goal ( https://code.claude.com/docs/en/goal), and dynamic workflows (

https://code.claude.com/docs/en/workflows#orchestrate-subagents-at-scale-with-dynamic-workflows

).

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

token managementClaude CodeSKILL.mdagent loopsgoal-based loopsproactive loopstime-based loopsturn-based loops
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.