Install
openclaw skills install @jingzhao-l/iterate-skillMulti-round automated code iteration: configurable N-dimension parallel review → atomic fixes directly → architectural fixes via user approval → validate → merge → push, looping until zero findings.
openclaw skills install @jingzhao-l/iterate-skill<goal> [rounds] [no-limit]中文:全自动多轮代码迭代。每轮从 N 个已启用维度并行审查整个项目(默认 9 个),原子问题直接修复,架构问题经用户批准后由子代理串行执行,验证通过后合并回主分支并推送,循环直到零 findings 或达到轮数上限。
English: Fully automated multi-round code iteration. Each round launches N parallel dimension reviewers across the project (default 9), fixes atomic issues directly, executes architectural issues after user approval via serial sub-agents, validates, merges into the target branch, pushes, and loops until zero findings or max rounds.
本 Skill 适用于以下场景:
This Skill is appropriate when:
本 Skill 不适用于以下场景:
validation.commands 未配置)。Do not use this Skill when:
validation.commands.调用格式 / Invocation: /iterate <goal> [rounds] [no-limit]
参数通过 Agent Skills 标准占位符注入:
| 占位符 / Placeholder | 含义 / Meaning | 默认值 / Default |
|---|---|---|
$goal / $0 | 迭代目标 / Iteration goal | required |
$rounds / $1 | 最大轮数 / Max rounds | 7 |
$limit_mode / $2 | 若设为 no-limit,则最大轮数为 50(硬上限)/ Set to no-limit for hard cap 50 | — |
$ARGUMENTS | 用户输入的全部参数原样字符串 / Raw argument string | — |
示例 / Examples:
/iterate improve error handling/iterate improve error handling 10/iterate improve error handling no-limit满足以下全部条件:
原子问题不进入用户审批流程,由主模型直接修复。
An issue is atomic when all of the following are true:
Atomic issues are fixed directly by the main model without user approval.
满足以下任一条件:
架构问题必须经用户批准后才能执行,由子代理串行完成。
An issue is architectural when any of the following is true:
Architectural issues require user approval and are executed by sub-agents serially.
关键原则 / Key Principle:原子问题和架构问题同样重要,都必须修复。区别仅在于是否需要用户批准以及由谁执行。
Setup
└─ Extract goal → load config → read project context → create isolated branch/worktree
Loop (round = 1 .. max_rounds)
├─ Phase 1: N-dimension parallel review (N = enabled dimensions count, default 9)
├─ Phase 2: Atomic fixes (direct)
├─ Phase 3: Architectural fixes (approval → serial sub-agents)
├─ Phase 4: Record round results
└─ Phase 5: Validate → merge → push
Summary
提取目标 / Extract goal
$0 / $goal 读取迭代目标;若缺失则反问用户。$0 / $goal; ask if missing.确定轮数 / Determine max rounds
maxRounds = $1 / $rounds,默认 7。$2 / $limit_mode 为 no-limit,则 maxRounds = 50(硬上限)。7 并提示用户。确定项目根目录 / Locate project root
.git、iterate.config.yaml 或 CLAUDE.md 的目录。读取配置 / Load configuration
config/iterate.config.yaml(Master),再读取项目根目录的 iterate.config.yaml(Overrides)递归覆盖同名字段。读取项目上下文 / Read project context
CLAUDE.md → PROJECT.md → README.md。projectContext 字符串供后续使用。.env、.env.*、*.{key,pem,p12,crt,cer}、credentials.json、.aws/、.ssh/ 等敏感文件。创建隔离环境 / Create isolated environment
git status,工作区必须干净(无未跟踪文件、无未提交修改、无未解决冲突);若不干净,询问用户是否 commit/stash。iterate/<goal-slug>-<timestamp>。git worktree add ../<name> -b iterate/<goal-slug>-<timestamp>。初始化决策日志 / Initialize decision log
.iterate_decisions.md,写入文件头。deferredArchitectural = [] for cross-round carry-over.round = 1
while round <= maxRounds:
启动 N 个并行审查子代理(N = 启用的 dimensions 数量,默认 9),每个审查一个维度。
Launch N parallel reviewer sub-agents (N = enabled dimensions count, default 9), one per dimension.
以下维度可通过 dimensions 列表启用或禁用(默认 9 个)。每个维度的中文名、英文名、优先级和 focus prompt 定义在 config/dimensions/<key>.yaml 中;config/dimensions.yaml 保留为聚合兼容文件。
| 维度 / Dimension | 优先级 / Priority | 关注点 / Focus |
|---|---|---|
| correctness | critical | 崩溃风险、逻辑错误、竞态条件、类型不匹配、静默吞错 |
| security | critical | 注入、路径遍历、硬编码密钥、输入校验、权限提升 |
| performance | high | N+1 查询、主线程阻塞、循环引用、O(n²)、启动瓶颈 |
| architecture | high | 模块边界违规、循环依赖、God Object、缺失抽象 |
| style-tests | medium | 函数 >80 行、圈复杂度 >15、嵌套 >3、魔法数字、缺失测试 |
| tech-debt | medium | TODO/FIXME/HACK、废弃 API、临时方案、硬编码配置 |
| spec-compliance | high | 对照 specs/ 目录,发现未实现功能、规范偏离 |
| frontend-backend | high | API/RPC 一致性、数据字段、错误传播、事件流覆盖 |
| ui-ux | medium | 加载/空/错误状态、导航、响应式断点、无障碍 |
每个子代理的任务提示:
Review the codebase for {DIMENSION} issues ONLY.
Scope: {review.scope}
- "full" → review the ENTIRE codebase.
- "changed-only" → review ONLY files changed in the current round (git diff against {git.target_branch}).
Focus: {focus description}
Project context: {projectContext}
For each finding, report:
- file, line (if applicable), severity (critical/high/medium/low)
- dimension, summary, failure_scenario, suggested_fix
- is_atomic (boolean): true if fix is ≤{atomic.max_lines} lines within a SINGLE function/file;
false if cross-file, new files, API changes, or large refactoring.
Return strictly as JSON: { "findings": [...] }
Each finding object must contain: file, severity, dimension, summary, failure_scenario, suggested_fix, is_atomic.
If no issues are found, return { "findings": [] }.
| 工具 / Tool | Trae | Claude Code | Cursor / Generic |
|---|---|---|---|
| 并行审查子代理 | Task × N (type: search or general_purpose_task) | Workflow / Agent × N | 手动或脚本并行运行 |
| 按目录拆分审查 | Task per directory/module | Agent per directory/module | 脚本分组 |
| 结果汇总 | Task (type: general_purpose_task) | Agent synthesize | 人工汇总 |
| reviewer 输出 schema 校验 | 主模型 JSON parse + field check | 主模型 JSON parse + field check | 脚本校验 |
| 用户审批 | AskUserQuestion | EnterPlanMode / ExitPlanMode | 对话确认 |
| 文件编辑 | Read / Edit / Write | Read / Edit / Write | IDE 编辑 |
| 执行命令 | RunCommand | Bash | Terminal |
| 配置校验 | python scripts/validate.py config ... | python scripts/validate.py config ... | 同左 |
使用 scripts/install.py install --ai <name> --target <project> 即可安装到对应目录:
| AI 助手 / Assistant | 安装路径 / Install Path |
|---|---|
| Trae | .trae/skills/iterate/ |
| Claude Code | .claude/skills/iterate/ |
| Cursor | .cursor/skills/iterate/ |
| Windsurf | .windsurf/skills/iterate/ |
| GitHub Copilot | .github/skills/iterate/ |
| OpenAI Codex | .codex/skills/iterate/ |
| Roo Code | .roo/skills/iterate/ |
| Qoder | .qoder/skills/iterate/ |
| Gemini CLI | .gemini/skills/iterate/ |
| OpenCode | .opencode/skills/iterate/ |
| Continue | .continue/skills/iterate/ |
| Augment | .augment/skills/iterate/ |
| Warp | .warp/skills/iterate/ |
安装脚本会自动复制 SKILL.md、配置、维度定义、校验脚本和模板到对应目录;--ai all 一次性安装到所有支持的助手目录。
常用 CLI 选项:
--force:覆盖已存在的 skill 文件。--global:安装到用户主目录(如 ~/.trae/skills/iterate/),供所有项目复用。uninstall --yes:卸载已安装的 skill;不加 --yes 时会要求二次确认。update:检测已安装的助手并从 GitHub 最新 release 下载源码刷新文件;下载失败时回退到本地源码。当项目较大时,可将一个维度拆分为多个子任务,每个任务只审查一个模块或目录:
Split dimension {DIMENSION} review by top-level directories.
For each directory, launch a reviewer with scope "changed-only" or "full".
Merge findings, removing duplicates across directory boundaries.
使用一个汇总子代理:
Synthesize findings from all reviewers.
Goal: {goal} / Round: {round}
Steps:
1. PARSE each reviewer output as JSON; if invalid and reviewer.output_schema_validation is true, retry that reviewer up to 2 times.
2. REMOVE duplicates (same defect, same file → keep most detailed)
3. REMOVE false positives (clearly wrong or unactionable)
4. RE-VALIDATE is_atomic flag for each finding
5. CLASSIFY into atomic and architectural
6. SORT each group by severity (critical → high → medium → low)
7. TRIM each group to 20 max
Return: { "empty": boolean, "atomic": [...], "architectural": [...] }
停止条件检查:
if empty AND deferredArchitectural is empty:
写入 .iterate_decisions.md: "Round {round}: 0 findings, iteration complete."
输出: "✅ Round {round}: 0 findings, iteration complete."
break
注意 / Note:如果所有 reviewer 都返回空但代码中明显存在问题,主模型应基于自身判断补充 findings。
若存在原子问题:
计划(内部,不中断) / Plan internally
顺序执行 / Execute sequentially
for each atomic finding:
Read target file
Apply fix using Edit/Write (ensure ≤ atomic.max_lines, single function scope)
Record completion status
验证原子修复 / Validate atomic fixes
根据改动的模块跑对应检查(从 validation.commands 读取,键名为示例):
python/:ruff check src/ && mypy src/ --ignore-missing-imports && pytest tests/ -x -q --timeout=60swift/:swift build -c debugtypescript/:npm run compile执行前检查命令前缀是否在 validation.command_whitelist 中;不在白名单中的命令必须二次确认。
若验证失败:
.iterate_decisions.md:Atomic fix validation failed: {details}❌ Round {round}: atomic fix validation failed, stopping iterationbreak若存在架构问题(含 deferredArchitectural):
文件碰撞检测 / File conflict detection
deferredArchitectural(下一轮处理)。executableArchitectural。分组与排序 / Group and sort
executableArchitectural 内部 task 之间的文件重叠;如有重叠,按依赖顺序拆分为串行 task 或合并为单一 task。用户审批 / User approval
呈现给用户:
可执行的架构修复 / Executable architectural tasks:
- {files} | {description} | {severity} | {approach}
延迟的架构修复 / Deferred tasks:
- {files} | {description} | {reason}
Approve these {N} architectural fixes?
deferredArchitectural,跳到 Phase 4。串行委派子代理 / Execute serially via sub-agents
for each task in executableArchitectural:
Use sub-agent with prompt:
"You are fixing an architectural issue.
Goal: {goal} / Round: {round}
Project context: {projectContext}
Task: {task description with file paths, findings, approach}
Workflow:
1. Read all affected files, their callers, and callees.
2. Apply the fix using Edit/Write tools.
3. Report: success/failure, files_changed, summary, notes.
Previous tasks in this round may have changed some files.
Read files fresh before editing — they may have been modified.
Do NOT run build/test commands."
Wait for completion before starting the next task.
If a sub-agent fails, log the reason, report it to the user, and ask whether to continue, skip, or abort the round.
整体验证 / Full validation
根据改动模块跑完整验证(同 Phase 2,但覆盖所有改动模块)。
执行前同样检查 validation.command_whitelist。
若失败:
.iterate_decisions.md:Full validation failed: {details}❌ Round {round}: full validation failed, stopping iterationbreak追加到 .iterate_decisions.md:
输出:✅ Round {round} complete
每轮验证通过后:
Backup tag / 备份标签
git tag iterate/round-{round}-backupgit reset --hard iterate/round-{round}-backup(仅用于迭代分支,不用于 main/master)。Commit / 提交
git add <changed files>git commit -m "fix: iterate round {round} — {brief summary}"Merge / 合并
git checkout {target_branch}git merge iterate/<goal-slug>-<timestamp>Push / 推送
git.push_per_round 为 true:
git push origin {target_branch}git pull --rebase,解决冲突,重新验证,再 push。git.push_per_round 为 false:
git push origin {target_branch}。切回迭代分支 / Switch back
git checkout iterate/<goal-slug>-<timestamp>记录 / Log
.iterate_decisions.md 中记录 backup tag、commit hash、merge 结果、冲突处理。round += 1
迭代结束后输出:
.iterate_decisions.md 路径 / Decision log path规则 / Rule:每次 /iterate 会话必须在隔离的本地分支或 worktree 中运行;每轮修复验证通过后,必须合并回本地主分支、解决冲突并推送到远程。绝不直接在 main/master 上提交。
Why:
# 1. Setup
git status # 必须干净
git checkout -b iterate/<goal>-<date> # 或 git worktree add ../<name> -b iterate/<goal>-<date>
# 2. Each round (after validation passes)
git add <changed files> && git commit -m "fix: iterate round {N} — ..."
git checkout <target-branch>
git merge iterate/<goal>-<date> # 解决冲突,重新验证
git push origin <target-branch>
git checkout iterate/<goal>-<date> # 继续下一轮
# 3. Session end
# 确保所有改动已合并推送
# 可询问用户是否删除已合并的迭代分支
git pull --rebase,解决冲突,重新验证,再 push。文件路径:.iterate_decisions.md
# Iterate Decision Log
Goal: {goal}
Max rounds: {maxRounds}
Started: {timestamp}
Branch: {iteration-branch}
---
## Round {N} — {timestamp}
### Atomic Fixes (Direct)
| # | File | Summary | Severity | Status |
|---|------|---------|----------|--------|
| 1 | x.swift | Fix null pointer | high | ✅ |
### Architectural Fixes (Approved + Executed)
| # | File(s) | Summary | Severity | Status |
|---|---------|---------|----------|--------|
| 1 | y.swift, z.swift | Unified error handling | critical | ✅ Executed |
### Architectural Fixes (Deferred to Next Round)
| # | File(s) | Summary | Defer Reason |
|---|---------|---------|-------------|
| 1 | a.swift, b.swift | Refactor data flow | File conflict with atomic fix |
### Reverted Fixes
| # | File(s) | Summary | Revert Reason |
|---|---------|---------|---------------|
| 1 | shared/error_codes.json | Merge v1 codes | Conflict with authoritative v2.0 numbering |
### AI Important Decisions
| # | Decision | Reason |
|---|---------|--------|
| 1 | Merged 5 findings into 1 task | Same module |
### Validation
- ruff check src/ → 0 errors
- mypy src/ → Success
- pytest tests/ → 2600 passed, 0 failed
一个完整的 iterate skill 目录应包含以下文件(相对 SKILL.md 的路径固定):
iterate/
├── SKILL.md # 本文件,技能入口
├── config/
│ ├── iterate.config.yaml # 默认配置
│ ├── config.schema.json # iterate.config.yaml 的 JSON Schema
│ ├── dimensions.yaml # 聚合版维度定义(兼容旧版)
│ └── dimensions/ # 数据驱动的维度定义
│ ├── correctness.yaml
│ ├── security.yaml
│ ├── performance.yaml
│ ├── architecture.yaml
│ ├── style-tests.yaml
│ ├── tech-debt.yaml
│ ├── spec-compliance.yaml
│ ├── frontend-backend.yaml
│ └── ui-ux.yaml
├── scripts/
│ ├── install.py # CLI:安装、卸载、配置、校验
│ ├── validate.py # 配置、决策日志、维度校验脚本
│ └── requirements.txt # 校验脚本依赖
├── templates/
│ └── iterate-decisions.template.md # 决策日志模板
├── tools/
│ ├── SKILL.trae.md # Trae 专属 prompt/workflow 示例
│ ├── SKILL.claude.md # Claude Code 专属 workflow 示例
│ └── SKILL.cursor.md # Cursor 专属 prompt 示例
├── tests/
│ └── test_validate.py # pytest 测试
└── README.md / CONTRIBUTING.md # 用户与贡献者文档
运行时优先读取项目根目录的 iterate.config.yaml;若不存在,则使用 skill 目录下的 config/iterate.config.yaml 作为默认配置。校验脚本路径以 ${CLAUDE_SKILL_DIR}/scripts/validate.py(Claude Code)或 skill 安装目录相对路径解析。
默认配置见 config/iterate.config.yaml。
| 配置项 / Key | 类型 / Type | 默认值 / Default | 说明 / Description |
|---|---|---|---|
goal | string | "Improve code quality" | 迭代目标 |
max_rounds | int | 7 | 最大轮数 |
language | string | "en" | 输出语言 zh / en |
dimensions | list | 全部 9 维度 | 启用的审查维度 |
review.scope | string | "full" | 审查范围:changed-only / full |
atomic.max_lines | int | 20 | 原子问题行数上限 |
atomic.max_adjacent_methods | int | 3 | 相邻方法数上限 |
git.target_branch | string | "main" | 合并目标分支 |
git.use_worktree | bool | false | 是否使用 worktree |
git.push_per_round | bool | true | 每轮通过后是否立即 push |
validation.command_whitelist | list | 常见命令前缀 | 无需二次确认的允许命令前缀 |
validation.commands.<module> | list | 示例命令 | 各模块验证命令 |
reviewer.output_schema_validation | bool | true | 是否校验 reviewer JSON 输出并自动重试 |
本 SKILL.md 同时遵循 Agent Skills 开放标准,以下字段已被使用或推荐:
| 字段 / Field | 当前取值 / Current Value | 说明 / Description |
|---|---|---|
name | iterate | 展示名 / Display name |
description | 英文简介 | 触发依据 / Trigger hint for Claude |
argument-hint | <goal> [rounds] [no-limit] | 命令行自动补全提示 / Autocomplete hint |
arguments | [goal, rounds, limit_mode] | 命名参数,用于 $goal / $rounds / $limit_mode 注入 |
disable-model-invocation | true | 必须由用户显式调用(因会修改代码并 push) |
allowed-tools | Read, Edit, Write, RunCommand, AskUserQuestion, Task, Glob, Grep | 调用 skill 时自动预授权的工具 |
context | — | 如需在子代理隔离环境中运行,可设为 fork |
paths | — | 如只想在特定文件模式匹配时自动加载,可设置 glob 列表 |
Reviewer 不读取敏感文件 / No sensitive file access
.env、.env.*、*.key、secrets/、*.pem、*.p12、*.crt、*.cer、
credentials.json、.aws/、.ssh/。projectContext 中不得包含 API 密钥、密码、Token、数据库连接字符串、私钥内容。命令白名单 / Command whitelist
ruff, mypy, pytest, swift, npm run, yarn, pnpm, go test, cargo, python, python3 等已知前缀。validation.commands 必须经用户二次确认后方可执行。python scripts/validate.py config <path> 提前检查命令合规性。修改范围审计 / Modification scope audit
.iterate_decisions.md 必须记录:本轮修改的文件、对应 task/reviewer、用户审批状态。No force-push / No direct main commits
main/master。main/master 上提交。在启动 reviewer 前确认:
projectContext,但不含密钥。review.scope(changed-only 或 full)。atomic.max_lines 和 atomic.max_adjacent_methods。CLAUDE.md 或 iterate.config.yaml 读取,不硬编码。iterate/* 分支或 worktree;每轮验证后合并并推送。.iterate_decisions.md 记录所有修复、延迟、回滚和重要决策。iterate.config.yaml 中的 validation.commands 由 AI 助手读取后执行;执行前检查 validation.command_whitelist,不在白名单的命令需用户确认。