ai-factory.evolve
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseEvolve - Skill Self-Improvement
Evolve - 技能自我提升
Analyze project context, patches, and codebase to improve existing skills. Makes AI Factory smarter with every run.
分析项目上下文、补丁和代码库,以改进现有技能。每次运行都能让AI Factory变得更智能。
Core Idea
核心思路
patches (past mistakes) + project context + codebase patterns
↓
analyze recurring problems, tech-specific pitfalls, project conventions
↓
enhance skills with project-specific rules, guards, and patternspatches (past mistakes) + project context + codebase patterns
↓
analyze recurring problems, tech-specific pitfalls, project conventions
↓
enhance skills with project-specific rules, guards, and patternsWorkflow
工作流程
Step 0: Load Context
步骤0:加载上下文
Read to understand:
.ai-factory/DESCRIPTION.md- Tech stack
- Architecture
- Conventions
读取 以了解:
.ai-factory/DESCRIPTION.md- 技术栈
- 架构
- 约定规范
Step 1: Collect Intelligence
步骤1:收集情报
1.1: Read all patches
Glob: .ai-factory/patches/*.mdRead every patch. For each one, extract:
- Problem category (null-check, async, validation, types, API, DB, etc.)
- Root cause pattern (what class of mistake was made)
- Prevention rule (what should be done differently)
- Tags
1.2: Aggregate patterns
Group patches by tags and categories. Identify:
- Recurring problems — same tag appears 3+ times? This is a systemic issue
- Tech-specific pitfalls — problems tied to the stack (e.g., React re-renders, Laravel N+1)
- Missing guards — what checks/patterns could have prevented these bugs
1.3: Read codebase conventions
Scan the project for patterns:
- Linter configs (,
.eslintrc,phpstan.neon, etc.)ruff.toml - Existing test patterns (test file structure, assertions used)
- Error handling patterns (try/catch style, error types)
- Logging patterns (logger used, format, levels)
- Import conventions, file structure
1.1:读取所有补丁
Glob: .ai-factory/patches/*.md读取每个补丁,并为每个补丁提取:
- 问题类别(空值检查、异步处理、验证、类型、API、数据库等)
- 根本原因模式(属于哪类错误)
- 预防规则(应该如何改进)
- 标签
1.2:聚合模式
按标签和类别对补丁进行分组,识别:
- 重复出现的问题 — 同一标签出现3次以上?这是系统性问题
- 技术栈特定陷阱 — 与技术栈相关的问题(例如React重渲染、Laravel N+1查询)
- 缺失的防护机制 — 哪些检查/模式本可以预防这些bug
1.3:读取代码库约定
扫描项目以识别模式:
- 代码检查器配置(、
.eslintrc、phpstan.neon等)ruff.toml - 现有测试模式(测试文件结构、使用的断言方式)
- 错误处理模式(try/catch风格、错误类型)
- 日志记录模式(使用的日志工具、格式、级别)
- 导入规范、文件结构
Step 2: Read Current Skills
步骤2:读取当前技能
Determine which skills to evolve:
- If contains a specific skill name → evolve only that skill
$ARGUMENTS - If is "all" or empty → evolve all installed skills
$ARGUMENTS
Read each target skill's SKILL.md:
Glob: {{skills_dir}}/*/SKILL.mdIf skills are not installed yet (no ), read from source:
{{skills_dir}}/Glob: skills/*/SKILL.md确定要进化的技能:
- 如果 包含特定技能名称 → 仅进化该技能
$ARGUMENTS - 如果 为 "all" 或为空 → 进化所有已安装的技能
$ARGUMENTS
读取每个目标技能的SKILL.md:
Glob: {{skills_dir}}/*/SKILL.md如果技能尚未安装(无 ),则从源目录读取:
{{skills_dir}}/Glob: skills/*/SKILL.mdStep 3: Analyze Gaps
步骤3:分析差距
For each skill, identify what's missing based on collected intelligence:
3.1: Patch-driven gaps
Compare patch patterns against skill instructions:
- Does mention the most common error categories from patches? If not → add them
/ai-factory.fix - Does warn about the pitfalls found in patches? If not → add guards
/ai-factory.implement - Does include logging/validation requirements for problem areas? If not → enhance
/ai-factory.task - Does check for the patterns that caused bugs? If not → add checklist items
/ai-factory.review
3.2: Tech-stack gaps
Compare project tech stack against skill instructions:
- Skills reference generic patterns but project uses specific framework? → Add framework-specific guidance
- Project uses TypeScript but skills show JS examples? → Update examples
- Project uses specific ORM (Prisma, Eloquent)? → Add ORM-specific patterns
3.3: Convention gaps
Compare project conventions against skill instructions:
- Project has specific error handling pattern? → Skills should enforce it
- Project uses specific logger? → Skills should reference it
- Project has specific file structure? → Skills should follow it
针对每个技能,基于收集到的情报识别缺失内容:
3.1:补丁驱动的差距
对比补丁模式与技能说明:
- 是否提及补丁中最常见的错误类别?如果没有 → 添加相关内容
/ai-factory.fix - 是否针对补丁中发现的陷阱发出警告?如果没有 → 添加防护规则
/ai-factory.implement - 是否包含针对问题领域的日志/验证要求?如果没有 → 增强相关内容
/ai-factory.task - 是否检查导致bug的模式?如果没有 → 添加检查清单项
/ai-factory.review
3.2:技术栈差距
对比项目技术栈与技能说明:
- 技能引用通用模式,但项目使用特定框架?→ 添加框架特定指导
- 项目使用TypeScript,但技能展示JS示例?→ 更新示例
- 项目使用特定ORM(Prisma、Eloquent)?→ 添加ORM特定模式
3.3:约定规范差距
对比项目约定与技能说明:
- 项目有特定的错误处理模式?→ 技能应强制执行该模式
- 项目使用特定日志工具?→ 技能应引用该工具
- 项目有特定文件结构?→ 技能应遵循该结构
Step 4: Generate Improvements
步骤4:生成改进方案
For each gap found, create a concrete improvement:
markdown
undefined针对每个发现的差距,创建具体的改进内容:
markdown
undefinedImprovement: [skill-name]
改进:[技能名称]
What
改进内容
[Specific change to make]
[具体要做的修改]
Why
原因
[Which patches/patterns drove this change]
[驱动此修改的补丁/模式]
Where
修改位置
[Exact section in SKILL.md to modify]
[SKILL.md中要修改的具体章节]
Change
修改内容
[The actual text to add/modify]
**Quality rules for improvements:**
- Each improvement must be traceable to a patch, convention, or tech-stack fact
- No generic advice — only project-specific enhancements
- Improvements must be minimal and focused — don't rewrite entire skills
- Preserve existing skill structure — add, don't replace[要添加/修改的实际文本]
**改进内容的质量规则:**
- 每项改进必须可追溯到补丁、约定规范或技术栈事实
- 不提供通用建议 — 仅针对项目的特定增强
- 改进必须最小化且聚焦 — 不要重写整个技能
- 保留现有技能结构 — 仅添加内容,不替换Step 5: Present & Apply
步骤5:展示与应用
5.1: Present improvements to user
undefined5.1:向用户展示改进方案
undefinedSkill Evolution Report
技能进化报告
Based on:
- X patches analyzed
- Y recurring patterns found
- Z tech-stack specific insights
基于:
- 分析了X个补丁
- 发现Y个重复模式
- Z个技术栈特定洞察
Proposed Improvements
拟议改进
/ai-factory.fix
/ai-factory.fix
-
Add null-check guard — 5 patches involved null references → Add to Step 2: "Check for optional/nullable fields before accessing nested properties"
-
Add async/await pattern — 3 patches involved unhandled promises → Add to Important Rules: "Always use try/catch with async/await"
-
添加空值检查防护 — 5个补丁涉及空引用 → 添加到步骤2:"在访问嵌套属性前检查可选/可空字段"
-
添加async/await模式 — 3个补丁涉及未处理的Promise → 添加到重要规则:"始终将async/await与try/catch配合使用"
/ai-factory.implement
/ai-factory.implement
- Add Prisma-specific warning — 2 patches from incorrect Prisma queries → Add to Logging: "Log all Prisma queries in DEBUG mode"
- 添加Prisma特定警告 — 2个补丁来自不正确的Prisma查询 → 添加到日志记录:"在DEBUG模式下记录所有Prisma查询"
/ai-factory.review
/ai-factory.review
- Add checklist item — optional chaining not checked → Add to Correctness: "Optional chaining for nullable relations"
Apply these improvements?
- Yes, apply all
- Let me pick which ones
- No, just save the report
**5.2: Apply approved improvements**
For each approved improvement:
1. Read the target SKILL.md
2. Apply the change using `Edit`
3. Keep changes minimal and surgical
**5.3: Save evolution log**
Create `.ai-factory/evolutions/YYYY-MM-DD-HH.mm.md`:
```bash
mkdir -p .ai-factory/evolutionsmarkdown
undefined- 添加检查清单项 — 未检查可选链 → 添加到正确性检查:"可空关联的可选链使用"
是否应用这些改进?
- 是,全部应用
- 让我选择要应用的项
- 否,仅保存报告
**5.2:应用已批准的改进**
针对每个已批准的改进:
1. 读取目标SKILL.md
2. 使用`Edit`应用修改
3. 保持修改最小化且精准
**5.3:保存进化日志**
创建 `.ai-factory/evolutions/YYYY-MM-DD-HH.mm.md`:
```bash
mkdir -p .ai-factory/evolutionsmarkdown
undefinedEvolution: YYYY-MM-DD HH:mm
进化记录:YYYY-MM-DD HH:mm
Intelligence Summary
情报摘要
- Patches analyzed: X
- Recurring patterns: [list]
- Tech stack: [from DESCRIPTION.md]
- 分析的补丁数量:X
- 重复模式:[列表]
- 技术栈:[来自DESCRIPTION.md]
Improvements Applied
已应用的改进
[skill-name]
[技能名称]
- [change description] ← driven by patches: [patch filenames]
- [修改描述] ← 驱动来源:[补丁文件名]
[skill-name]
[技能名称]
- [change description] ← driven by: [tech stack / convention]
- [修改描述] ← 驱动来源:[技术栈 / 约定规范]
Patterns Identified
识别的模式
- [pattern]: [frequency] occurrences
- [pattern]: [frequency] occurrences
undefined- [模式]:出现[频次]次
- [模式]:出现[频次]次
undefinedStep 6: Suggest Next Actions
步骤6:建议后续操作
undefinedundefinedEvolution Complete
进化完成
Skills improved: X
Improvements applied: Y
已改进技能数量:X
已应用改进数量:Y
Recommendations
建议
- Run on recent code to verify improvements
/ai-factory.review - Next evolution — run again after 5-10 more fixes
/ai-factory.evolve - Consider new skill — if pattern X keeps recurring, create a dedicated skill:
/ai-factory.skill-generator <skill-name>
undefined- 运行 检查近期代码,验证改进效果
/ai-factory.review - 下次进化 — 在完成5-10次更多修复后,再次运行
/ai-factory.evolve - 考虑新增技能 — 如果模式X持续出现,创建专用技能:
/ai-factory.skill-generator <skill-name>
undefinedContext Cleanup
上下文清理
Context is heavy after reading all patches and skills. All improvements are saved — suggest freeing space:
AskUserQuestion: Free up context before continuing?
Options:
1. /clear — Full reset (recommended)
2. /compact — Compress history
3. Continue as is读取所有补丁和技能后,上下文占用较大。所有改进已保存 — 建议释放空间:
AskUserQuestion: 在继续之前释放上下文空间?
选项:
1. /clear — 完全重置(推荐)
2. /compact — 压缩历史记录
3. 保持当前状态继续What Each Skill Can Learn
各技能可学习内容
| Skill | Learns From | Example Enhancement |
|---|---|---|
| Patches → common errors | "Check for X before accessing Y" |
| Patches → prevention rules | "When creating models, always validate Z" |
| Patches → logging gaps | "Add validation task for nullable fields" |
| Patches → missed issues | "Check: are all optional relations null-safe?" |
| Codebase → conventions | "Use project's commit prefix format" |
| Codebase → patterns | "Default branch prefix based on project convention" |
| 技能 | 学习来源 | 示例改进 |
|---|---|---|
| 补丁 → 常见错误 | "在访问Y之前检查X" |
| 补丁 → 预防规则 | "创建模型时,始终验证Z" |
| 补丁 → 日志缺口 | "添加可空字段的验证任务" |
| 补丁 → 遗漏问题 | "检查:所有可选关联是否都做了空值安全处理?" |
| 代码库 → 约定规范 | "使用项目的提交前缀格式" |
| 代码库 → 模式 | "基于项目约定的默认分支前缀" |
Important Rules
重要规则
- Traceable — every improvement must link to a patch, convention, or tech fact
- Minimal — add rules, don't rewrite skills
- Reversible — user approves before changes are applied
- Cumulative — each evolution builds on previous ones
- No hallucination — only suggest improvements backed by evidence
- Preserve structure — don't change skill workflow, only enrich it
- 可追溯 — 每项改进必须关联到补丁、约定规范或技术事实
- 最小化 — 添加规则,不要重写技能
- 可逆 — 在应用修改前需获得用户批准
- 累积性 — 每次进化都基于之前的成果
- 无幻觉 — 仅建议有证据支持的改进
- 保留结构 — 不要改变技能工作流程,仅丰富内容
Examples
示例
Example 1: After 10 fixes with null-reference patterns
示例1:在10次修复后,空引用模式频繁出现
/ai-factory.evolve fix
→ Found 6/10 patches tagged #null-check
→ Improvement: Add to /ai-factory.fix Step 2:
"PRIORITY CHECK: Look for optional/nullable fields accessed
without null guards. This is the #1 source of bugs in this project."
→ Improvement: Add to /ai-factory.review checklist:
"- [ ] All nullable DB fields have null checks in UI/API layer"/ai-factory.evolve fix
→ 发现10个补丁中有6个标记为#null-check
→ 改进:添加到/ai-factory.fix步骤2:
"优先级检查:在访问嵌套属性前,检查可选/可空字段。这是本项目中排名第一的bug来源。"
→ 改进:添加到/ai-factory.review检查清单:
"- [ ] 所有可空数据库字段在UI/API层都有空值检查"Example 2: Laravel project with N+1 issues
示例2:存在N+1问题的Laravel项目
/ai-factory.evolve all
→ Stack: Laravel + Eloquent (from DESCRIPTION.md)
→ Found 3 patches tagged #n-plus-one #database
→ Improvement: Add to /ai-factory.implement logging:
"Enable query logging: DB::enableQueryLog() in DEBUG mode"
→ Improvement: Add to /ai-factory.review checklist:
"- [ ] Eager loading used for related models (no N+1)"
→ Improvement: Add to /ai-factory.task descriptions:
"Include 'use ->with() for relations' in DB-related tasks"/ai-factory.evolve all
→ 技术栈:Laravel + Eloquent(来自DESCRIPTION.md)
→ 发现3个补丁标记为#n-plus-one #database
→ 改进:添加到/ai-factory.implement日志记录:
"启用查询日志:在DEBUG模式下使用DB::enableQueryLog()"
→ 改进:添加到/ai-factory.review检查清单:
"- [ ] 关联模型使用了预加载(无N+1问题)"
→ 改进:添加到/ai-factory.task描述:
"在数据库相关任务中包含'使用->with()处理关联'"Example 3: First run with no patches
示例3:首次运行,无补丁
/ai-factory.evolve
→ No patches found (first run)
→ Analyzing project context only...
→ Stack: Next.js 14 + Prisma + TypeScript
→ Improvement: Add to /ai-factory.implement:
"Use server actions for mutations, API routes for external APIs"
→ Improvement: Add to /ai-factory.fix:
"For Prisma errors, check schema.prisma for field types first"
→ Improvement: Add to /ai-factory.review:
"- [ ] Server components don't use client-only hooks"/ai-factory.evolve
→ 未找到补丁(首次运行)
→ 仅分析项目上下文...
→ 技术栈:Next.js 14 + Prisma + TypeScript
→ 改进:添加到/ai-factory.implement:
"使用Server Actions处理突变,API路由处理外部API"
→ 改进:添加到/ai-factory.fix:
"对于Prisma错误,首先检查schema.prisma中的字段类型"
→ 改进:添加到/ai-factory.review:
"- [ ] 服务端组件未使用仅客户端钩子"DO NOT:
禁止操作:
- Do not rewrite entire skills
- Do not remove existing rules
- Do not add generic advice ("write clean code")
- Do not create new skills (suggest using instead)
/ai-factory.skill-generator - Do not apply changes without user approval
- Do not evolve skills not installed in the project
- 不要重写整个技能
- 不要删除现有规则
- 不要添加通用建议(如"编写整洁代码")
- 不要创建新技能(建议使用替代)
/ai-factory.skill-generator - 不要在未获得用户批准的情况下应用修改
- 不要进化项目中未安装的技能