The Gather-Context, Plan, Act, Verify Loop
CoreImprove developer workflows with AI-assisted tooling · Difficulty 2/5
Explanation
Anthropic's Claude Code best practice for raising developer productivity is a disciplined four-stage loop, not an unsupervised speedup.
The Loop
| Stage | What Happens | Why It Matters |
|---|---|---|
| Gather context | Give the agent the right context | Under-context causes guessing; over-context causes context rot |
| Plan | Let the agent plan before acting | Surfaces the approach before code changes are made |
| Act | The agent makes the change | Executes against the agreed plan |
| Verify | Check the result (tests, build, review) | Catches errors before they compound |
Each stage feeds the next: a lean, well-scoped context produces a better plan, a better plan produces a more correct action, and verification confirms (or corrects) that the action actually achieved the intended result.
Keep Context Lean
The best-practice loop explicitly calls for keeping context lean to avoid context rot -- degraded output quality that results from an overloaded or stale context window. Productivity gains from AI-assisted tooling come from giving the agent exactly the context it needs, not from maximizing how much is loaded.
The Goal: Leverage With Guardrails
The architect's job in promoting this workflow is to raise throughput while keeping verification and least privilege in place. The loop is what makes "AI-assisted" safe to scale across a team: it is a repeatable discipline, not a one-off habit left to individual developers.
Common exam traps
- Equating "AI-assisted" with "unsupervised." Productivity gains come from a disciplined verify step and lean context, not from removing checks. An exam item describing an agent running fully unsupervised on production as a productivity win should be recognized as the anti-pattern, not the best practice.
Key Takeaways
- The best-practice workflow is gather-context, plan, act, verify -- not a single unsupervised step
- Keep context lean at each stage to avoid context rot degrading output quality
- The verify stage (tests, build, review) is what makes AI-assisted speed safe, not optional overhead
- The goal is leverage with guardrails: raise throughput while keeping verification and least privilege in place
- Removing the verify step or running agents unsupervised on production is the anti-pattern the exam tests against
Glossary Terms
A Claude Code execution mode for exploration and analysis before making changes. Claude reads and analyzes but does not write files or execute commands. Use when requirements are ambiguous, multiple valid approaches exist, or decisions have significant architectural implications.
A Claude Code workflow pattern that builds solutions incrementally through small, verifiable steps rather than attempting complete implementation in one pass. Each step produces testable output; failures are caught early. Pair with test-driven iteration for maximum reliability.
A Claude Code workflow where tests are written or identified before implementation, and each iteration is verified by running the test suite. Claude uses test failures as feedback to correct its approach. The 'interview pattern' involves asking clarifying questions before writing any code.
Related Concepts
Programmatic Enablement: Agent SDK & Headless Mode
The Agent SDK enables building custom internal agents for CI/CD checks, codebase modernization, and repetitive engineering tasks
Issue Isolation: Localizing Failures Across Layers
Isolate a failure to transport, integration/parsing code, retrieval, or model output before applying any fix