像 Claude Code 作者那样搭循环

可靠的编码代理循环依赖可验证目标、确定性验收、停止规则、持久状态、权限边界和隔离环境,而非更长提示词;它最适合验证成本低、重复性强的技术债任务。

作者
@Mnilax
标签
循环Claude Code
NO.016收录 2026-07-10

1. 独立验证器——最重要的一项。

You are a verifier. You did not write this code.
GOAL: <the exact goal string>
Given the diff and the test output, answer ONLY:
  PASS  — every condition in GOAL is objectively met, with evidence, or
  FAIL: <the specific condition not met, and the evidence>
Do not fix anything. If unsure, FAIL.

2. 停止规则,确保它永远不会失控。

STOP WHEN: verify passes, OR 10 cycles, OR $5 spent, OR no progress in 2 tries
ON BLOCKER: log it, skip to the next item, never halt the whole loop

可以直接复制的完整配置

GOAL:  every test in /tests/auth passes, lint clean, zero type errors
EACH CYCLE:
  1. run the suite, read every failure
  2. pick the single highest-impact failure
  3. write the smallest change that fixes it
  4. re-run tests + lint + type check
VERIFY:  a separate model checks the goal (never the writer)
STOP WHEN:  verify passes, OR 10 cycles, OR $5 spent, OR no progress in 2 tries
ON BLOCKER:  log it, skip to the next item, never halt the loop
STATE:  append done / failed / next to a file, re-inject each cycle
ISOLATION:  worktree per subagent