Stop Writing Prompts: Claude’s Official Guide to 4 Types of Loops That Automate Work
The article discusses a shift in AI development from manually crafting prompts to designing "loops"—systems where AI agents autonomously perform tasks until a defined stopping condition is triggered. Inspired by figures like Peter Steinberger and Boris Cherny, this approach, termed "loop engineering," focuses on creating self-running systems rather than one-off interactions.
Claude Code's team formally defines a loop as an agent repeatedly executing work until a stop condition is met and categorizes four primary loop types based on their stopping mechanisms:
1. **Turn-based loops:** Human-controlled, step-by-step execution for short, discrete tasks.
2. **Goal loops (/goal):** An evaluator model checks outputs against predefined, quantifiable objectives (e.g., a performance score), forcing retries until the goal is met or a limit is reached.
3. **Time loops (/loop and /schedule):** Time-triggered, like cron jobs, for recurring tasks (e.g., daily summaries) or monitoring external systems.
4. **Proactive loops:** Event or time-triggered, fully automated workflows for ongoing, bounded tasks like bug triage, running until manually stopped.
The core shift is from designing prompt content to designing the behavioral system—its triggers, verification mechanisms, and termination rules. Effective verification, where the agent can self-check its output, is highlighted as crucial for loop efficiency.
The article warns that uncontrolled loops risk high costs and getting stuck in unproductive cycles. It recommends implementing essential "gates": machine-verifiable completion conditions, hard limits on iterations/cost, and stagnation detection. Best practices include using smaller models where possible, testing on small scales first, and automating deterministic parts with scripts.
In summary, AI programming is evolving from prompt engineering to system design, where the skill lies in architecting loops that can autonomously execute, validate, and decisively conclude their work.
marsbit07/17 01:06