This skill generates a structured chapter outline for intelligent textbooks by analyzing course descriptions, learning graphs, and concept dependencies. Use this skill after the learning graph has been created and before generating chapter content, to design an optimal chapter structure that respects concept dependencies and distributes content evenly across all of the chapter in a book.
Version: 1.1.2
v1.1.2 — The "Concepts Covered" table's second column is now headed Concept Impact Score instead of the abbreviated CIS Score, which redundantly repeated "Score" (CIS already stands for Concept Impact Score). Purely a column-header rename -- the underlying cis field, its computation, and every other behavior are unchanged. Applies to newly generated chapters; a book with chapters already generated under an earlier skill version keeps the old header on those files until its own chapter-generation script or table is updated separately.
v1.1.1 — Step 4.6's completion message now always includes a strong recommendation to create a learning mascot (via book-installer's learning-mascot guide) before running chapter-content-generator. A mascot designed up front gets placed into every chapter as content is written; adding one after dozens of chapters already exist means retrofitting each one instead. Also stated as a standing rule in the Notes section. No change to chapter design or file structure.
v1.1.0 — Version is now tracked in the SKILL.md frontmatter as metadata.ibook.version. It lives under metadata: rather than a bare version: key because strict packaging validation rejects any frontmatter key outside the six spec fields, which would block the skill from claude.ai, the Skills API, and package_skill.py. No behavioural change.
v1.0.0 — BREAKING: First tracked version number for this skill. Step 1.4a no longer computes its own "dependents count" from the edge list — it now reads the pre-computed Concept Impact Score (CIS) directly from each node's cis field in learning-graph.json (added by learning-graph-generator v1.06+). CIS is a strictly better importance signal than raw dependents count: it captures transitive impact (a concept with few direct dependents can still be highly foundational if those dependents themselves have many dependents), which plain dependents-count undercounts. The "Concepts Covered" section in each generated chapter's index.md (Step 4.4) is now a markdown table with Concept and CIS Score columns, replacing the old numbered list with a (N dependents) suffix. Requires learning-graph.json to have been regenerated with learning-graph-generator v1.06+ (nodes missing a cis field will read as cis=1, the minimum — check the console output when loading the graph and regenerate if every concept shows 1).
This skill creates a comprehensive chapter structure for intelligent textbooks by analyzing the course description, learning graph, and concept taxonomy. It designs an optimal chapter outline that ensures all concepts are covered exactly once, respects dependency relationships, and distributes content appropriately across chapters. This task is run serially after the learning graph generation.
Use this skill when:
Prerequisites:
/docs/course-description.md must exist/docs/learning-graph/learning-graph.json must exist with ~200 conceptsDo NOT use this skill if:
learning-graph-generator first)This skill follows a four-step sequential workflow with user approval before generating files.
Before designing chapters, analyze the following resources:
Read /docs/course-description.md to understand:
Read /docs/learning-graph/learning-graph.json to extract:
!!! info "Learning Graph = Concept Dependency Graph (a DAG)" A learning graph is a Concept Dependency Graph -- a directed acyclic graph (DAG) where each edge represents a "depends on" relationship. We chose the dependency direction (edges point FROM a concept TO the concepts it depends on) because this aligns with standard graph theory algorithms for topological sorting, cycle detection, and transitive reduction.
Some learning management systems use an alternative called an **enablement graph**,
where edges point in the opposite direction (FROM prerequisite TO the concepts it
enables). The enablement direction is more intuitive for some teachers ("learning
Ecology enables you to learn Ecosystems"), but it is less natural for graph
algorithms. This project uses the dependency direction exclusively.
!!! danger "CRITICAL: Edge Direction in learning-graph.json" In the vis-network JSON format, edges point FROM dependent TO prerequisite (the dependency direction).
- Edge `{from: 5, to: 1}` means "Biodiversity (5) depends on Ecology (1)"
- It does NOT mean "Ecology leads to Biodiversity" (that would be the enablement direction)
**To build a prerequisite map:**
```python
prereqs = defaultdict(set)
for edge in data['edges']:
prereqs[edge['from']].add(edge['to']) # CORRECT: dependency direction
```
**NEVER use** `prereqs[edge['to']].add(edge['from'])` -- this accidentally
converts to the enablement direction, inverting ALL dependencies and silently
producing invalid chapter orderings. This bug wastes significant tokens and
requires a complete redesign.
Validate that:
Before designing any chapters, verify the edge direction is correct:
prereqs[edge['from']].add(edge['to'])# Quick validation
foundational = [n for n in data['nodes'] if n['id'] not in prereqs]
print(f"Foundational ({len(foundational)}):")
for n in foundational:
print(f" {n['id']}: {n['label']}")
# These should be simple/introductory. If you see "Sustainability",
# "Climate Change", etc., the edge direction is inverted.
Do NOT proceed to chapter design until this check passes.
Read /docs/learning-graph/concept-taxonomy.md (if it exists) to understand:
Analyze the data to identify:
Every node in learning-graph.json carries a pre-computed cis field
(added by learning-graph-generator v1.06+) -- the Concept Impact Score, a
PageRank-style recursive importance measure: CIS(x) = 1 + sum(CIS(d) for d in direct dependents of x). Unlike a simple dependents count (direct
dependents only), CIS captures transitive impact: a concept with only 1-2
direct dependents can still have a very high CIS if those dependents
themselves have many dependents. This is why CIS, not raw dependents count,
now drives per-concept word-count and non-text-element targets in
chapter-content-generator.
# cis[concept_id] = the concept's pre-computed Concept Impact Score
cis = {n['id']: n.get('cis', 1) for n in data['nodes']}
# A concept with cis[cid] == 1 is a terminal concept (nothing transitively
# builds on it). A concept with a high cis[cid] is a foundational "hub"
# concept -- large amounts of the book's content ultimately rest on it,
# even if its direct dependents count is small.
Sanity check: if every concept shows cis == 1, learning-graph.json
predates learning-graph-generator v1.06 and needs to be regenerated before
proceeding -- do not fall back to computing your own dependents count.
Carry this cis map forward into Step 4 -- it is placed alongside each
concept name in every chapter's "Concepts Covered" table.
Design an optimal chapter structure following these principles:
Choose the appropriate number of chapters (6-20) based on:
Guidelines:
Design chapter assignments that satisfy these requirements:
CRITICAL REQUIREMENTS:
OPTIMIZATION GOALS:
For each chapter, create a title that:
Examples:
For each chapter, write a single sentence (20-40 words) that:
Before creating any files, present the chapter design to the user in this format:
## Proposed Chapter Structure
I've designed a [number]-chapter structure for your textbook covering [total] concepts.
### Chapters:
1. **[Chapter Title]** ([X] concepts)
[One sentence summary]
2. **[Chapter Title]** ([X] concepts)
[One sentence summary]
[... continue for all chapters ...]
### Design Challenges & Solutions:
[Discuss any challenges encountered and how the design addresses them, such as:]
- **Challenge**: Concept X has 15 dependencies, making placement difficult
**Solution**: Placed in Chapter 8 after all prerequisites are covered in Chapters 1-7
- **Challenge**: Taxonomy category Y contains 45 concepts
**Solution**: Split across Chapters 3, 6, and 9 to maintain logical flow
[... other challenges ...]
### Statistics:
- Total chapters: [X]
- Average concepts per chapter: [X.X]
- Range: [min]-[max] concepts per chapter
- All [total] concepts covered: ✓
- All dependencies respected: ✓
After presenting the design, ask:
Do you approve this chapter structure? (y/n)
If no, please specify what changes you'd like:
- Different number of chapters?
- Specific concepts moved to different chapters?
- Chapter titles revised?
- Different grouping strategy?
If the user says "no" or requests changes:
If the user says "yes":
Once the user approves the design, create the chapter structure:
For each chapter, create a URL-friendly path name:
Rules:
Examples:
"Introduction to Graph Theory Fundamentals" → "intro-to-graph-theory"
"Binary Trees and Tree Traversal Algorithms" → "binary-trees-traversal"
"Advanced Topics in Network Flow Optimization" → "advanced-network-flow"
Create the following directory structure:
/docs/chapters/
├── index.md
├── 01-[url-path-name]/
│ └── index.md
├── 02-[url-path-name]/
│ └── index.md
├── 03-[url-path-name]/
│ └── index.md
[... continue for all chapters ...]
Implementation:
mkdir -p /docs/chapters
mkdir -p /docs/chapters/01-[url-path-name]
mkdir -p /docs/chapters/02-[url-path-name]
# ... continue for all chapters
Create /docs/chapters/index.md with:
# Chapters
This textbook is organized into [X] chapters covering [Y] concepts.
## Chapter Overview
1. [Chapter 1 Title](01-[url-path-name]/index.md) - [One sentence summary]
2. [Chapter 2 Title](02-[url-path-name]/index.md) - [One sentence summary]
[... continue for all chapters ...]
## How to Use This Textbook
[Add 2-3 sentences about how readers should progress through the chapters, noting that dependencies are respected and concepts build on each other]
---
**Note:** Each chapter includes a list of concepts covered. Make sure to complete prerequisites before moving to advanced chapters.
For each chapter, create /docs/chapters/[XX]-[url-path-name]/index.md with this structure:
# [Chapter Title]
## Summary
[Write a 2-4 sentence summary of what the chapter covers, expanding on the one-sentence version from the design. Include:]
- Main topics and themes
- How this chapter fits in the learning progression
- What students will be able to do after completing this chapter
## Concepts Covered
This chapter covers the following [X] concepts from the learning graph:
| Concept | Concept Impact Score |
|---------|-----------------------|
| [Concept Name 1] | 187 |
| [Concept Name 2] | 1 |
| [Concept Name 3] | 42 |
[... continue for all concepts in this chapter, in pedagogical order ...]
## Prerequisites
[If this is not the first chapter, list which previous chapters should be completed first:]
This chapter builds on concepts from:
- [Chapter X: Chapter Title](../[XX]-[url-path-name]/index.md)
- [Chapter Y: Chapter Title](../[YY]-[url-path-name]/index.md)
[If this is the first chapter or has no prerequisites within the book:]
This chapter assumes only the prerequisites listed in the [course description](../../course-description.md).
---
TODO: Generate Chapter Content
Important formatting notes:
Concept and Concept Impact Score
columns (not a numbered list) -- one row per concept, in the same
pedagogical order used elsewhere in this chapter, using the cis map
read in Step 1.4a. Always include the blank line before the table
(MkDocs requirement).After creating all chapter files, add the chapters to the Chapters: section of
mkdocs.yml. Follow the canonical nav-editing rules (read-before-write,
serialize edits, only touch your section, number-only chapter labels) in
$BK_HOME/skills/book-installer/references/mkdocs-nav-editing.md.
- Chapters:
- List of Chapters: chapters/index.md
- 1. [Chapter 1 Title]: chapters/01-[url-path-name]/index.md
- 2. [Chapter 2 Title]: chapters/02-[url-path-name]/index.md
# ... continue for all chapters
After all files are created, inform the user. Always include the mascot recommendation below verbatim — do not omit it or make it conditional on whether a mascot appears to already exist:
✅ Chapter structure generated successfully!
Created:
- chapters/index.md (main chapter overview)
- [X] chapter directories with index files
- Updated mkdocs.yml navigation
Strong recommendation: create a learning mascot before generating any
chapter content. Run the `book-installer` skill's learning-mascot guide (or
just ask to "add a learning mascot") now. The `chapter-content-generator`
skill places mascot admonitions as it writes each chapter, and retrofitting
a mascot into chapters that already exist is far more expensive than
designing one first.
Next steps:
1. Create a learning mascot (strongly recommended, see above) — run `book-installer`, then the learning mascot guide
2. Review the chapter structure: `mkdocs serve`
3. Navigate to the Chapters section to see all chapter outlines
4. Use the chapter content generation skill (when ready) to populate each chapter
5. Each chapter index.md has "TODO: Generate Chapter Content" as a placeholder
Statistics:
- Total chapters: [X]
- Total concepts assigned: [Y]
- All dependencies respected: ✓
Critical: The chapter sequence must respect the DAG structure:
Mandatory validation before presenting to user:
Run this strict check and achieve zero violations before proceeding to Step 3:
# Build prereqs: from=dependent, to=prerequisite (NEVER invert this)
prereqs = defaultdict(set)
for e in data['edges']:
prereqs[e['from']].add(e['to'])
# Map each concept to its chapter index
chapter_map = {}
for i, (title, cids) in enumerate(chapters):
for cid in cids:
chapter_map[cid] = i
# Check: every prerequisite must be in same or earlier chapter
violations = []
for i, (title, cids) in enumerate(chapters):
for cid in cids:
for dep in prereqs.get(cid, set()):
if dep in chapter_map and chapter_map[dep] > i:
violations.append(f"{nodes[cid]} ch{i+1} needs {nodes[dep]} ch{chapter_map[dep]+1}")
assert len(violations) == 0, f"{len(violations)} dependency violations found"
Do NOT present a chapter design with any violations to the user. Fix all violations first by moving concepts between chapters or reordering chapters.
Aim for balanced chapter sizes:
If a chapter is too large, consider splitting it into two chapters. If a chapter is too small, consider merging it with a related chapter.
Structure chapters to support learning:
Within each chapter, order concepts from:
Consider student cognitive load:
Problem: A single taxonomy category contains 40+ concepts.
Solutions:
Problem: Concept Z depends on Y, which depends on X, which depends on W... (5+ levels deep).
Solutions:
Problem: Some concepts have no dependents (nothing builds on them).
Solutions:
Problem: A natural concept cluster (e.g., 5 tree traversal algorithms) is too large for one chapter but splitting it feels wrong.
Solutions:
Problem: The dependency structure forces 30 concepts into Chapter 2 and only 8 concepts into Chapter 7.
Solutions:
Before finalizing the chapter structure, verify:
Concept and Concept Impact Score columns (not a numbered list)User request: "Create chapters for my Graph Theory textbook"
Skill workflow:
npx skills add dmccreary/book-chapter-generator下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Category:science-education