extract
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese/si:extract — Create Skills from Patterns
/si:extract — 从模式创建Skill
Transforms a recurring pattern or debugging solution into a standalone, portable skill that can be installed in any project.
将重复出现的模式或调试解决方案转换为可独立移植的Skill,可在任何项目中安装。
Usage
使用方法
/si:extract <pattern description> # Interactive extraction
/si:extract <pattern> --name docker-m1-fixes # Specify skill name
/si:extract <pattern> --output ./skills/ # Custom output directory
/si:extract <pattern> --dry-run # Preview without creating files/si:extract <pattern description> # 交互式提取
/si:extract <pattern> --name docker-m1-fixes # 指定Skill名称
/si:extract <pattern> --output ./skills/ # 自定义输出目录
/si:extract <pattern> --dry-run # 预览而不创建文件When to Extract
何时提取
A learning qualifies for skill extraction when ANY of these are true:
| Criterion | Signal |
|---|---|
| Recurring | Same issue across 2+ projects |
| Non-obvious | Required real debugging to discover |
| Broadly applicable | Not tied to one specific codebase |
| Complex solution | Multi-step fix that's easy to forget |
| User-flagged | "Save this as a skill", "I want to reuse this" |
当满足以下任一条件时,就可以将经验提炼为Skill:
| 标准 | 信号 |
|---|---|
| 重复出现 | 2个以上项目中出现相同问题 |
| 非显而易见 | 需要实际调试才能发现 |
| 广泛适用 | 不绑定到特定代码库 |
| 解决方案复杂 | 多步骤修复,容易遗忘 |
| 用户标记 | “将这个保存为Skill”、“我想复用这个” |
Workflow
工作流程
Step 1: Identify the pattern
步骤1:识别模式
Read the user's description. Search auto-memory for related entries:
bash
MEMORY_DIR="$HOME/.claude/projects/$(pwd | sed 's|/|%2F|g; s|%2F|/|; s|^/||')/memory"
grep -rni "<keywords>" "$MEMORY_DIR/"If found in auto-memory, use those entries as source material. If not, use the user's description directly.
阅读用户描述。在自动记忆中搜索相关条目:
bash
MEMORY_DIR="$HOME/.claude/projects/$(pwd | sed 's|/|%2F|g; s|%2F|/|; s|^/||')/memory"
grep -rni "<keywords>" "$MEMORY_DIR/"如果在自动记忆中找到,使用这些条目作为源材料。如果没有,直接使用用户描述。
Step 2: Determine skill scope
步骤2:确定Skill范围
Ask (max 2 questions):
- "What problem does this solve?" (if not clear)
- "Should this include code examples?" (if applicable)
最多问2个问题:
- “这解决了什么问题?”(如果不明确)
- “是否应包含代码示例?”(如果适用)
Step 3: Generate skill name
步骤3:生成Skill名称
Rules for naming:
- Lowercase, hyphens between words
- Descriptive but concise (2-4 words)
- Examples: ,
docker-m1-fixes,api-timeout-patternspnpm-workspace-setup
命名规则:
- 小写,单词间用连字符连接
- 描述性但简洁(2-4个单词)
- 示例:,
docker-m1-fixes,api-timeout-patternspnpm-workspace-setup
Step 4: Create the skill files
步骤4:创建Skill文件
Spawn the agent for the actual file generation.
skill-extractorThe agent creates:
<skill-name>/
├── SKILL.md # Main skill file with frontmatter
├── README.md # Human-readable overview
└── reference/ # (optional) Supporting documentation
└── examples.md # Concrete examples and edge cases启动 Agent 来实际生成文件。
skill-extractorAgent会创建:
<skill-name>/
├── SKILL.md # 包含前置元数据的主Skill文件
├── README.md # 人类可读的概述
└── reference/ # (可选) 支持文档
└── examples.md # 具体示例和边缘情况Step 5: SKILL.md structure
步骤5:SKILL.md结构
The generated SKILL.md must follow this format:
markdown
---
name: <skill-name>
description: "<one-line description>. Use when: <trigger conditions>."
---生成的SKILL.md必须遵循以下格式:
markdown
---
name: <skill-name>
description: "<一行描述>。适用场景:<触发条件>。"
---<Skill Title>
<Skill标题>
One-line summary of what this skill solves.
关于此Skill解决问题的一行摘要。
Quick Reference
快速参考
| Problem | Solution |
|---|---|
| {{problem 1}} | {{solution 1}} |
| {{problem 2}} | {{solution 2}} |
| 问题 | 解决方案 |
|---|---|
| {{problem 1}} | {{solution 1}} |
| {{problem 2}} | {{solution 2}} |
The Problem
问题说明
{{2-3 sentences explaining what goes wrong and why it's non-obvious.}}
{{2-3句话解释问题是什么以及为什么它非显而易见。}}
Solutions
解决方案
Option 1: {{Name}} (Recommended)
选项1:{{名称}}(推荐)
{{Step-by-step with code examples.}}
{{带代码示例的分步说明。}}
Option 2: {{Alternative}}
选项2:{{替代方案}}
{{For when Option 1 doesn't apply.}}
{{当选项1不适用时的方案。}}
Trade-offs
权衡对比
| Approach | Pros | Cons |
|---|---|---|
| Option 1 | {{pros}} | {{cons}} |
| Option 2 | {{pros}} | {{cons}} |
| 方法 | 优点 | 缺点 |
|---|---|---|
| 选项1 | {{pros}} | {{cons}} |
| 选项2 | {{pros}} | {{cons}} |
Edge Cases
边缘情况
- {{edge case 1 and how to handle it}}
- {{edge case 2 and how to handle it}}
undefined- {{边缘情况1及其处理方法}}
- {{边缘情况2及其处理方法}}
undefinedStep 6: Quality gates
步骤6:质量检查
Before finalizing, verify:
- SKILL.md has valid YAML frontmatter with and
namedescription - matches the folder name (lowercase, hyphens)
name - Description includes "Use when:" trigger conditions
- Solutions are self-contained (no external context needed)
- Code examples are complete and copy-pasteable
- No project-specific hardcoded values (paths, URLs, credentials)
- No unnecessary dependencies
最终确定前,验证以下内容:
- SKILL.md包含有效的YAML前置元数据,带有和
namedescription - 与文件夹名称匹配(小写,连字符连接)
name - 描述中包含“适用场景:”触发条件
- 解决方案是自包含的(无需外部上下文)
- 代码示例完整且可直接复制粘贴
- 没有项目特定的硬编码值(路径、URL、凭证)
- 没有不必要的依赖
Step 7: Report
步骤7:报告
✅ Skill extracted: {{skill-name}}
Files created:
{{path}}/SKILL.md ({{lines}} lines)
{{path}}/README.md ({{lines}} lines)
{{path}}/reference/examples.md ({{lines}} lines)
Install: /plugin install (copy to your skills directory)
Publish: clawhub publish {{path}}
Source: MEMORY.md entries at lines {{n, m, ...}} (retained — the skill is portable, the memory is project-specific)✅ Skill已提取:{{skill-name}}
已创建文件:
{{path}}/SKILL.md ({{lines}} 行)
{{path}}/README.md ({{lines}} 行)
{{path}}/reference/examples.md ({{lines}} 行)
安装:/plugin install(复制到你的skills目录)
发布:clawhub publish {{path}}
来源:MEMORY.md中第{{n, m, ...}}行的条目(已保留 — Skill是可移植的,记忆是项目特定的)Examples
示例
Extracting a debugging pattern
提取调试模式
/si:extract "Fix for Docker builds failing on Apple Silicon with platform mismatch"Creates with:
docker-m1-fixes/SKILL.md- The platform mismatch error message
- Three solutions (build flag, Dockerfile, docker-compose)
- Trade-offs table
- Performance note about Rosetta 2 emulation
/si:extract "Fix for Docker builds failing on Apple Silicon with platform mismatch"创建,包含:
docker-m1-fixes/SKILL.md- 平台不匹配的错误消息
- 三种解决方案(构建标志、Dockerfile、docker-compose)
- 权衡对比表
- 关于Rosetta 2模拟的性能说明
Extracting a workflow pattern
提取工作流模式
/si:extract "Always regenerate TypeScript API client after modifying OpenAPI spec"Creates with:
api-client-regen/SKILL.md- Why manual regen is needed
- The exact command sequence
- CI integration snippet
- Common failure modes
/si:extract "Always regenerate TypeScript API client after modifying OpenAPI spec"创建,包含:
api-client-regen/SKILL.md- 为什么需要手动重新生成
- 确切的命令序列
- CI集成代码片段
- 常见失败模式
Tips
提示
- Extract patterns that would save time in a different project
- Keep skills focused — one problem per skill
- Include the error messages people would search for
- Test the skill by reading it without the original context — does it make sense?
- 提取能在其他项目中节省时间的模式
- 保持Skill聚焦 — 一个Skill解决一个问题
- 包含人们会搜索的错误消息
- 通过脱离原始上下文阅读来测试Skill — 它是否有意义?