mcpField
S
skill-from-book

skill-from-book

github.com/bmad-labsAgent 工作流19177 次安装6 天前更新
代码仓库

关于 skill-from-book

Skill From Book 是一项将 Markdown 书籍内容整理为结构化 Claude 技能的指南,面向需要把长篇资料转成可复用知识文件和工作流的人。它规定分阶段分析、规划、提取与审核,并要求提取时使用子代理。

主要功能

  1. 01将书籍拆分为细粒度知识文件
  2. 02规划目录、任务与进度
  3. 03按阶段执行提取流程
  4. 04要求子代理处理主题提取
  5. 05支持工作流提案与最终审核

适用场景

  1. 01把 Markdown 书籍转成 Claude 技能
  2. 02为知识主题规划独立文件
  3. 03从书籍内容提取可复用工作流
  4. 04跟踪多阶段技能制作进度

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/bmad-labs/skills --skill skill-from-book

安装后在 Claude Code 中输入/skill-from-book确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

LICENSE
references/
analysis-guide.md
extraction-patterns.md
file-templates.md
guidelines-template.md
workflow-templates.md
scripts/
init-book-skill.py

详细介绍

Skill From Book

将书籍内容转换为结构化、上下文高效的 Claude 技能。

概述

此技能将引导你把一本书(Markdown 格式)转换为组织良好的技能,其中包括:

  • 细粒度知识文件(每个文件涵盖一个概念)
  • 可重复执行任务的工作流
  • 用例指南(将任务映射到相关文件)
  • 多会话工作的进度跟踪
  • 子 Agent 提取任务

重要指示

必须严格遵循此工作流。不得跳过或调整阶段顺序。

  1. 在开始阶段 1 之前,不要读取书籍 Markdown 文件的内容
  2. 开始相应阶段之前,必须先阅读每个参考文件
  3. 完成每个阶段后才能进入下一阶段
  4. 提取任务必须使用子 Agent
  5. 最终确定之前,必须向用户提出工作流方案

工作流

阶段 1:分析

停!继续之前,必须:

  1. 完整阅读 references/analysis-guide.md
  2. 然后才能继续执行以下步骤

阶段 1 步骤:

  1. 仅提取目录和大纲(不要阅读整本书的内容)

    # Count total lines
    wc -l book.md
    
    # Extract headers/TOC - THIS IS ALL YOU NEED
    grep -E "^#{1,3} " book.md
    
  2. 根据大纲确定知识类别

    • 核心原则/理念
    • 规则和指南
    • 示例(好与坏)
    • 模式和反模式
    • 检查清单和速查表
  3. 定义用例

    • 谁会使用此技能?
    • 他们会执行哪些任务?
    • 他们会提出哪些问题?
  4. 请用户确认确定的类别和用例,然后再继续


阶段 2:规划

停!继续之前,必须:

  1. 完整阅读 references/extraction-patterns.md
  2. 完整阅读 references/file-templates.md
  3. 然后才能继续执行以下步骤

阶段 2 步骤:

  1. 为每个类别设计包含必需文件的文件结构

    每个类别必须包含以下 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
    
  2. 创建 progress.md

    • 列出所有要创建的文件(必需和可选)
    • 按阶段/优先级分组
    • 跟踪完成状态
  3. 规划提取任务

    • 每个知识文件对应一个任务
    • 定义输入(包含行范围的书籍章节)和输出(文件路径)
    • 确定任务之间的依赖关系
  4. 请用户确认文件结构和提取计划,然后再继续


阶段 3:提取

停!继续之前,必须:

  1. 已完成阶段 1 和阶段 2
  2. 已获得用户对计划的确认
  3. 然后才能开始提取

重要:提取时必须使用子 Agent(Task 工具)。每个主题使用一个子 Agent,每个子 Agent 为该主题创建所有文件。

阶段 3 的主 Agent 指示

必须遵循以下步骤:

  1. 每个主题使用一个子 Agent——每个子 Agent 只读取一次书籍章节,并为该主题创建所有文件(knowledge.md、rules.md、examples.md,以及任何可选文件)
  2. 填写以下模板,准备子 Agent 提示词,使用具体的值替换模板内容
  3. 根据阶段 1 的分析(含行号的目录)计算行范围
  4. 创建完整的提示词——不得留有未填写的占位符
  5. 并行启动不同主题的子 Agent
  6. 所有子 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 阶段:创建指南

停止!继续之前,你必须:

  1. 完成第 3 阶段的所有提取任务
  2. 完整阅读 references/guidelines-template.md
  3. 然后才能继续创建指南

第 4 阶段步骤:

创建 guidelines.md,建立以下对应关系:

  • 任务 → 相关文件(和工作流)
  • 代码元素 → 相关文件
  • 症状/问题 → 相关文件
  • 常见场景的决策树

第 5 阶段:工作流提案

停止!继续之前,你必须:

  1. 完成第 4 阶段(指南)
  2. 完整阅读 references/workflow-templates.md
  3. 然后才能继续提出工作流

第 5 阶段步骤:

  1. 根据书籍内容识别潜在工作流

    查找:

    • 流程描述(“如何执行 X”)
    • 重复出现的任务(多次提及的任务)
    • 书中的检查清单
    • 反模式章节(其中暗示了正确流程)
    • 多步骤流程
  2. 向用户提出工作流

    列出潜在工作流:

    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] |
    
  3. 请用户选择要创建的工作流

    Which workflows would you like me to create?
    - Select from the list above
    - Suggest additional workflows
    - Skip workflow creation
    
  4. 创建选定的工作流

    对于每个选定的工作流:

    • 使用 references/workflow-templates.md 中的模板
    • 添加对相关知识文件的交叉引用
    • 为每个步骤添加复选框
    • 明确规定完成条件
  5. 更新 guidelines.md,加入工作流引用

    在 guidelines.md 顶部添加“工作流”部分:

    ## Workflows
    
    | Task | Workflow |
    |------|----------|
    | [task description] | `workflows/[name].md` |
    

第 6 阶段:最终整理

第 6 阶段步骤:

  1. 检查所有文件的一致性
  2. 更新 progress.md(标记为已完成)
  3. 使用示例查询进行测试
  4. 根据测试结果完善指南
  5. 请用户审核最终技能

核心原则

粒度
  • 每个文件只包含一个概念
  • 文件长度应为 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
...

快速开始

  1. 用户提供书籍 Markdown 文件路径
  2. 暂时不要阅读书籍内容
  3. 运行第 1 阶段:分析(仅提取目录)
  4. 获取用户确认
  5. 运行第 2 阶段:规划
  6. 获取用户确认
  7. 运行第 3 阶段:提取(使用子 Agent)
  8. 运行第 4 阶段:创建指南
  9. 运行第 5 阶段:提出工作流(获取用户选择)
  10. 运行第 6 阶段:最终整理

评论

支持 Markdown