--- name: self-evolution description: Post-task reflection, pattern extraction, skill generation, memory update. Continuous self-improvement loop. metadata: { "openclaw": { "emoji": "🧬" } } --- # Self-Evolution — Continuous Improvement Loop After every completed task, run the evolution cycle. Each task makes the system stronger. ## Evolution Cycle (9 Steps) ### 1. Record Successes What worked? Why? Can we replicate it? → `/reflections/YYYY-MM-DD-.md` ### 2. Record Failures What broke? Root cause? Fix applied? → same reflection file ### 3. Generate New Skill Does this task create a reusable capability? If yes: → `/skills/.md` (YAML frontmatter + usage guide) ### 4. Update Memory Write today's key events to daily log. → `memory/daily/YYYY-MM-DD.md` ### 5. Update Best Practices Extract reusable patterns that worked. → `/patterns/design-patterns.md` (problem → solution → anti-pattern) ### 6. Update Prompt Templates Did we create a useful prompt format? Template it. → `/patterns/prompt-templates.md` ### 7. Update Tool Strategy Did we learn about tool selection/sequencing? → `/playbooks/` or pattern file ### 8. Update CodeGraph Re-index the workspace to capture new code. ```bash node src/codegraph/index.js index . --force ``` ### 9. Update Compression Rules Did we discover new content type → compression strategy mappings? → update `src/compression/detector.js` signal weights ## Directory Structure ``` workspace/ ├── reflections/ ← 每次任务的反思 (YYYY-MM-DD-.md) ├── patterns/ ← 可复用设计模式 ├── playbooks/ ← 常用任务的操作手册 ├── skills/ ← 能力技能文件 └── memory/ ← 长期记忆系统 ``` ## Integration with Existing Systems - **Dream Cycle** (cron 4:00) → 自动整合 reflections/ 到 memory/ - **Memory Search** → 可检索过往反思 - **CodeGraph** → 索引所有演化产物 ## Quality Gate After each evolution cycle, verify: - [ ] reflections/ 有本次任务的反思文件 - [ ] 如果产生了新模式 → patterns/ 已更新 - [ ] 如果产生了新能力 → skills/ 已创建 - [ ] memory/daily/ 已写入今日总结 - [ ] 所有新代码可独立运行