Files
everything-claude-code-zh/skills/continuous-learning-v2/commands/evolve.md

187 lines
4.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: evolve
description: 将相关本能Instincts聚类为技能、命令或智能体
command: /evolve
implementation: python3 ~/.claude/skills/continuous-learning-v2/scripts/instinct-cli.py evolve
---
# 演进Evolve命令
## 实现
```bash
python3 ~/.claude/skills/continuous-learning-v2/scripts/instinct-cli.py evolve [--generate]
```
分析本能Instincts并将相关的本能聚类为更高级别的结构
- **命令Commands**:当本能描述的是用户调用的操作时
- **技能Skills**:当本能描述的是自动触发的行为时
- **智能体Agents**:当本能描述的是复杂的、多步骤的过程时
## 用法
```
/evolve # 分析所有本能并建议演进方案
/evolve --domain testing # 仅演进测试领域testing domain中的本能
/evolve --dry-run # 显示将要创建的内容而不实际执行
/evolve --threshold 5 # 要求 5 个或更多相关本能才进行聚类
```
## 演进规则
### → 命令Command用户调用
当本能描述用户会显式请求的操作时:
- 多个关于“当用户要求...”的本能
- 带有“在创建新的 X 时”等触发器的本能
- 遵循可重复序列的本能
示例:
- `new-table-step1`:“在添加数据库表时,创建迁移文件”
- `new-table-step2`:“在添加数据库表时,更新 schema”
- `new-table-step3`:“在添加数据库表时,重新生成类型”
→ 创建:`/new-table` 命令
### → 技能Skill自动触发
当本能描述应该自动发生的行为时:
- 模式匹配触发器
- 错误处理响应
- 代码风格强制执行
示例:
- `prefer-functional`:“在编写函数时,优先使用函数式风格”
- `use-immutable`:“在修改状态时,使用不可变模式”
- `avoid-classes`:“在设计模块时,避免基于类的设计”
→ 创建:`functional-patterns` 技能
### → 智能体Agent需要深度/隔离)
当本能描述受益于隔离的复杂、多步骤过程时:
- 调试工作流Workflow
- 重构序列
- 研究任务
示例:
- `debug-step1`:“调试时,先检查日志”
- `debug-step2`:“调试时,隔离故障组件”
- `debug-step3`:“调试时,创建最小复现”
- `debug-step4`:“调试时,通过测试验证修复”
→ 创建:`debugger` 智能体
## 执行步骤
1.`~/.claude/homunculus/instincts/` 读取所有本能
2. 按以下维度对本能进行分组:
- 领域相似性
- 触发模式重叠
- 动作序列关系
3. 对于每个包含 3 个或更多相关本能的聚类:
- 确定演进类型(命令/技能/智能体)
- 生成相应的文件
- 保存到 `~/.claude/homunculus/evolved/{commands,skills,agents}/`
4. 将演进后的结构链接回源本能
## 输出格式
```
🧬 演进分析Evolve Analysis
==================
发现 3 个已准备好演进的聚类:
## 聚类 1: 数据库迁移工作流
本能: new-table-migration, update-schema, regenerate-types
类型: 命令 (Command)
置信度: 85% (基于 12 次观察)
将创建: /new-table 命令
文件:
- ~/.claude/homunculus/evolved/commands/new-table.md
## 聚类 2: 函数式代码风格
本能: prefer-functional, use-immutable, avoid-classes, pure-functions
类型: 技能 (Skill)
置信度: 78% (基于 8 次观察)
将创建: functional-patterns 技能
文件:
- ~/.claude/homunculus/evolved/skills/functional-patterns.md
## 聚类 3: 调试过程
本能: debug-check-logs, debug-isolate, debug-reproduce, debug-verify
类型: 智能体 (Agent)
置信度: 72% (基于 6 次观察)
将创建: debugger 智能体
文件:
- ~/.claude/homunculus/evolved/agents/debugger.md
---
运行 `/evolve --execute` 来创建这些文件。
```
## 标志Flags
- `--execute`:实际创建演进后的结构(默认为预览)
- `--dry-run`:预览而不创建
- `--domain <name>`:仅演进指定领域中的本能
- `--threshold <n>`形成聚类所需的最小本能数量默认3
- `--type <command|skill|agent>`:仅创建指定类型
## 生成文件格式
### 命令 (Command)
```markdown
---
name: new-table
description: 创建带有迁移、schema 更新和类型生成的数据库新表
command: /new-table
evolved_from:
- new-table-migration
- update-schema
- regenerate-types
---
# New Table 命令
[基于聚类本能生成的具体内容]
## 步骤
1. ...
2. ...
```
### 技能 (Skill)
```markdown
---
name: functional-patterns
description: 强制执行函数式编程模式
evolved_from:
- prefer-functional
- use-immutable
- avoid-classes
---
# Functional Patterns 技能
[基于聚类本能生成的具体内容]
```
### 智能体 (Agent)
```markdown
---
name: debugger
description: 系统化调试智能体
model: sonnet
evolved_from:
- debug-check-logs
- debug-isolate
- debug-reproduce
---
# Debugger 智能体
[基于聚类本能生成的具体内容]
```