Systematically improve code through disciplined analysis, targeted mutations, verification, scoring, and logging to iteratively enhance quality and design.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install iterative-code-evolution或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install iterative-code-evolution⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/iterative-code-evolution/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: iterative-code-evolution description: Systematically improve code through structured analysis-mutation-evaluation loops. Adapted from ALMA (Automated meta-Learning of Memory designs for Agentic systems). Use when iterating on code quality, optimizing implementations, debugging persistent issues, or evolving a design through multiple improvement cycles. Replaces ad-hoc "try and fix" with disciplined reflection, variant tracking, and principled selection of what to change next. ---
A structured methodology for improving code through disciplined reflect → mutate → verify → score cycles, adapted from the ALMA research framework for meta-learning code designs.
Every improvement cycle follows this sequence:
┌─────────────────────────────────────────────────────┐
│ 1. ANALYZE — structured diagnosis of current code │
│ 2. PLAN — prioritized, concrete changes │
│ 3. MUTATE — implement the changes │
│ 4. VERIFY — run it, check for errors │
│ 5. SCORE — measure improvement vs. baseline │
│ 6. ARCHIVE — log what was tried and what happened │
│ │
│ Loop back to 1 with new knowledge │
└─────────────────────────────────────────────────────┘
Track all iterations in .evolution/log.json at the project root. This is the memory that makes each cycle smarter than the last.
{
"baseline": {
"description": "Initial implementation before evolution began",
"score": 0.0,
"timestamp": "2025-01-15T10:00:00Z"
},
"variants": {
"v001": {
"parent": "baseline",
"description": "Added input validation and error handling",
"changes_made": [
{
"what": "Added type checks on all public methods",
"why": "Runtime crashes from malformed input in 3/10 test cases",
"priority": "High"
}
],
"score": 0.6,
"delta": "+0.6 vs parent",
"timestamp": "2025-01-15T10:30:00Z",
"learned": "Input validation was the primary failure mode — most other logic was sound"
},
"v002": {
"parent": "v001",
"description": "Refactored parsing logic to handle edge cases",
"changes_made": [
{
"what": "Rewrote parse_input() to use state machine instead of regex",
"why": "Regex approach failed on nested structures (seen in test cases 7,8)",
"priority": "High"
}
],
"score": 0.85,
"delta": "+0.25 vs parent",
"timestamp": "2025-01-15T11:00:00Z",
"learned": "State machine approach generalizes better than regex for this grammar"
}
},
"principles_learned": [
"Input validation fixes give the biggest early gains",
"Regex-based parsing breaks on recursive structures — prefer state machines",
"Small targeted changes score better than large rewrites"
]
}
Before changing anything, perform a structured analysis of the current code and its outputs. This is the most important phase — it prevents wasted mutations.
Step 1 — Learn from past edits (skip on first iteration)
Review the evolution log. For each previous change:
Step 2 — Component-level assessment
For each meaningful component (function, class, module, pipeline stage), label it:
| Label | Meaning | |-------|---------| | Working | Produces correct output, no issues observed | | Fragile | Works on happy path but fails on edge cases or specific inputs | | Broken | Produces wrong output or errors | | Redundant | Duplicates logic found elsewhere, adds complexity without value | | Missing | A needed component that doesn't exist yet |
For each label, write a one-line explanation of why — linked to specific test outputs or observed behavior.
Step 3 — Quality and coherence check
Look for cross-cutting issues:
Step 4 — Produce prioritized suggestions
Based on Steps 1-3, produce concrete changes. Each suggestion must have:
- PRIORITY: High | Medium | Low
- WHAT: Precise description of the change (code-level, not vague)
- WHY: Link to a specific observation from Steps 1-3
- RISK: What could go wrong if this change is made incorrectly
Rule: Every suggestion must link to an observation. No "this might help" suggestions — only changes grounded in something you actually saw in the code or outputs.
Rule: Limit to 3 suggestions per cycle. More than 3 changes at once makes it impossible to attribute improvement or regression to specific changes.
Pick 1-3 suggestions from the analysis. Selection principles:
Write the new code. Key discipline:
# evo-v003: switched to state machine per edge case failures)Execute the modified code against the same inputs/tests used for scoring.
If it crashes (up to 3 retries):
Use the reflection-fix protocol:
After 3 failed retries, revert to parent variant and log the failure:
{
"attempted": "Description of what was tried",
"failure_mode": "The error that couldn't be resolved",
"learned": "Why this approach doesn't work"
}
This failure data is valuable — it prevents re-attempting the same broken approach.
If it runs but produces wrong output:
Don't immediately retry. Go back to Phase 1 (ANALYZE) with the new outputs. The wrong output is diagnostic data.
...
安装 Iterative Code Evolution 后,可以对 AI 说这些话来触发它
Help me get started with Iterative Code Evolution
Explains what Iterative Code Evolution does, walks through the setup, and runs a quick demo based on your current project
Use Iterative Code Evolution to systematically improve code through disciplined analysis, targeted ...
Invokes Iterative Code Evolution with the right parameters and returns the result directly in the conversation
What can I do with Iterative Code Evolution in my developer & devops workflow?
Lists the top use cases for Iterative Code Evolution, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/iterative-code-evolution/ 目录(个人级,所有项目可用),或 .claude/skills/iterative-code-evolution/(项目级)。重启 AI 客户端后,用 /iterative-code-evolution 主动调用,或让 AI 根据上下文自动发现并使用。
Iterative Code Evolution 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Iterative Code Evolution 可免费安装使用。请查阅仓库了解许可证信息。
Systematically improve code through disciplined analysis, targeted mutations, verification, scoring, and logging to iteratively enhance quality and design.
Iterative Code Evolution 属于「Developer & DevOps」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my developer & devops tasks using Iterative Code Evolution
Identifies repetitive steps in your workflow and sets up Iterative Code Evolution to handle them automatically