From claudecode-bootstrap
Six proven autonomous agent loop patterns with guard rails. Provides reusable patterns for generate->validate->fix, explore->hypothesize->test, and other autonomous workflows. Includes the reviewer-never-authored principle for quality assurance. Use when: (1) Building autonomous agent workflows, (2) Designing self-correcting pipelines, (3) Implementing agent retry/fix loops, (4) Setting up multi-agent review processes, (5) User asks about agent loop patterns.
How this skill is triggered — by the user, by Claude, or both
Slash command
/claudecode-bootstrap:autonomous-loopsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**The agent that reviews work must never be the agent that authored it.**
The agent that reviews work must never be the agent that authored it.
This is the single most important principle for autonomous quality. Self-review is unreliable -- the same blind spots that caused the error will miss it during review.
Implementation:
subagent_type or name) for reviewThe most common autonomous loop. Generate output, validate against criteria, fix if needed.
+----------+ +----------+ +----------+
| Generate |---->| Validate |---->| Fix |--+
| | | | | | |
+----------+ +----+-----+ +----------+ |
| Pass |
v |
+----------+ |
| Accept |<-------------------+
+----------+ (max 3 iterations)
When to use: Code generation, document creation, configuration authoring
MAX_ITERATIONS = 3
for iteration in range(MAX_ITERATIONS):
if iteration == 0:
output = generate(prompt, context)
else:
output = fix(output, validation_errors, context)
is_valid, errors = validate(output, acceptance_criteria)
if is_valid:
return accept(output)
return escalate_to_human(output, errors)
Guard rails:
For debugging and investigation. Gather evidence, form theory, validate.
+----------+ +-------------+ +----------+
| Explore |---->| Hypothesize |---->| Test |--+
| (gather | | (form | | (verify | |
| evidence)| | theory) | | theory) | |
+----------+ +-------------+ +----+-----+ |
| Fail |
v |
+----------+ |
| Refine |--+
| hypothesis|
+----------+
When to use: Bug investigation, root cause analysis, codebase exploration
Guard rails:
For multi-step implementation tasks.
+----------+ +----------+ +----------+ +----------+
| Plan |---->| Execute |---->| Verify |---->| Adjust |--+
| (steps) | | (step N) | | (tests) | | (plan) | |
+----------+ +----------+ +----------+ +----------+ |
^ |
+------------------------------------------------------------+
When to use: Feature implementation, refactoring, migration tasks
Guard rails:
For creative or design tasks where multiple approaches are valid.
+------------+ +------------+ +----------+
| Diverge |---->| Converge |---->| Select |
| (generate | | (evaluate | | (pick |
| N options)| | trade-offs)| | best) |
+------------+ +------------+ +----------+
When to use: Architecture decisions, API design, UI alternatives
Guard rails:
For building up content or code incrementally.
+----------+ +----------+ +----------+
| Seed |---->| Expand |---->| Prune |--+
| (minimal | | (add | | (remove | |
| version)| | features)| | bloat) | |
+----------+ +----------+ +----------+ |
^ |
+--------------------------+
(until scope complete)
When to use: MVP development, documentation, test suite building
Guard rails:
For reactive, event-driven agent workflows.
+----------+ +----------+ +----------+ +----------+
| Observe |---->| Orient |---->| Decide |---->| Act |
| (monitor | | (analyze | | (choose | | (execute |
| events) | | context)| | action) | | action) |
+----------+ +----------+ +----------+ +----------+
^ |
+----------------------------------------------------+
When to use: Monitoring, incident response, CI/CD automation
Guard rails:
| Task Type | Recommended Pattern |
|---|---|
| Code generation / editing | Generate -> Validate -> Fix |
| Bug investigation | Explore -> Hypothesize -> Test |
| Feature implementation | Plan -> Execute -> Verify -> Adjust |
| Architecture / design | Diverge -> Converge -> Select |
| Incremental building | Seed -> Expand -> Prune |
| Monitoring / ops | OODA |
Patterns can be nested. For example:
Apply these to ALL patterns:
npx claudepluginhub stevengonsalvez/ainb-toolkitGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.