autonomous-loops by affaan-m/everything-claude-code
npx skills add https://github.com/affaan-m/everything-claude-code --skill autonomous-loops兼容性说明 (v1.8.0):
autonomous-loops将保留一个版本。规范的技能名称现在是continuous-agent-loop。新的循环指南应在此处编写,而此技能仍可用以避免破坏现有工作流。
用于在循环中自主运行 Claude Code 的模式、架构和参考实现。涵盖从简单的 claude -p 管道到完整的 RFC 驱动的多智能体 DAG 编排的一切。
从最简单到最复杂:
| 模式 | 复杂度 | 最适合 |
|---|---|---|
| 顺序管道 | 低 | 日常开发步骤,脚本化工作流 |
| NanoClaw REPL | 低 | 交互式持久会话 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 无限智能体循环 | 中 | 并行内容生成,规范驱动的工作 |
| 持续 Claude PR 循环 | 中 | 具有 CI 门控的多日迭代项目 |
| 去杂乱模式 | 附加组件 | 在任何实现者步骤之后进行质量清理 |
| Ralphinho / RFC 驱动的 DAG | 高 | 大型功能,具有合并队列的多单元并行工作 |
claude -p)最简单的循环。 将日常开发分解为一系列非交互式的 claude -p 调用。每次调用都是一个具有清晰提示的专注步骤。
如果你无法设计出这样的循环,那意味着你甚至无法在交互模式下驱动 LLM 来修复你的代码。
claude -p 标志以非交互方式运行 Claude Code 并附带提示,完成后退出。链接调用以构建管道:
#!/bin/bash
# daily-dev.sh — 用于功能分支的顺序管道
set -e
# 步骤 1: 实现功能
claude -p "阅读 docs/auth-spec.md 中的规范。在 src/auth/ 中实现 OAuth2 登录。先编写测试(TDD)。不要创建任何新的文档文件。"
# 步骤 2: 去杂乱(清理环节)
claude -p "审查上一次提交更改的所有文件。移除任何不必要的类型测试、过度防御性检查或对语言特性的测试(例如,测试 TypeScript 泛型是否有效)。保留真实的业务逻辑测试。清理后运行测试套件。"
# 步骤 3: 验证
claude -p "运行完整的构建、代码检查、类型检查和测试套件。修复任何失败。不要添加新功能。"
# 步骤 4: 提交
claude -p "为所有暂存的更改创建一个约定式提交。使用 'feat: add OAuth2 login flow' 作为提交信息。"
claude -p 调用都有一个新的上下文窗口,意味着步骤之间没有上下文泄漏。set -e 在失败时停止管道。使用模型路由:
# 使用 Opus 进行研究(深度推理)
claude -p --model opus "分析代码库架构,并为添加缓存编写计划..."
# 使用 Sonnet 实现(快速,能力强)
claude -p "根据 docs/caching-plan.md 中的计划实现缓存层..."
# 使用 Opus 审查(彻底)
claude -p --model opus "审查所有更改以查找安全问题、竞态条件和边界情况..."
使用环境上下文:
# 通过文件传递上下文,而不是提示长度
echo "重点领域:认证模块,API 速率限制" > .claude-context.md
claude -p "阅读 .claude-context.md 了解优先级。按顺序处理它们。"
rm .claude-context.md
使用 --allowedTools 限制:
# 只读分析环节
claude -p --allowedTools "Read,Grep,Glob" "审计此代码库以查找安全漏洞..."
# 只写实现环节
claude -p --allowedTools "Read,Write,Edit,Bash" "根据 security-audit.md 实现修复..."
ECC 内置的持久循环。 一个具有会话感知能力的 REPL,它使用完整的对话历史记录同步调用 claude -p。
# 启动默认会话
node scripts/claw.js
# 带有技能上下文的命名会话
CLAW_SESSION=my-project CLAW_SKILLS=tdd-workflow,security-review node scripts/claw.js
~/.claude/claw/{session}.md 加载对话历史记录claude -p| 使用场景 | NanoClaw | 顺序管道 |
|---|---|---|
| 交互式探索 | 是 | 否 |
| 脚本化自动化 | 否 | 是 |
| 会话持久性 | 内置 | 手动 |
| 上下文累积 | 每轮增长 | 每步刷新 |
| CI/CD 集成 | 差 | 优秀 |
有关完整详情,请参阅 /claw 命令文档。
一个双提示系统,用于协调并行子智能体进行规范驱动的生成。由 disler 开发(致谢:@disler)。
PROMPT 1 (协调器) PROMPT 2 (子智能体)
┌─────────────────────┐ ┌──────────────────────┐
│ 解析规范文件 │ │ 接收完整上下文 │
│ 扫描输出目录 │ 部署 │ 读取分配的编号 │
│ 计划迭代 │────────────│ 严格按照规范执行 │
│ 分配创意方向 │ N 个智能体│ 生成独特的输出 │
│ 管理批次 │ │ 保存到输出目录 │
└─────────────────────┘ └──────────────────────┘
创建 .claude/commands/infinite.md:
Parse the following arguments from $ARGUMENTS:
1. spec_file — path to the specification markdown
2. output_dir — where iterations are saved
3. count — integer 1-N or "infinite"
PHASE 1: Read and deeply understand the specification.
PHASE 2: List output_dir, find highest iteration number. Start at N+1.
PHASE 3: Plan creative directions — each agent gets a DIFFERENT theme/approach.
PHASE 4: Deploy sub-agents in parallel (Task tool). Each receives:
- Full spec text
- Current directory snapshot
- Their assigned iteration number
- Their unique creative direction
PHASE 5 (infinite mode): Loop in waves of 3-5 until context is low.
调用:
/project:infinite specs/component-spec.md src/ 5
/project:infinite specs/component-spec.md src/ infinite
| 数量 | 策略 |
|---|---|
| 1-5 | 所有智能体同时进行 |
| 6-20 | 每批 5 个 |
| infinite | 每批 3-5 个,逐步提升复杂度 |
不要依赖智能体自我区分。协调器分配每个智能体一个特定的创意方向和迭代编号。这可以防止并行智能体之间出现重复概念。
一个生产级的 shell 脚本,在持续循环中运行 Claude Code,创建 PR,等待 CI,并自动合并。由 AnandChowdhary 创建(致谢:@AnandChowdhary)。
┌─────────────────────────────────────────────────────┐
│ 持续 CLAUDE 迭代 │
│ │
│ 1. 创建分支 (continuous-claude/iteration-N) │
│ 2. 使用增强提示运行 claude -p │
│ 3. (可选)审查环节 — 单独的 claude -p │
│ 4. 提交更改 (claude 生成提交信息) │
│ 5. 推送 + 创建 PR (gh pr create) │
│ 6. 等待 CI 检查 (轮询 gh pr checks) │
│ 7. CI 失败? → 自动修复环节 (claude -p) │
│ 8. 合并 PR (squash/merge/rebase) │
│ 9. 返回主分支 → 重复 │
│ │
│ 限制条件:--max-runs N | --max-cost $X │
│ --max-duration 2h | 完成信号 │
└─────────────────────────────────────────────────────┘
curl -fsSL https://raw.githubusercontent.com/AnandChowdhary/continuous-claude/HEAD/install.sh | bash
# 基础:10 次迭代
continuous-claude --prompt "为所有未测试的函数添加单元测试" --max-runs 10
# 成本限制
continuous-claude --prompt "修复所有代码检查错误" --max-cost 5.00
# 时间限制
continuous-claude --prompt "提高测试覆盖率" --max-duration 8h
# 带代码审查环节
continuous-claude \
--prompt "添加认证功能" \
--max-runs 10 \
--review-prompt "运行 npm test && npm run lint,修复任何失败"
# 通过 worktrees 并行执行
continuous-claude --prompt "添加测试" --max-runs 5 --worktree tests-worker &
continuous-claude --prompt "重构代码" --max-runs 5 --worktree refactor-worker &
wait
关键创新:一个 SHARED_TASK_NOTES.md 文件在迭代之间持久存在:
## 进度
- [x] 为认证模块添加了测试(迭代 1)
- [x] 修复了令牌刷新中的边界情况(迭代 2)
- [ ] 仍需:速率限制测试,错误边界测试
## 后续步骤
- 接下来专注于速率限制模块
- tests/helpers.ts 中的模拟设置可以重用
Claude 在迭代开始时读取此文件,并在迭代结束时更新它。这弥合了独立 claude -p 调用之间的上下文差距。
当 PR 检查失败时,Continuous Claude 自动执行:
gh run list 获取失败的运行 IDclaude -pgh run view 检查日志,修复代码,提交,推送--ci-retry-max 次)Claude 可以通过输出一个魔法短语来发出"我已完成"的信号:
continuous-claude \
--prompt "修复问题跟踪器中的所有错误" \
--completion-signal "CONTINUOUS_CLAUDE_PROJECT_COMPLETE" \
--completion-threshold 3 # 连续 3 次信号后停止
连续三次迭代发出完成信号会停止循环,防止在已完成的工作上浪费运行。
| 标志 | 用途 |
|---|---|
--max-runs N | 在 N 次成功迭代后停止 |
--max-cost $X | 在花费 $X 后停止 |
--max-duration 2h | 在时间用完后停止 |
--merge-strategy squash | squash、merge 或 rebase |
--worktree <name> | 通过 git worktrees 并行执行 |
--disable-commits | 试运行模式(无 git 操作) |
--review-prompt "..." | 每次迭代添加审查环节 |
--ci-retry-max N | 自动修复 CI 失败(默认:1) |
适用于任何循环的附加模式。 在每个实现者步骤之后添加一个专门的清理/重构步骤。
当你要求 LLM 使用 TDD 实现时,它会过于字面地理解"编写测试":
typeof x === 'string')在实现者提示中添加"不要测试类型系统"或"不要添加不必要的检查"会产生下游影响:
不要限制实现者,让它彻底完成。然后添加一个专注的清理智能体:
# 步骤 1: 实现(让它彻底完成)
claude -p "使用完整的 TDD 实现该功能。测试要彻底。"
# 步骤 2: 去杂乱(独立上下文,专注清理)
claude -p "审查工作树中的所有更改。移除:
- 验证语言/框架行为而非业务逻辑的测试
- 类型系统已经强制执行的多余类型检查
- 对不可能状态的过度防御性错误处理
- Console.log 语句
- 注释掉的代码
保留所有业务逻辑测试。清理后运行测试套件以确保没有破坏任何东西。"
for feature in "${features[@]}"; do
# 实现
claude -p "使用 TDD 实现 $feature。"
# 去杂乱
claude -p "清理环节:审查更改,移除测试/代码杂乱,运行测试。"
# 验证
claude -p "运行构建 + 代码检查 + 测试。修复任何失败。"
# 提交
claude -p "提交并附带信息:feat: add $feature"
done
与其添加具有下游质量影响的否定性指令,不如添加一个独立的去杂乱环节。两个专注的智能体优于一个受约束的智能体。
最复杂的模式。 一个 RFC 驱动的多智能体管道,将规范分解为依赖关系 DAG,通过分层质量管道运行每个单元,并通过智能体驱动的合并队列落地。由 enitrat 创建(致谢:@enitrat)。
RFC/PRD 文档
│
▼
分解 (AI)
将 RFC 分解为具有依赖关系 DAG 的工作单元
│
▼
┌──────────────────────────────────────────────────────┐
│ RALPH 循环(最多 3 轮) │
│ │
│ 对于每个 DAG 层(按依赖关系顺序): │
│ │
│ ┌── 质量管道(每个单元并行) ───────┐ │
│ │ 每个单元在自己的 worktree 中: │ │
│ │ 研究 → 计划 → 实现 → 测试 → 审查 │ │
│ │ (深度因复杂度层级而异) │ │
│ └────────────────────────────────────────────────┘ │
│ │
│ ┌── 合并队列 ─────────────────────────────────┐ │
│ │ 变基到主分支 → 运行测试 → 落地或驱逐 │ │
│ │ 被驱逐的单元带着冲突上下文重新进入 │ │
│ └────────────────────────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────┘
AI 读取 RFC 并生成工作单元:
interface WorkUnit {
id: string; // kebab-case 标识符
name: string; // 人类可读名称
rfcSections: string[]; // 此单元涉及哪些 RFC 部分
description: string; // 详细描述
deps: string[]; // 依赖项(其他单元 ID)
acceptance: string[]; // 具体的验收标准
tier: "trivial" | "small" | "medium" | "large";
}
分解规则:
依赖关系 DAG 决定了执行顺序:
Layer 0: [unit-a, unit-b] ← 无依赖,并行运行
Layer 1: [unit-c] ← 依赖于 unit-a
Layer 2: [unit-d, unit-e] ← 依赖于 unit-c
不同层级获得不同深度的管道:
| 层级 | 管道阶段 |
|---|---|
| trivial | 实现 → 测试 |
| small | 实现 → 测试 → 代码审查 |
| medium | 研究 → 计划 → 实现 → 测试 → PRD 审查 + 代码审查 → 审查修复 |
| large | 研究 → 计划 → 实现 → 测试 → PRD 审查 + 代码审查 → 审查修复 → 最终审查 |
这可以防止在简单更改上进行昂贵的操作,同时确保架构更改得到彻底审查。
每个阶段在自己的智能体进程中运行,拥有自己的上下文窗口:
| 阶段 | 模型 | 目的 |
|---|---|---|
| 研究 | Sonnet | 读取代码库 + RFC,生成上下文文档 |
| 计划 | Opus | 设计实现步骤 |
| 实现 | Codex | 按照计划编写代码 |
| 测试 | Sonnet | 运行构建 + 测试套件 |
| PRD 审查 | Sonnet | 规范符合性检查 |
| 代码审查 | Opus | 质量 + 安全检查 |
| 审查修复 | Codex | 处理审查问题 |
| 最终审查 | Opus | 质量门控(仅限大型层级) |
关键设计: 审查者从未编写过它正在审查的代码。这消除了作者偏见——这是自我审查中最常见的遗漏问题来源。
质量管道完成后,单元进入合并队列:
单元分支
│
├─ 变基到主分支
│ └─ 冲突? → 驱逐(捕获冲突上下文)
│
├─ 运行构建 + 测试
│ └─ 失败? → 驱逐(捕获测试输出)
│
└─ 通过 → 快进主分支,推送,删除分支
文件重叠智能:
驱逐恢复: 当被驱逐时,会捕获完整的上下文(冲突文件、差异、测试输出)并在下一轮 Ralph 循环中反馈给实现者:
## 合并冲突 — 在下一次落地前解决
你之前的实现与另一个先落地的单元发生了冲突。
重构你的更改以避免下面的冲突文件/行。
{包含差异的完整驱逐上下文}
research.contextFilePath ──────────────────→ plan
plan.implementationSteps ──────────────────→ implement
implement.{filesCreated, whatWasDone} ─────→ test, reviews
test.failingSummary ───────────────────────→ reviews, implement (next pass)
reviews.{feedback, issues} ────────────────→ review-fix → implement (next pass)
final-review.reasoning ────────────────────→ implement (next pass)
evictionContext ───────────────────────────→ implement (after merge conflict)
每个单元在隔离的 worktree 中运行(使用 jj/Jujutsu,而不是 git):
/tmp/workflow-wt-{unit-id}/
同一单元的管道阶段共享一个 worktree,在研究 → 计划 → 实现 → 测试 → 审查之间保留状态(上下文文件、计划文件、代码更改)。
| 信号 | 使用 Ralphinho | 使用更简单的模式 |
|---|---|---|
| 多个相互依赖的工作单元 | 是 | 否 |
| 需要并行实现 | 是 | 否 |
| 可能发生合并冲突 | 是 | 否(顺序执行即可) |
| 单文件更改 | 否 | 是(顺序管道) |
| 多日项目 | 是 | 可能(continuous-claude) |
| 规范/RFC 已编写 | 是 | 可能 |
| 快速迭代单一事物 | 否 | 是(NanoClaw 或管道) |
任务是单一专注的更改吗?
├─ 是 → 顺序管道或 NanoClaw
└─ 否 → 是否有书面规范/RFC?
├─ 是 → 是否需要并行实现?
│ ├─ 是 → Ralphinho (DAG 编排)
│ └─ 否 → Continuous Claude (迭代 PR 循环)
└─ 否 → 是否需要同一事物的许多变体?
├─ 是 → 无限智能体循环 (规范驱动生成)
└─ 否 → 带有去杂乱功能的顺序管道
这些模式可以很好地组合:
顺序管道 + 去杂乱 — 最常见的组合。每个实现步骤都附带一个清理环节。
Continuous Claude + 去杂乱 — 为每次迭代添加带有去杂乱指令的 --review-prompt。
任何循环 + 验证 — 在提交前使用 ECC 的 /verify 命令或 verification-loop 技能作为门控。
在更简单的循环中使用 Ralphinho 的分层方法 — 即使在顺序管道中,你也可以将简单任务路由到 Haiku,复杂任务路由到 Opus:
# 简单的格式化修复
claude -p --model haiku "修复 src/utils.ts 中的导入顺序"
# 复杂的架构更改
claude -p --model opus "重构认证模块以使用策略模式"
没有退出条件的无限循环 — 始终设置 max-runs、max-cost、max-duration 或完成信号。
迭代之间没有上下文桥梁 — 每个 claude -p 调用都是全新的开始。使用 SHARED_TASK_NOTES.md 或文件系统状态来桥接上下文。
重试相同的失败 — 如果一次迭代失败,不要只是重试。捕获错误上下文并将其提供给下一次尝试。
使用否定性指令而非清理环节 — 不要说"不要做 X"。添加一个移除 X 的独立环节。
所有智能体在一个上下文窗口中 — 对于复杂的工作流,将关注点分离到不同的智能体进程中。审查者永远不应该是作者。
在并行工作中忽略文件重叠 — 如果两个并行智能体可能编辑同一个文件,你需要一个合并策略(顺序落地、变基或冲突解决)。
| 项目 | 作者 | 链接 |
|---|---|---|
| Ralphinho | enitrat | credit: @enitrat |
| 无限智能体循环 | disler | credit: @disler |
| Continuous Claude | AnandChowdhary | credit: @AnandChowdhary |
| NanoClaw | ECC | 此仓库中的 /claw 命令 |
| 验证循环 | ECC | 此仓库中的 skills/verification-loop/ |
每周安装量
233
仓库
GitHub 星标数
70.6K
首次出现
8 天前
安全审计
安装于
codex221
kimi-cli197
gemini-cli197
cursor197
opencode197
amp197
Compatibility note (v1.8.0):
autonomous-loopsis retained for one release. The canonical skill name is nowcontinuous-agent-loop. New loop guidance should be authored there, while this skill remains available to avoid breaking existing workflows.
Patterns, architectures, and reference implementations for running Claude Code autonomously in loops. Covers everything from simple claude -p pipelines to full RFC-driven multi-agent DAG orchestration.
From simplest to most sophisticated:
| Pattern | Complexity | Best For |
|---|---|---|
| Sequential Pipeline | Low | Daily dev steps, scripted workflows |
| NanoClaw REPL | Low | Interactive persistent sessions |
| Infinite Agentic Loop | Medium | Parallel content generation, spec-driven work |
| Continuous Claude PR Loop | Medium | Multi-day iterative projects with CI gates |
| De-Sloppify Pattern | Add-on | Quality cleanup after any Implementer step |
| Ralphinho / RFC-Driven DAG | High | Large features, multi-unit parallel work with merge queue |
claude -p)The simplest loop. Break daily development into a sequence of non-interactive claude -p calls. Each call is a focused step with a clear prompt.
If you can't figure out a loop like this, it means you can't even drive the LLM to fix your code in interactive mode.
The claude -p flag runs Claude Code non-interactively with a prompt, exits when done. Chain calls to build a pipeline:
#!/bin/bash
# daily-dev.sh — Sequential pipeline for a feature branch
set -e
# Step 1: Implement the feature
claude -p "Read the spec in docs/auth-spec.md. Implement OAuth2 login in src/auth/. Write tests first (TDD). Do NOT create any new documentation files."
# Step 2: De-sloppify (cleanup pass)
claude -p "Review all files changed by the previous commit. Remove any unnecessary type tests, overly defensive checks, or testing of language features (e.g., testing that TypeScript generics work). Keep real business logic tests. Run the test suite after cleanup."
# Step 3: Verify
claude -p "Run the full build, lint, type check, and test suite. Fix any failures. Do not add new features."
# Step 4: Commit
claude -p "Create a conventional commit for all staged changes. Use 'feat: add OAuth2 login flow' as the message."
claude -p call means no context bleed between steps.set -e stops the pipeline on failure.With model routing:
# Research with Opus (deep reasoning)
claude -p --model opus "Analyze the codebase architecture and write a plan for adding caching..."
# Implement with Sonnet (fast, capable)
claude -p "Implement the caching layer according to the plan in docs/caching-plan.md..."
# Review with Opus (thorough)
claude -p --model opus "Review all changes for security issues, race conditions, and edge cases..."
With environment context:
# Pass context via files, not prompt length
echo "Focus areas: auth module, API rate limiting" > .claude-context.md
claude -p "Read .claude-context.md for priorities. Work through them in order."
rm .claude-context.md
With--allowedTools restrictions:
# Read-only analysis pass
claude -p --allowedTools "Read,Grep,Glob" "Audit this codebase for security vulnerabilities..."
# Write-only implementation pass
claude -p --allowedTools "Read,Write,Edit,Bash" "Implement the fixes from security-audit.md..."
ECC's built-in persistent loop. A session-aware REPL that calls claude -p synchronously with full conversation history.
# Start the default session
node scripts/claw.js
# Named session with skill context
CLAW_SESSION=my-project CLAW_SKILLS=tdd-workflow,security-review node scripts/claw.js
~/.claude/claw/{session}.mdclaude -p with full history as context| Use Case | NanoClaw | Sequential Pipeline |
|---|---|---|
| Interactive exploration | Yes | No |
| Scripted automation | No | Yes |
| Session persistence | Built-in | Manual |
| Context accumulation | Grows per turn | Fresh each step |
| CI/CD integration | Poor | Excellent |
See the /claw command documentation for full details.
A two-prompt system that orchestrates parallel sub-agents for specification-driven generation. Developed by disler (credit: @disler).
PROMPT 1 (Orchestrator) PROMPT 2 (Sub-Agents)
┌─────────────────────┐ ┌──────────────────────┐
│ Parse spec file │ │ Receive full context │
│ Scan output dir │ deploys │ Read assigned number │
│ Plan iteration │────────────│ Follow spec exactly │
│ Assign creative dirs │ N agents │ Generate unique output │
│ Manage waves │ │ Save to output dir │
└─────────────────────┘ └──────────────────────┘
Create .claude/commands/infinite.md:
Parse the following arguments from $ARGUMENTS:
1. spec_file — path to the specification markdown
2. output_dir — where iterations are saved
3. count — integer 1-N or "infinite"
PHASE 1: Read and deeply understand the specification.
PHASE 2: List output_dir, find highest iteration number. Start at N+1.
PHASE 3: Plan creative directions — each agent gets a DIFFERENT theme/approach.
PHASE 4: Deploy sub-agents in parallel (Task tool). Each receives:
- Full spec text
- Current directory snapshot
- Their assigned iteration number
- Their unique creative direction
PHASE 5 (infinite mode): Loop in waves of 3-5 until context is low.
Invoke:
/project:infinite specs/component-spec.md src/ 5
/project:infinite specs/component-spec.md src/ infinite
| Count | Strategy |
|---|---|
| 1-5 | All agents simultaneously |
| 6-20 | Batches of 5 |
| infinite | Waves of 3-5, progressive sophistication |
Don't rely on agents to self-differentiate. The orchestrator assigns each agent a specific creative direction and iteration number. This prevents duplicate concepts across parallel agents.
A production-grade shell script that runs Claude Code in a continuous loop, creating PRs, waiting for CI, and merging automatically. Created by AnandChowdhary (credit: @AnandChowdhary).
┌─────────────────────────────────────────────────────┐
│ CONTINUOUS CLAUDE ITERATION │
│ │
│ 1. Create branch (continuous-claude/iteration-N) │
│ 2. Run claude -p with enhanced prompt │
│ 3. (Optional) Reviewer pass — separate claude -p │
│ 4. Commit changes (claude generates message) │
│ 5. Push + create PR (gh pr create) │
│ 6. Wait for CI checks (poll gh pr checks) │
│ 7. CI failure? → Auto-fix pass (claude -p) │
│ 8. Merge PR (squash/merge/rebase) │
│ 9. Return to main → repeat │
│ │
│ Limit by: --max-runs N | --max-cost $X │
│ --max-duration 2h | completion signal │
└─────────────────────────────────────────────────────┘
curl -fsSL https://raw.githubusercontent.com/AnandChowdhary/continuous-claude/HEAD/install.sh | bash
# Basic: 10 iterations
continuous-claude --prompt "Add unit tests for all untested functions" --max-runs 10
# Cost-limited
continuous-claude --prompt "Fix all linter errors" --max-cost 5.00
# Time-boxed
continuous-claude --prompt "Improve test coverage" --max-duration 8h
# With code review pass
continuous-claude \
--prompt "Add authentication feature" \
--max-runs 10 \
--review-prompt "Run npm test && npm run lint, fix any failures"
# Parallel via worktrees
continuous-claude --prompt "Add tests" --max-runs 5 --worktree tests-worker &
continuous-claude --prompt "Refactor code" --max-runs 5 --worktree refactor-worker &
wait
The critical innovation: a SHARED_TASK_NOTES.md file persists across iterations:
## Progress
- [x] Added tests for auth module (iteration 1)
- [x] Fixed edge case in token refresh (iteration 2)
- [ ] Still need: rate limiting tests, error boundary tests
## Next Steps
- Focus on rate limiting module next
- The mock setup in tests/helpers.ts can be reused
Claude reads this file at iteration start and updates it at iteration end. This bridges the context gap between independent claude -p invocations.
When PR checks fail, Continuous Claude automatically:
gh run listclaude -p with CI fix contextgh run view, fixes code, commits, pushes--ci-retry-max attempts)Claude can signal "I'm done" by outputting a magic phrase:
continuous-claude \
--prompt "Fix all bugs in the issue tracker" \
--completion-signal "CONTINUOUS_CLAUDE_PROJECT_COMPLETE" \
--completion-threshold 3 # Stops after 3 consecutive signals
Three consecutive iterations signaling completion stops the loop, preventing wasted runs on finished work.
| Flag | Purpose |
|---|---|
--max-runs N | Stop after N successful iterations |
--max-cost $X | Stop after spending $X |
--max-duration 2h | Stop after time elapsed |
--merge-strategy squash | squash, merge, or rebase |
--worktree <name> | Parallel execution via git worktrees |
--disable-commits |
An add-on pattern for any loop. Add a dedicated cleanup/refactor step after each Implementer step.
When you ask an LLM to implement with TDD, it takes "write tests" too literally:
typeof x === 'string')Adding "don't test type systems" or "don't add unnecessary checks" to the Implementer prompt has downstream effects:
Instead of constraining the Implementer, let it be thorough. Then add a focused cleanup agent:
# Step 1: Implement (let it be thorough)
claude -p "Implement the feature with full TDD. Be thorough with tests."
# Step 2: De-sloppify (separate context, focused cleanup)
claude -p "Review all changes in the working tree. Remove:
- Tests that verify language/framework behavior rather than business logic
- Redundant type checks that the type system already enforces
- Over-defensive error handling for impossible states
- Console.log statements
- Commented-out code
Keep all business logic tests. Run the test suite after cleanup to ensure nothing breaks."
for feature in "${features[@]}"; do
# Implement
claude -p "Implement $feature with TDD."
# De-sloppify
claude -p "Cleanup pass: review changes, remove test/code slop, run tests."
# Verify
claude -p "Run build + lint + tests. Fix any failures."
# Commit
claude -p "Commit with message: feat: add $feature"
done
Rather than adding negative instructions which have downstream quality effects, add a separate de-sloppify pass. Two focused agents outperform one constrained agent.
The most sophisticated pattern. An RFC-driven, multi-agent pipeline that decomposes a spec into a dependency DAG, runs each unit through a tiered quality pipeline, and lands them via an agent-driven merge queue. Created by enitrat (credit: @enitrat).
RFC/PRD Document
│
▼
DECOMPOSITION (AI)
Break RFC into work units with dependency DAG
│
▼
┌──────────────────────────────────────────────────────┐
│ RALPH LOOP (up to 3 passes) │
│ │
│ For each DAG layer (sequential, by dependency): │
│ │
│ ┌── Quality Pipelines (parallel per unit) ───────┐ │
│ │ Each unit in its own worktree: │ │
│ │ Research → Plan → Implement → Test → Review │ │
│ │ (depth varies by complexity tier) │ │
│ └────────────────────────────────────────────────┘ │
│ │
│ ┌── Merge Queue ─────────────────────────────────┐ │
│ │ Rebase onto main → Run tests → Land or evict │ │
│ │ Evicted units re-enter with conflict context │ │
│ └────────────────────────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────┘
AI reads the RFC and produces work units:
interface WorkUnit {
id: string; // kebab-case identifier
name: string; // Human-readable name
rfcSections: string[]; // Which RFC sections this addresses
description: string; // Detailed description
deps: string[]; // Dependencies (other unit IDs)
acceptance: string[]; // Concrete acceptance criteria
tier: "trivial" | "small" | "medium" | "large";
}
Decomposition Rules:
The dependency DAG determines execution order:
Layer 0: [unit-a, unit-b] ← no deps, run in parallel
Layer 1: [unit-c] ← depends on unit-a
Layer 2: [unit-d, unit-e] ← depend on unit-c
Different tiers get different pipeline depths:
| Tier | Pipeline Stages |
|---|---|
| trivial | implement → test |
| small | implement → test → code-review |
| medium | research → plan → implement → test → PRD-review + code-review → review-fix |
| large | research → plan → implement → test → PRD-review + code-review → review-fix → final-review |
This prevents expensive operations on simple changes while ensuring architectural changes get thorough scrutiny.
Each stage runs in its own agent process with its own context window:
| Stage | Model | Purpose |
|---|---|---|
| Research | Sonnet | Read codebase + RFC, produce context doc |
| Plan | Opus | Design implementation steps |
| Implement | Codex | Write code following the plan |
| Test | Sonnet | Run build + test suite |
| PRD Review | Sonnet | Spec compliance check |
| Code Review | Opus | Quality + security check |
| Review Fix | Codex | Address review issues |
| Final Review | Opus | Quality gate (large tier only) |
Critical design: The reviewer never wrote the code it reviews. This eliminates author bias — the most common source of missed issues in self-review.
After quality pipelines complete, units enter the merge queue:
Unit branch
│
├─ Rebase onto main
│ └─ Conflict? → EVICT (capture conflict context)
│
├─ Run build + tests
│ └─ Fail? → EVICT (capture test output)
│
└─ Pass → Fast-forward main, push, delete branch
File Overlap Intelligence:
Eviction Recovery: When evicted, full context is captured (conflicting files, diffs, test output) and fed back to the implementer on the next Ralph pass:
## MERGE CONFLICT — RESOLVE BEFORE NEXT LANDING
Your previous implementation conflicted with another unit that landed first.
Restructure your changes to avoid the conflicting files/lines below.
{full eviction context with diffs}
research.contextFilePath ──────────────────→ plan
plan.implementationSteps ──────────────────→ implement
implement.{filesCreated, whatWasDone} ─────→ test, reviews
test.failingSummary ───────────────────────→ reviews, implement (next pass)
reviews.{feedback, issues} ────────────────→ review-fix → implement (next pass)
final-review.reasoning ────────────────────→ implement (next pass)
evictionContext ───────────────────────────→ implement (after merge conflict)
Every unit runs in an isolated worktree (uses jj/Jujutsu, not git):
/tmp/workflow-wt-{unit-id}/
Pipeline stages for the same unit share a worktree, preserving state (context files, plan files, code changes) across research → plan → implement → test → review.
| Signal | Use Ralphinho | Use Simpler Pattern |
|---|---|---|
| Multiple interdependent work units | Yes | No |
| Need parallel implementation | Yes | No |
| Merge conflicts likely | Yes | No (sequential is fine) |
| Single-file change | No | Yes (sequential pipeline) |
| Multi-day project | Yes | Maybe (continuous-claude) |
| Spec/RFC already written | Yes | Maybe |
| Quick iteration on one thing | No | Yes (NanoClaw or pipeline) |
Is the task a single focused change?
├─ Yes → Sequential Pipeline or NanoClaw
└─ No → Is there a written spec/RFC?
├─ Yes → Do you need parallel implementation?
│ ├─ Yes → Ralphinho (DAG orchestration)
│ └─ No → Continuous Claude (iterative PR loop)
└─ No → Do you need many variations of the same thing?
├─ Yes → Infinite Agentic Loop (spec-driven generation)
└─ No → Sequential Pipeline with de-sloppify
These patterns compose well:
Sequential Pipeline + De-Sloppify — The most common combination. Every implement step gets a cleanup pass.
Continuous Claude + De-Sloppify — Add --review-prompt with a de-sloppify directive to each iteration.
Any loop + Verification — Use ECC's /verify command or verification-loop skill as a gate before commits.
Ralphinho's tiered approach in simpler loops — Even in a sequential pipeline, you can route simple tasks to Haiku and complex tasks to Opus:
# Simple formatting fix
claude -p --model haiku "Fix the import ordering in src/utils.ts"
# Complex architectural change
claude -p --model opus "Refactor the auth module to use the strategy pattern"
Infinite loops without exit conditions — Always have a max-runs, max-cost, max-duration, or completion signal.
No context bridge between iterations — Each claude -p call starts fresh. Use SHARED_TASK_NOTES.md or filesystem state to bridge context.
Retrying the same failure — If an iteration fails, don't just retry. Capture the error context and feed it to the next attempt.
Negative instructions instead of cleanup passes — Don't say "don't do X." Add a separate pass that removes X.
All agents in one context window — For complex workflows, separate concerns into different agent processes. The reviewer should never be the author.
Ignoring file overlap in parallel work — If two parallel agents might edit the same file, you need a merge strategy (sequential landing, rebase, or conflict resolution).
| Project | Author | Link |
|---|---|---|
| Ralphinho | enitrat | credit: @enitrat |
| Infinite Agentic Loop | disler | credit: @disler |
| Continuous Claude | AnandChowdhary | credit: @AnandChowdhary |
| NanoClaw | ECC | /claw command in this repo |
| Verification Loop | ECC | skills/verification-loop/ in this repo |
Weekly Installs
233
Repository
GitHub Stars
70.6K
First Seen
8 days ago
Security Audits
Gen Agent Trust HubFailSocketWarnSnykFail
Installed on
codex221
kimi-cli197
gemini-cli197
cursor197
opencode197
amp197
Azure Data Explorer (Kusto) 查询技能:KQL数据分析、日志遥测与时间序列处理
93,700 周安装
| Dry-run mode (no git operations) |
--review-prompt "..." | Add reviewer pass per iteration |
--ci-retry-max N | Auto-fix CI failures (default: 1) |