Mastering Loop Engineering with Claude Code
AI LABSgo watch the original →
the gist
Loop engineering shifts the developer's role from manual verification to defining 'done' criteria, allowing AI agents to autonomously build, verify, and ship features via iterative goal-based loops.
The Shift from Prompting to Loop Engineering
Loop engineering is the evolution of AI-assisted development where the human stops acting as the manual verification layer. In traditional prompting, the developer provides a prompt, the agent builds, the developer checks, and the cycle repeats. In loop engineering, the developer defines the goal and the criteria for success, and the agent iterates autonomously until those criteria are met. This process is now viable because modern models can maintain context and operate for hours without human intervention.
Level 1: The Single-Goal Loop
At the entry level, the focus is on a single feature. The core distinction is between the /loop command (which runs on a timer) and the /goal command (which runs until a condition is met). The developer creates a features/ directory where each feature contains a spec file and an empty verification folder. The agent uses a 'Grill Me' skill to clarify requirements before building. Verification is automated by a smaller model that evaluates the output against the spec. A key insight here is that the agent should not verify its own work; instead, it uses a separate, faster verification step—such as screenshot-based checks—to confirm progress.
Level 2: The Software Factory Workflow
Scaling to multiple features requires a 'factory' approach. The developer plans several features at once, creating a queue in a queue.md file. Before building, the agent creates a clickable UI prototype; this serves two purposes: validating the user's intent and providing a baseline for the agent to verify against. The workflow utilizes sub-agents: one agent builds on a separate branch, while an adversarial review agent attempts to find bugs. The main agent loops until the adversarial agent approves the work. Once approved, the branch is merged, and the deployment platform (Vercel) automatically pushes the update to production.
Level 3: Remote Agentic Control
At the highest level, the developer removes themselves from the laptop entirely. By using tools like Paseo, the developer can run Claude Code on a local machine while interacting with it via a mobile interface. This allows for 'plan and approve' workflows where the developer only intervenes to set the high-level goal and perform the final merge approval. Mobile preview skills allow the developer to click through prototypes on a phone, ensuring the product feels right before it is fully deployed.
Key Takeaways
- Define 'Done' upfront: Never start a loop without clear, objective success criteria in a spec file.
- Separate build and verify: The agent that writes the code should never be the one to verify it; use a secondary agent or a distinct verification pass.
- Use prototypes: Build a non-functional UI prototype first to ensure the vision matches the requirement before investing in logic.
- Leverage CLIs: Use platform CLIs (Vercel, Supabase) to allow the agent to manage infrastructure autonomously.
- Avoid looping MVPs: Build the initial rough version by hand; loops are for refining and scaling features once the direction is established.