File contents evolve — repo-medic 自进化
self-contained skill。把"最近踩的坑"蒸馏成 SKILL.md 可注入的规则,让未来使用不再踩同样坑。
🛑 MANDATORY WORKFLOW — check all before declaring done
Phase 0: Collect sources
Phase 1: Distill (candidate → lesson)
Phase 2: User review
Phase 3: Inject(只做加法 — 永不改 skill 包内文件)
Phase 4: Verify + Share
包含
路径
内容
scripts/extract.py
git log + work-notes 提取器(输出候选 lesson)
templates/lesson.md
lesson 文件格式模板
templates/lessons-skill.md
repo-medic-lessons companion skill 骨架(Phase 3 首次运行据此创建)
references/lesson-schema.md
提取字段定义(Symptom / Cause / Fix / Frequency)
使用
# 默认扫描最近 7 天
python scripts/extract.py --repo .
# 自定义时间窗 + 输出到文件
python scripts/extract.py --repo . --since 30d --output lessons-candidates.md
# 限 commit 数
python scripts/extract.py --repo . --max-commits 100
# JSON 给后续脚本消费
python scripts/extract.py --repo . --json | jq '.candidates[].tag' | sort | uniq -c
输出是候选列表(含来源 commit/work-note 链接 + 频率)。用户审核后,按 Phase 3 归入 repo-medic-lessons companion skill 中对应 target sub-skill 的桶。
14 硬约束(跨子工作流通用)
零新增依赖 (YAGNI) : extract.py 只用 stdlib(git log 是 subprocess,no pygit2)。
commit 颗粒度 : 1 lesson = 1 commit。
默认回滚 = git revert 。绝对禁止 git reset --hard 。
死代码证明 : 不适用(extract 是临时脚本,不入 sub-skill 长期代码)。
TDD : 不适用(一次性提取 + 人工审核)。
commit 前全绿 : 注入 lesson 后跑 sub-skill smoke test。
prod 锁定 : 不直接动 prod 项目 sub-skill 的 SKILL.md — 先在 fork 或 worktree 试。
宁缺勿伪 : extract 输出含 source 链接(commit hash + work-note 文件),用户可验证。
DB 删除 : 不适用。
批量先测最小 : extract.py --since 1d 先小范围跑 + 校准,再扩到 30d。
daemon 4 步独立 : 不适用。
buffer 所有权 : 不适用。
hash 产物整目录同步 : 不适用。
部署验证实际生效 : lesson 注入后跑 sub-skill smoke test + 用户实际使用验证 1 次。
关联
/repo-medic — meta 入口
所有其他 sub-skill — evolve 的 inject target
docs/work-note/ — 数据源(CLAUDE.md 强制格式 Symptom/Cause/Fix)
仓库
github.com/liyong-labs/repo-medic — Apache-2.0。
1 --- 2 name: evolve-2 3 description: evolve — repo-medic 自进化 4 --- 5 6 # evolve — repo-medic 自进化 7 8 self-contained skill。把"最近踩的坑"蒸馏成 SKILL.md 可注入的规则,让未来使用不再踩同样坑。 9 10 ## 🛑 MANDATORY WORKFLOW — check all before declaring done 11 12 ### Phase 0: Collect sources 13 14 - [ ] **Read** `references/lesson-schema.md` (lesson 提取格式) 15 - [ ] **设时间窗**: 默认 `--since 7d`(用户可改 1d / 30d / since-last-tag) 16 - [ ] **scan git log**: 提取 commit message + body(用 `git log --since=... --pretty=full`) 17 - [ ] **scan work-notes**: 读 `docs/work-note/*.md` 正则匹配 `**Symptom**:` / `**Cause**:` / `**Fix**:` 字段 18 - [ ] **可选**:scan KB public-knowledge 命中"教训"类内容 19 - [ ] **Run** `python scripts/extract.py --since 7d --repo .` 提取候选 20 - [ ] 🛑 **GATE**: 提取完成 + 输出候选列表给用户 21 22 ### Phase 1: Distill (candidate → lesson) 23 24 - [ ] **去重**: 相似 Symptom/Cause 合并 25 - [ ] **频率排序**: 出现 ≥ 2 次的优先(高 ROI) 26 - [ ] **分类打标**: 每条 lesson 标一个 tag(DB / deploy / config / frontend / general) 27 - [ ] **filter 范围**: 跳过与 repo-medic 无关的(用户业务逻辑、第三方 bug 等) 28 - [ ] **抽象成规则**: 把具体 case 抽成可复用的「如遇 X,做 Y」模式 29 - [ ] 🛑 **GATE**: 蒸馏后 ≤ 10 条候选给用户看(> 10 = 没收敛,重抽) 30 31 ### Phase 2: User review 32 33 - [ ] **逐条给用户**: 显示「候选 N: ...」+ 命中 source (commit/work-note) 34 - [ ] **用户确认**: 接受 / 拒绝 / 修改每条 35 - [ ] **用户指定 target sub-skill**: 每条选归入哪个 skill 的 lessons 桶(py-improve / doc-reorg / db-tweak / vue-improve / config-base) 36 - [ ] 🛑 **GATE**: 用户逐条 OK 才能进 Phase 3 37 38 ### Phase 3: Inject(只做加法 — 永不改 skill 包内文件) 39 40 - [ ] **lessons 目录**: 写到 `~/.claude/skills/repo-medic-lessons/lessons/<target-skill>/<topic>.md`(首次运行先建目录)。**绝不写进任何 skill 自己的目录** — skill 目录升级时整体替换,写进去的迟早丢失 41 - [ ] **lessons 目录纳入版本管理**: 若 `~/.claude/skills/repo-medic-lessons/` 还不是 git 仓库,先 `git init` + 初始 commit——下面「1 lesson = 1 commit」的门禁才有落点,lesson 也有历史可回滚 42 - [ ] **索引更新**: 维护 `~/.claude/skills/repo-medic-lessons/SKILL.md` — 每条 lesson 一行摘要 + 按域积累 trigger 关键词(骨架见 `templates/lessons-skill.md`) 43 - [ ] **commit**: 1 commit = 1 lesson(铁律 2) 44 - [ ] 🛑 **GATE**: diff 给用户看 + 用户 OK 才能 commit 45 46 ### Phase 4: Verify + Share 47 48 - [ ] **tests pass**: sub-skill 测试或 smoke test 49 - [ ] **KB 同步**(可选): 推到所配 KB 端点的 public-knowledge 集合(未配 KB 系统则跳过) 50 - [ ] **work-note**: 写 `docs/work-note/<date>-evolve-extract.md` 记录本轮蒸馏 51 - [ ] **零包内写入**: 不往 `evolve/` 或任何其他 skill 目录添加内容 — 持久产出只进 `repo-medic-lessons/` 52 53 --- 54 55 ## 包含 56 57 | 路径 | 内容 | 58 |---|---| 59 | `scripts/extract.py` | git log + work-notes 提取器(输出候选 lesson) | 60 | `templates/lesson.md` | lesson 文件格式模板 | 61 | `templates/lessons-skill.md` | `repo-medic-lessons` companion skill 骨架(Phase 3 首次运行据此创建) | 62 | `references/lesson-schema.md` | 提取字段定义(Symptom / Cause / Fix / Frequency) | 63 64 ## 使用 65 66 ```bash 67 # 默认扫描最近 7 天 68 python scripts/extract.py --repo . 69 70 # 自定义时间窗 + 输出到文件 71 python scripts/extract.py --repo . --since 30d --output lessons-candidates.md 72 73 # 限 commit 数 74 python scripts/extract.py --repo . --max-commits 100 75 76 # JSON 给后续脚本消费 77 python scripts/extract.py --repo . --json | jq '.candidates[].tag' | sort | uniq -c 78 ``` 79 80 输出是候选列表(含来源 commit/work-note 链接 + 频率)。用户审核后,按 Phase 3 归入 repo-medic-lessons companion skill 中对应 target sub-skill 的桶。 81 82 ## 14 硬约束(跨子工作流通用) 83 84 1. **零新增依赖 (YAGNI)**: extract.py 只用 stdlib(git log 是 subprocess,no pygit2)。 85 2. **commit 颗粒度**: 1 lesson = 1 commit。 86 3. **默认回滚 = git revert**。**绝对禁止 `git reset --hard`**。 87 4. **死代码证明**: 不适用(extract 是临时脚本,不入 sub-skill 长期代码)。 88 5. **TDD**: 不适用(一次性提取 + 人工审核)。 89 6. **commit 前全绿**: 注入 lesson 后跑 sub-skill smoke test。 90 7. **prod 锁定**: 不直接动 prod 项目 sub-skill 的 SKILL.md — 先在 fork 或 worktree 试。 91 8. **宁缺勿伪**: extract 输出含 source 链接(commit hash + work-note 文件),用户可验证。 92 9. **DB 删除**: 不适用。 93 10. **批量先测最小**: `extract.py --since 1d` 先小范围跑 + 校准,再扩到 30d。 94 11. **daemon 4 步独立**: 不适用。 95 12. **buffer 所有权**: 不适用。 96 13. **hash 产物整目录同步**: 不适用。 97 14. **部署验证实际生效**: lesson 注入后跑 sub-skill smoke test + 用户实际使用验证 1 次。 98 99 ## 关联 100 101 - `/repo-medic` — meta 入口 102 - 所有其他 sub-skill — evolve 的 inject target 103 - `docs/work-note/` — 数据源(CLAUDE.md 强制格式 Symptom/Cause/Fix) 104 105 ## 仓库 106 107 github.com/liyong-labs/repo-medic — Apache-2.0。
liyong-labs/repo-medic/tree/main/docs/zh/evolve commit bc6d8baab8
Frequently asked questions How do I install the Evolve skill? Run npx skillmds@latest add liyong-labs/evolve-2 in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Evolve skill do? evolve — repo-medic 自进化 It is listed under Coding & Dev Tools on SkillMD.
Is Evolve safe to use? This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Evolve? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Evolve free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Evolve? liyong-labs (@liyong-labs) published this skill. Their other Agent Skills are listed on their SkillMD profile.