Running Claude in loops enables spec-driven development, CI/CD-style pipelines, and iterative refinement without human intervention between steps.
Choose your pattern by complexity:
claude -p calls for linear workflows| Pattern | Setup | Complexity | Best For |
|---|---|---|---|
| --------- | ------- | ----------- | ---------- |
| Sequential Pipeline | Bash script | Low | Daily tasks, scripted workflows |
| REPL | Node/CLI | Low | Interactive development |
| Parallel Agents | Claude Code loop | Medium | Content generation, spec variations |
| PR Loop | Shell script | Medium | Iterative multi-day projects |
| De-Sloppify | Add-on to any | Optional | Quality cleanup after implementation |
| DAG Orchestration | Python/Node | High | Large features, parallel units, merge coordination |
references/sequential-pipeline.md — Basic claude -p loops with examplesreferences/persistent-repl.md — NanoClaw-style session persistencereferences/parallel-agents.md — Spec-driven deployment with wave managementreferences/pr-automation.md — Continuous Claude PR loop with CI gatesreferences/de-sloppify.md — Quality cleanup patternreferences/dag-orchestration.md — RFC-driven multi-unit coordinationIs this a single focused change?
├─ Yes → Sequential Pipeline
└─ No → Do you have a spec/RFC?
├─ Yes → Do you need parallel work?
│ ├─ Yes → DAG Orchestration
│ └─ No → PR Automation Loop
└─ No → Do you need many variations?
├─ Yes → Parallel Agents + Spec
└─ No → Sequential Pipeline + De-Sloppify
❌ Infinite loops without exit conditions
❌ No context bridge between iterations
❌ Retrying the same failure without capturing error context
❌ Negative instructions instead of cleanup passes
❌ All agents in one context window (reviewer should never be the author)
❌ Ignoring file overlap in parallel work
Adapted from everything-claude-code by @affaan-m (MIT)
共 1 个版本