skill-from-book
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSkill From Book
基于书籍创建Skill
Transform book content into structured, context-efficient Claude skills.
将书籍内容转换为结构化、上下文高效的Claude skills。
Overview
概述
This skill guides you through converting a book (in markdown format) into a well-organized skill with:
- Granular knowledge files (one concept per file)
- Workflows for repeatable tasks
- Use-case guidelines (mapping tasks to relevant files)
- Progress tracking for multi-session work
- Subagent extraction tasks
本技能将引导你把Markdown格式的书籍转换为结构清晰的Skill,包含:
- 细粒度知识文件(每个文件对应一个概念)
- 用于重复任务的工作流
- 用例指南(将任务映射到相关文件)
- 多会话工作的进度跟踪
- 子代理提取任务
CRITICAL INSTRUCTIONS
重要指令
YOU MUST FOLLOW THIS WORKFLOW STRICTLY. DO NOT SKIP OR REORDER PHASES.
- DO NOT read the book markdown file content before starting Phase 1
- MUST read each reference file BEFORE starting its corresponding phase
- MUST complete each phase before moving to the next
- MUST use subagents for extraction tasks
- MUST propose workflows to user before finalization
你必须严格遵循此工作流,不得跳过或调整阶段顺序。
- 在开始第一阶段前,禁止阅读书籍Markdown文件的内容
- 在开始对应阶段前,必须阅读每个参考文件
- 必须完成当前阶段后,才能进入下一阶段
- 必须使用子代理执行提取任务
- 在最终确定前,必须向用户提交工作流提案
Workflow
工作流
Phase 1: Analysis
第一阶段:分析
STOP! Before proceeding, you MUST:
- Read completely
references/analysis-guide.md - Only then proceed with the steps below
Phase 1 Steps:
-
Extract TOC and outline ONLY (DO NOT read full book content)bash
# Count total lines wc -l book.md # Extract headers/TOC - THIS IS ALL YOU NEED grep -E "^#{1,3} " book.md -
Identify knowledge categories from outline
- Core principles/philosophy
- Rules and guidelines
- Examples (good vs bad)
- Patterns and anti-patterns
- Checklists and quick references
-
Define use cases
- Who will use this skill?
- What tasks will they perform?
- What questions will they ask?
-
Ask user to confirm the identified categories and use cases before proceeding
暂停!继续前你必须:
- 完整阅读
references/analysis-guide.md - 之后再执行以下步骤
第一阶段步骤:
-
仅提取目录和大纲(禁止阅读书籍完整内容)bash
# Count total lines wc -l book.md # Extract headers/TOC - THIS IS ALL YOU NEED grep -E "^#{1,3} " book.md -
从大纲中识别知识分类
- 核心原则/理念
- 规则与指南
- 示例(正面/反面)
- 模式与反模式
- 检查表与快速参考
-
定义用例
- 谁会使用此技能?
- 他们将执行哪些任务?
- 他们会提出哪些问题?
-
请用户确认已识别的分类和用例后,再继续
Phase 2: Planning
第二阶段:规划
STOP! Before proceeding, you MUST:
- Read completely
references/extraction-patterns.md - Read completely
references/file-templates.md - Only then proceed with the steps below
Phase 2 Steps:
-
Design file structure with required files per categoryEach category MUST contain these 3 basic files:
- - Core concepts, definitions, and foundational understanding
knowledge.md - - Specific guidelines, do's and don'ts
rules.md - - Good/bad code examples, before/after comparisons
examples.md
Additional files as needed:- - Reusable solutions
patterns.md - - Anti-patterns and what to avoid
smells.md - - Quick reference checklists
checklist.md
skill-name/ ├── SKILL.md ├── progress.md ├── guidelines.md ├── workflows/ # NEW: Step-by-step processes │ ├── [task-1].md │ └── [task-2].md └── references/ ├── category-1/ │ ├── knowledge.md # REQUIRED │ ├── rules.md # REQUIRED │ ├── examples.md # REQUIRED │ ├── patterns.md # Optional │ └── checklist.md # Optional └── category-2/ ├── knowledge.md # REQUIRED ├── rules.md # REQUIRED ├── examples.md # REQUIRED └── smells.md # Optional -
Create progress.md
- List ALL files to create (required + optional)
- Group by phase/priority
- Track completion status
-
Plan extraction tasks
- One task per knowledge file
- Define input (book section with line ranges) and output (file path)
- Identify dependencies between tasks
-
Ask user to confirm the file structure and extraction plan before proceeding
暂停!继续前你必须:
- 完整阅读
references/extraction-patterns.md - 完整阅读
references/file-templates.md - 之后再执行以下步骤
第二阶段步骤:
-
设计每个分类对应的文件结构每个分类必须包含以下3个基础文件:
- - 核心概念、定义与基础理解
knowledge.md - - 具体指南、注意事项
rules.md - - 正面/反面代码示例、前后对比
examples.md
可根据需要添加以下文件:- - 可复用解决方案
patterns.md - - 反模式与规避要点
smells.md - - 快速参考检查表
checklist.md
skill-name/ ├── SKILL.md ├── progress.md ├── guidelines.md ├── workflows/ # NEW: Step-by-step processes │ ├── [task-1].md │ └── [task-2].md └── references/ ├── category-1/ │ ├── knowledge.md # REQUIRED │ ├── rules.md # REQUIRED │ ├── examples.md # REQUIRED │ ├── patterns.md # Optional │ └── checklist.md # Optional └── category-2/ ├── knowledge.md # REQUIRED ├── rules.md # REQUIRED ├── examples.md # REQUIRED └── smells.md # Optional -
创建progress.md
- 列出所有需要创建的文件(必填+可选)
- 按阶段/优先级分组
- 跟踪完成状态
-
规划提取任务
- 每个知识文件对应一个任务
- 定义输入(书籍章节的行范围)和输出(文件路径)
- 识别任务间的依赖关系
-
请用户确认文件结构和提取计划后,再继续
Phase 3: Extraction
第三阶段:提取
STOP! Before proceeding, you MUST:
- Have completed Phase 1 and Phase 2
- Have user confirmation on the plan
- Only then proceed with extraction
CRITICAL: You MUST use subagents (Task tool) for extraction. One subagent per topic - each subagent creates ALL files for that topic.
暂停!继续前你必须:
- 完成第一和第二阶段
- 获得用户对计划的确认
- 之后再执行提取操作
重要提示:必须使用子代理(任务工具)执行提取任务。每个主题对应一个子代理,每个子代理负责创建该主题的所有文件。
Main Agent Instructions for Phase 3
主代理第三阶段指令
YOU MUST follow these steps:
- One subagent per topic - Each subagent reads a book section ONCE and creates all files for that topic (knowledge.md, rules.md, examples.md, plus any optional files)
- Prepare the subagent prompt by filling in the template below with specific values
- Calculate line ranges from your Phase 1 analysis (TOC with line numbers)
- Create the complete prompt - do NOT leave placeholders unfilled
- Launch subagents in parallel for different topics
- Update progress.md after all subagents complete
你必须遵循以下步骤:
- 每个主题对应一个子代理 - 每个子代理仅读取一次书籍章节,并创建该主题的所有文件(knowledge.md、rules.md、examples.md及可选文件)
- 填充子代理提示模板,替换所有占位符为具体值
- 根据第一阶段的分析结果(带行号的目录)计算行范围
- 创建完整的提示内容 - 不得留空占位符
- 并行启动不同主题的子代理
- 所有子代理完成后,更新progress.md
Subagent Prompt Template
子代理提示模板
IMPORTANT: Copy this template and replace ALL bracketed placeholders with actual values before launching subagent.
markdown
undefined重要提示:复制此模板并替换所有括号内的占位符为实际值后,再启动子代理。
markdown
undefinedTask: Extract [TOPIC] Knowledge Base
Task: Extract [TOPIC] Knowledge Base
You are extracting knowledge from a book section to create a complete topic reference.
You are extracting knowledge from a book section to create a complete topic reference.
Prerequisites - Read These Files First:
Prerequisites - Read These Files First:
- - Templates for all file types
skills/skill-from-book/references/file-templates.md - - Extraction rules
skills/skill-from-book/references/extraction-patterns.md
- - Templates for all file types
skills/skill-from-book/references/file-templates.md - - Extraction rules
skills/skill-from-book/references/extraction-patterns.md
Source Material:
Source Material:
- Book: [BOOK_PATH]
- Section: [CHAPTER/SECTION_NAME]
- Line range: Read with offset=[START_LINE], limit=[LINE_COUNT]
- Book: [BOOK_PATH]
- Section: [CHAPTER/SECTION_NAME]
- Line range: Read with offset=[START_LINE], limit=[LINE_COUNT]
Output Directory: [OUTPUT_TOPIC_PATH]
Output Directory: [OUTPUT_TOPIC_PATH]
Files to Create (in this order):
Files to Create (in this order):
1. knowledge.md (REQUIRED)
1. knowledge.md (REQUIRED)
Core concepts, definitions, and foundational understanding.
- Extract: definitions, terminology, key concepts, how things relate
- Use the "Knowledge File" template
Core concepts, definitions, and foundational understanding.
- Extract: definitions, terminology, key concepts, how things relate
- Use the "Knowledge File" template
2. rules.md (REQUIRED)
2. rules.md (REQUIRED)
Specific guidelines, do's and don'ts.
- Extract: explicit rules, guidelines, best practices, exceptions
- Use the "Rules File" template
Specific guidelines, do's and don'ts.
- Extract: explicit rules, guidelines, best practices, exceptions
- Use the "Rules File" template
3. examples.md (REQUIRED)
3. examples.md (REQUIRED)
Good/bad code examples, before/after comparisons.
- Extract: all code samples, refactoring examples, comparisons
- Use the "Examples File" template
Good/bad code examples, before/after comparisons.
- Extract: all code samples, refactoring examples, comparisons
- Use the "Examples File" template
4. [OPTIONAL_FILES - list any additional files needed]
4. [OPTIONAL_FILES - list any additional files needed]
[e.g., patterns.md, smells.md, checklist.md - specify what each should contain]
[e.g., patterns.md, smells.md, checklist.md - specify what each should contain]
Your Instructions:
Your Instructions:
- Read the two prerequisite files FIRST to understand templates and extraction rules
- Read the book section ONCE using: offset=[START_LINE], limit=[LINE_COUNT]
- From that single read, extract content for ALL files listed above
- For each file:
- Transform content (prose → bullets, extract rules, include examples)
- Format using the appropriate template from file-templates.md
- Keep each file under 200 lines
- Write to [OUTPUT_TOPIC_PATH]/[filename].md
- Create files in order: knowledge.md → rules.md → examples.md → optional files
- Read the two prerequisite files FIRST to understand templates and extraction rules
- Read the book section ONCE using: offset=[START_LINE], limit=[LINE_COUNT]
- From that single read, extract content for ALL files listed above
- For each file:
- Transform content (prose → bullets, extract rules, include examples)
- Format using the appropriate template from file-templates.md
- Keep each file under 200 lines
- Write to [OUTPUT_TOPIC_PATH]/[filename].md
- Create files in order: knowledge.md → rules.md → examples.md → optional files
Content Guidance:
Content Guidance:
[SPECIFIC_GUIDANCE - what to focus on, what to skip]
[SPECIFIC_GUIDANCE - what to focus on, what to skip]
Language Conversion (if applicable):
Language Conversion (if applicable):
- Source: [SOURCE_LANG or "N/A"]
- Target: [TARGET_LANG or "N/A"]
- Convert ALL code examples to target language
undefined- Source: [SOURCE_LANG or "N/A"]
- Target: [TARGET_LANG or "N/A"]
- Convert ALL code examples to target language
undefinedExample: Filled Subagent Prompt
示例:填充后的子代理提示
markdown
undefinedmarkdown
undefinedTask: Extract Functions Knowledge Base
Task: Extract Functions Knowledge Base
You are extracting knowledge from a book section to create a complete topic reference.
You are extracting knowledge from a book section to create a complete topic reference.
Prerequisites - Read These Files First:
Prerequisites - Read These Files First:
- - Templates for all file types
skills/skill-from-book/references/file-templates.md - - Extraction rules
skills/skill-from-book/references/extraction-patterns.md
- - Templates for all file types
skills/skill-from-book/references/file-templates.md - - Extraction rules
skills/skill-from-book/references/extraction-patterns.md
Source Material:
Source Material:
- Book: /path/to/clean-code.md
- Section: Chapter 3 - Functions
- Line range: Read with offset=450, limit=380
- Book: /path/to/clean-code.md
- Section: Chapter 3 - Functions
- Line range: Read with offset=450, limit=380
Output Directory: skills/clean-code/references/functions
Output Directory: skills/clean-code/references/functions
Files to Create (in this order):
Files to Create (in this order):
1. knowledge.md (REQUIRED)
1. knowledge.md (REQUIRED)
Core concepts, definitions, and foundational understanding.
- Extract: what makes a function clean, key terminology (side effects, arguments, abstraction levels), how functions relate to other concepts
- Use the "Knowledge File" template
Core concepts, definitions, and foundational understanding.
- Extract: what makes a function clean, key terminology (side effects, arguments, abstraction levels), how functions relate to other concepts
- Use the "Knowledge File" template
2. rules.md (REQUIRED)
2. rules.md (REQUIRED)
Specific guidelines, do's and don'ts.
- Extract: size rules, argument limits, naming conventions, single responsibility, do one thing principle
- Use the "Rules File" template
Specific guidelines, do's and don'ts.
- Extract: size rules, argument limits, naming conventions, single responsibility, do one thing principle
- Use the "Rules File" template
3. examples.md (REQUIRED)
3. examples.md (REQUIRED)
Good/bad code examples, before/after comparisons.
- Extract: all code samples showing good vs bad functions, refactoring walkthroughs
- Use the "Examples File" template
Good/bad code examples, before/after comparisons.
- Extract: all code samples showing good vs bad functions, refactoring walkthroughs
- Use the "Examples File" template
4. checklist.md (OPTIONAL)
4. checklist.md (OPTIONAL)
Quick reference for reviewing functions.
- Create a checklist from the rules for code review
Quick reference for reviewing functions.
- Create a checklist from the rules for code review
Your Instructions:
Your Instructions:
- Read the two prerequisite files FIRST to understand templates and extraction rules
- Read the book section ONCE using: offset=450, limit=380
- From that single read, extract content for ALL files listed above
- For each file:
- Transform content (prose → bullets, extract rules, include examples)
- Format using the appropriate template from file-templates.md
- Keep each file under 200 lines
- Write to skills/clean-code/references/functions/[filename].md
- Create files in order: knowledge.md → rules.md → examples.md → checklist.md
- Read the two prerequisite files FIRST to understand templates and extraction rules
- Read the book section ONCE using: offset=450, limit=380
- From that single read, extract content for ALL files listed above
- For each file:
- Transform content (prose → bullets, extract rules, include examples)
- Format using the appropriate template from file-templates.md
- Keep each file under 200 lines
- Write to skills/clean-code/references/functions/[filename].md
- Create files in order: knowledge.md → rules.md → examples.md → checklist.md
Content Guidance:
Content Guidance:
Focus on practical, actionable content. Skip author anecdotes and historical context. Prioritize rules that are universally applicable.
Focus on practical, actionable content. Skip author anecdotes and historical context. Prioritize rules that are universally applicable.
Language Conversion:
Language Conversion:
- Source: Java
- Target: TypeScript
- Convert ALL code examples to TypeScript
undefined- Source: Java
- Target: TypeScript
- Convert ALL code examples to TypeScript
undefinedParallel Extraction Strategy
并行提取策略
Run in parallel: Different topics (each handled by one subagent)
- Subagent 1: functions/ (Chapter 3)
- Subagent 2: naming/ (Chapter 2)
- Subagent 3: classes/ (Chapter 10)
Must wait: guidelines.md and workflows creation waits for ALL topic subagents to complete
并行运行:不同主题(每个主题由一个子代理处理)
- Subagent 1: functions/ (Chapter 3)
- Subagent 2: naming/ (Chapter 2)
- Subagent 3: classes/ (Chapter 10)
必须等待:guidelines.md和工作流的创建需等待所有主题子代理完成
Main Agent Checklist Before Launching Subagent
启动子代理前的主代理检查清单
- All placeholders replaced with actual values
- Line offset and limit calculated from Phase 1 TOC
- Output directory path follows naming convention
- All required files (knowledge.md, rules.md, examples.md) listed
- Optional files specified with clear content guidance
- Content guidance is specific to this topic
- Language conversion specified if needed
- 所有占位符已替换为实际值
- 行偏移和行数限制根据第一阶段的目录计算得出
- 输出目录路径符合命名规范
- 列出了所有必填文件(knowledge.md、rules.md、examples.md)
- 可选文件已明确内容要求
- 内容指南针对当前主题
- 如需语言转换已明确说明
Phase 4: Guidelines Creation
第四阶段:指南创建
STOP! Before proceeding, you MUST:
- Have completed all extraction tasks in Phase 3
- Read completely
references/guidelines-template.md - Only then proceed with guidelines creation
Phase 4 Steps:
Create that maps:
guidelines.md- Tasks → relevant files (and workflows)
- Code elements → relevant files
- Symptoms/problems → relevant files
- Decision trees for common scenarios
暂停!继续前你必须:
- 完成第三阶段的所有提取任务
- 完整阅读
references/guidelines-template.md - 之后再执行指南创建
第四阶段步骤:
创建,映射以下内容:
guidelines.md- 任务 → 相关文件(及工作流)
- 代码元素 → 相关文件
- 症状/问题 → 相关文件
- 常见场景的决策树
Phase 5: Workflow Proposal
第五阶段:工作流提案
STOP! Before proceeding, you MUST:
- Have completed Phase 4 (Guidelines)
- Read completely
references/workflow-templates.md - Only then proceed with workflow proposal
Phase 5 Steps:
-
Identify potential workflows from the book contentLook for:
- Process descriptions ("how to do X")
- Repeated tasks (mentioned multiple times)
- Checklists in the book
- Anti-pattern sections (imply correct process)
- Multi-step procedures
-
Propose workflows to userPresent a list of potential workflows:
Based on the book content, I recommend these workflows: | Workflow | Purpose | Key Steps | |----------|---------|-----------| | [name] | [what it does] | [brief step summary] | | [name] | [what it does] | [brief step summary] | -
Ask user to select which workflows to create
Which workflows would you like me to create? - Select from the list above - Suggest additional workflows - Skip workflow creation -
Create selected workflowsFor each selected workflow:
- Use the template from
references/workflow-templates.md - Include cross-references to relevant knowledge files
- Add checkboxes for each step
- Define clear exit criteria
- Use the template from
-
Update guidelines.md to include workflow referencesAdd a "Workflows" section at the top of guidelines.md:markdown
## Workflows | Task | Workflow | |------|----------| | [task description] | `workflows/[name].md` |
暂停!继续前你必须:
- 完成第四阶段(指南创建)
- 完整阅读
references/workflow-templates.md - 之后再执行工作流提案
第五阶段步骤:
-
从书籍内容中识别潜在工作流重点关注:
- 流程描述(“如何完成X”)
- 重复任务(多次提及的任务)
- 书籍中的检查表
- 反模式章节(隐含正确流程)
- 多步骤流程
-
向用户提交工作流提案列出潜在工作流:
Based on the book content, I recommend these workflows: | Workflow | Purpose | Key Steps | |----------|---------|-----------| | [name] | [what it does] | [brief step summary] | | [name] | [what it does] | [brief step summary] | -
请用户选择需要创建的工作流
Which workflows would you like me to create? - Select from the list above - Suggest additional workflows - Skip workflow creation -
创建选中的工作流每个选中的工作流需:
- 使用中的模板
references/workflow-templates.md - 包含相关知识文件的交叉引用
- 为每个步骤添加复选框
- 定义明确的退出标准
- 使用
-
更新guidelines.md以包含工作流引用在guidelines.md顶部添加“工作流”部分:markdown
## Workflows | Task | Workflow | |------|----------| | [task description] | `workflows/[name].md` |
Phase 6: Finalization
第六阶段:最终确定
Phase 6 Steps:
- Review all files for consistency
- Update progress.md (mark complete)
- Test with sample queries
- Refine guidelines based on testing
- Ask user to review the final skill
第六阶段步骤:
- 检查所有文件的一致性
- 更新progress.md(标记完成状态)
- 使用示例查询进行测试
- 根据测试结果优化指南
- 请用户审核最终的技能
Key Principles
核心原则
Granularity
细粒度
- One concept per file
- Files should be 50-200 lines
- Split large topics into subtopics
- 每个文件对应一个概念
- 文件长度控制在50-200行
- 将大主题拆分为子主题
Context Efficiency
上下文高效
- Only load what's needed
- Guidelines file routes to specific knowledge
- Avoid duplication across files
- 仅加载所需内容
- 指南文件引导至特定知识
- 避免文件间内容重复
Actionable Content
可操作性
- Rules over explanations
- Examples over theory
- Checklists for quick reference
- Workflows for repeatable tasks
- 优先规则而非解释
- 优先示例而非理论
- 提供快速参考检查表
- 为重复任务提供工作流
Subagent-Friendly
子代理友好
- Each extraction task is independent
- Clear input/output specification
- Can run multiple extractions in parallel
- 每个提取任务独立
- 明确输入/输出规范
- 支持多提取任务并行运行
File Naming Conventions
文件命名规范
skill-name/
├── SKILL.md
├── guidelines.md
├── progress.md
├── workflows/ # Step-by-step processes
│ ├── [verb]-[noun].md # e.g., code-review.md, bug-fix.md
│ └── ...
└── references/
├── [category]/ # Noun, plural (e.g., functions, classes)
│ ├── knowledge.md # REQUIRED: Core concepts and definitions
│ ├── rules.md # REQUIRED: Specific guidelines
│ ├── examples.md # REQUIRED: Good/bad examples
│ ├── patterns.md # Optional: Reusable solutions
│ ├── smells.md # Optional: Anti-patterns
│ └── checklist.md # Optional: Quick referenceskill-name/
├── SKILL.md
├── guidelines.md
├── progress.md
├── workflows/ # Step-by-step processes
│ ├── [verb]-[noun].md # e.g., code-review.md, bug-fix.md
│ └── ...
└── references/
├── [category]/ # Noun, plural (e.g., functions, classes)
│ ├── knowledge.md # REQUIRED: Core concepts and definitions
│ ├── rules.md # REQUIRED: Specific guidelines
│ ├── examples.md # REQUIRED: Good/bad examples
│ ├── patterns.md # Optional: Reusable solutions
│ ├── smells.md # Optional: Anti-patterns
│ └── checklist.md # Optional: Quick referenceProgress Tracking
进度跟踪
Always maintain :
progress.mdmarkdown
undefined始终维护progress.md:
markdown
undefined[Skill Name] - Creation Progress
[Skill Name] - Creation Progress
Status: [X/Y files complete]
Status: [X/Y files complete]
Phase 1: Foundation
Phase 1: Foundation
- SKILL.md
- progress.md
- guidelines.md
- SKILL.md
- progress.md
- guidelines.md
Phase 2: Workflows
Phase 2: Workflows
- workflows/[name].md
- workflows/[name].md
- workflows/[name].md
- workflows/[name].md
Phase 3: [Category Name]
Phase 3: [Category Name]
- category/knowledge.md # REQUIRED
- category/rules.md # REQUIRED
- category/examples.md # REQUIRED
- category/patterns.md # Optional ...
undefined- category/knowledge.md # REQUIRED
- category/rules.md # REQUIRED
- category/examples.md # REQUIRED
- category/patterns.md # Optional ...
undefinedQuick Start
快速开始
- User provides the book markdown file path
- DO NOT read the book content yet
- Run Phase 1: Analysis (extract TOC only)
- Get user confirmation
- Run Phase 2: Planning
- Get user confirmation
- Run Phase 3: Extraction (use subagents)
- Run Phase 4: Guidelines Creation
- Run Phase 5: Workflow Proposal (get user selection)
- Run Phase 6: Finalization
- 用户提供书籍Markdown文件路径
- 禁止立即阅读书籍内容
- 执行第一阶段:分析(仅提取目录)
- 获得用户确认
- 执行第二阶段:规划
- 获得用户确认
- 执行第三阶段:提取(使用子代理)
- 执行第四阶段:指南创建
- 执行第五阶段:工作流提案(获取用户选择)
- 执行第六阶段:最终确定