Getting Started with Loops
Key point
The Claude Code team introduces three types of agent loops it defines and how to manage them efficiently.
Details
In recent coding agent usage, the importance of 'Designing Loops' beyond simple prompting is growing. The Claude Code team defines a loop as 'an agent that repeats work cycles until a stopping condition is met', and classifies it into three types based on trigger method and stopping criteria.
1. Turn-based loops Started by a user's prompt, these end when Claude judges the task complete or determines additional context is needed. They are suitable for short, one-off tasks, and using a SKILL.md file to automate verification steps can help manage token usage and improve quality.
2. Goal-based loop (/goal) Used for complex tasks with clear completion criteria (e.g., passing tests, reaching a certain score). To prevent the agent from ending early by judging on its own that it has done 'enough', the loop continues repeating until the set goal or a maximum number of iterations is reached.
3. Time-based loop (/loop and /schedule) Suitable for repetitive tasks triggered at specific time intervals. It is useful for handling regular work where only the input changes but the task itself stays the same, such as summarizing Slack messages, and efficiency can be improved by configuring it to react in an event-driven manner.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.