关于 skill-from-book
Skill From Book 是一项将 Markdown 书籍内容整理为结构化 Claude 技能的指南,面向需要把长篇资料转成可复用知识文件和工作流的人。它规定分阶段分析、规划、提取与审核,并要求提取时使用子代理。
主要功能
- 01将书籍拆分为细粒度知识文件
- 02规划目录、任务与进度
- 03按阶段执行提取流程
- 04要求子代理处理主题提取
- 05支持工作流提案与最终审核
适用场景
- 01把 Markdown 书籍转成 Claude 技能
- 02为知识主题规划独立文件
- 03从书籍内容提取可复用工作流
- 04跟踪多阶段技能制作进度
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ bmad-labs/ skills --skill skill-from-book安装后在 Claude Code 中输入/skill-from-book确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
LICENSEreferences/analysis-guide.mdextraction-patterns.mdfile-templates.mdguidelines-template.mdworkflow-templates.mdscripts/init-book-skill.py详细介绍
Skill From Book
将书籍内容转换为结构化、上下文高效的 Claude 技能。
概述
此技能将引导你把一本书(Markdown 格式)转换为组织良好的技能,其中包括:
- 细粒度知识文件(每个文件涵盖一个概念)
- 可重复执行任务的工作流
- 用例指南(将任务映射到相关文件)
- 多会话工作的进度跟踪
- 子 Agent 提取任务
重要指示
必须严格遵循此工作流。不得跳过或调整阶段顺序。
- 在开始阶段 1 之前,不要读取书籍 Markdown 文件的内容
- 开始相应阶段之前,必须先阅读每个参考文件
- 完成每个阶段后才能进入下一阶段
- 提取任务必须使用子 Agent
- 最终确定之前,必须向用户提出工作流方案
工作流
阶段 1:分析
停!继续之前,必须:
- 完整阅读
references/analysis-guide.md - 然后才能继续执行以下步骤
阶段 1 步骤:
-
仅提取目录和大纲(不要阅读整本书的内容)
# Count total lines wc -l book.md # Extract headers/TOC - THIS IS ALL YOU NEED grep -E "^#{1,3} " book.md -
根据大纲确定知识类别
- 核心原则/理念
- 规则和指南
- 示例(好与坏)
- 模式和反模式
- 检查清单和速查表
-
定义用例
- 谁会使用此技能?
- 他们会执行哪些任务?
- 他们会提出哪些问题?
-
请用户确认确定的类别和用例,然后再继续
阶段 2:规划
停!继续之前,必须:
- 完整阅读
references/extraction-patterns.md - 完整阅读
references/file-templates.md - 然后才能继续执行以下步骤
阶段 2 步骤:
-
为每个类别设计包含必需文件的文件结构
每个类别必须包含以下 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
- 列出所有要创建的文件(必需和可选)
- 按阶段/优先级分组
- 跟踪完成状态
-
规划提取任务
- 每个知识文件对应一个任务
- 定义输入(包含行范围的书籍章节)和输出(文件路径)
- 确定任务之间的依赖关系
-
请用户确认文件结构和提取计划,然后再继续
阶段 3:提取
停!继续之前,必须:
- 已完成阶段 1 和阶段 2
- 已获得用户对计划的确认
- 然后才能开始提取
重要:提取时必须使用子 Agent(Task 工具)。每个主题使用一个子 Agent,每个子 Agent 为该主题创建所有文件。
阶段 3 的主 Agent 指示
必须遵循以下步骤:
- 每个主题使用一个子 Agent——每个子 Agent 只读取一次书籍章节,并为该主题创建所有文件(knowledge.md、rules.md、examples.md,以及任何可选文件)
- 填写以下模板,准备子 Agent 提示词,使用具体的值替换模板内容
- 根据阶段 1 的分析(含行号的目录)计算行范围
- 创建完整的提示词——不得留有未填写的占位符
- 并行启动不同主题的子 Agent
- 所有子 Agent 完成后,更新 progress.md
子 Agent 提示词模板
重要:复制此模板,并在启动子 Agent 前将所有方括号占位符替换为实际值。
## Task: Extract [TOPIC] Knowledge Base
You are extracting knowledge from a book section to create a complete topic reference.
### Prerequisites - Read These Files First:
1. `skills/skill-from-book/references/file-templates.md` - Templates for all file types
2. `skills/skill-from-book/references/extraction-patterns.md` - Extraction rules
### Source Material:
- **Book**: [BOOK_PATH]
- **Section**: [CHAPTER/SECTION_NAME]
- **Line range**: Read with offset=[START_LINE], limit=[LINE_COUNT]
### Output Directory: [OUTPUT_TOPIC_PATH]
### Files to Create (in this order):
#### 1. knowledge.md (REQUIRED)
Core concepts, definitions, and foundational understanding.
- Extract: definitions, terminology, key concepts, how things relate
- Use the "Knowledge File" template
#### 2. rules.md (REQUIRED)
Specific guidelines, do's and don'ts.
- Extract: explicit rules, guidelines, best practices, exceptions
- Use the "Rules File" template
#### 3. examples.md (REQUIRED)
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]
[e.g., patterns.md, smells.md, checklist.md - specify what each should contain]
### Your Instructions:
1. Read the two prerequisite files FIRST to understand templates and extraction rules
2. Read the book section ONCE using: offset=[START_LINE], limit=[LINE_COUNT]
3. From that single read, extract content for ALL files listed above
4. 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
5. Create files in order: knowledge.md → rules.md → examples.md → optional files
### Content Guidance:
[SPECIFIC_GUIDANCE - what to focus on, what to skip]
### Language Conversion (if applicable):
- Source: [SOURCE_LANG or "N/A"]
- Target: [TARGET_LANG or "N/A"]
- Convert ALL code examples to target language
示例:已填写的子 Agent 提示词
## Task: Extract Functions Knowledge Base
You are extracting knowledge from a book section to create a complete topic reference.
### Prerequisites - Read These Files First:
1. `skills/skill-from-book/references/file-templates.md` - Templates for all file types
2. `skills/skill-from-book/references/extraction-patterns.md` - Extraction rules
### Source Material:
- **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
### Files to Create (in this order):
#### 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
#### 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
#### 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
#### 4. checklist.md (OPTIONAL)
Quick reference for reviewing functions.
- Create a checklist from the rules for code review
### Your Instructions:
1. Read the two prerequisite files FIRST to understand templates and extraction rules
2. Read the book section ONCE using: offset=450, limit=380
3. From that single read, extract content for ALL files listed above
4. 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
5. Create files in order: knowledge.md → rules.md → examples.md → checklist.md
### Content Guidance:
Focus on practical, actionable content. Skip author anecdotes and historical context. Prioritize rules that are universally applicable.
### Language Conversion:
- Source: Java
- Target: TypeScript
- Convert ALL code examples to TypeScript
并行提取策略
并行运行:不同主题(每个主题由一个子 Agent 处理)
- 子 Agent 1:functions/(第 3 章)
- 子 Agent 2:naming/(第 2 章)
- 子 Agent 3:classes/(第 10 章)
必须等待:guidelines.md 和 workflows 的创建必须等所有主题子 Agent 完成后才能开始
启动子 Agent 前的主 Agent 检查清单
- 已将所有占位符替换为实际值
- 已根据第 1 阶段的 TOC 计算行偏移量和限制
- 输出目录路径符合命名约定
- 已列出所有必需文件(knowledge.md、rules.md、examples.md)
- 已明确指定可选文件及其内容要求
- 内容要求针对当前主题
- 已指定需要时的语言转换
第 4 阶段:创建指南
停止!继续之前,你必须:
- 完成第 3 阶段的所有提取任务
- 完整阅读
references/guidelines-template.md - 然后才能继续创建指南
第 4 阶段步骤:
创建 guidelines.md,建立以下对应关系:
- 任务 → 相关文件(和工作流)
- 代码元素 → 相关文件
- 症状/问题 → 相关文件
- 常见场景的决策树
第 5 阶段:工作流提案
停止!继续之前,你必须:
- 完成第 4 阶段(指南)
- 完整阅读
references/workflow-templates.md - 然后才能继续提出工作流
第 5 阶段步骤:
-
根据书籍内容识别潜在工作流
查找:
- 流程描述(“如何执行 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 顶部添加“工作流”部分:
## Workflows | Task | Workflow | |------|----------| | [task description] | `workflows/[name].md` |
第 6 阶段:最终整理
第 6 阶段步骤:
- 检查所有文件的一致性
- 更新 progress.md(标记为已完成)
- 使用示例查询进行测试
- 根据测试结果完善指南
- 请用户审核最终技能
核心原则
粒度
- 每个文件只包含一个概念
- 文件长度应为 50–200 行
- 将大型主题拆分为子主题
上下文效率
- 只加载所需内容
- 指南文件负责指引到具体知识
- 避免文件间内容重复
可操作性
- 规则优于解释
- 示例优于理论
- 使用检查清单以便快速查阅
- 对可重复执行的任务使用工作流
适合子 Agent 协作
- 每项提取任务都是独立的
- 输入/输出规范清晰
- 可并行运行多项提取任务
文件命名约定
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 reference
进度跟踪
始终维护 progress.md:
# [Skill Name] - Creation Progress
## Status: [X/Y files complete]
## Phase 1: Foundation
- [x] SKILL.md
- [x] progress.md
- [ ] guidelines.md
## Phase 2: Workflows
- [ ] workflows/[name].md
- [ ] workflows/[name].md
## Phase 3: [Category Name]
- [ ] category/knowledge.md # REQUIRED
- [ ] category/rules.md # REQUIRED
- [ ] category/examples.md # REQUIRED
- [ ] category/patterns.md # Optional
...
快速开始
- 用户提供书籍 Markdown 文件路径
- 暂时不要阅读书籍内容
- 运行第 1 阶段:分析(仅提取目录)
- 获取用户确认
- 运行第 2 阶段:规划
- 获取用户确认
- 运行第 3 阶段:提取(使用子 Agent)
- 运行第 4 阶段:创建指南
- 运行第 5 阶段:提出工作流(获取用户选择)
- 运行第 6 阶段:最终整理