Use when generating a table of contents, validating metadata, or exploring book content. Triggers on "generate TOC", "table of contents", "validate frontmatter", "book chat".
Guide for book-level operations: table of contents generation, metadata validation, and conversational content exploration.
When regenerating the table of contents:
Step 1: Scan Chapter Files
Glob: chapters/**/*.md
Glob: appendices/**/*.md
Step 2: Extract Frontmatter
For each file, parse YAML frontmatter:
title - entry titlepart - numberpart_title - part namechapter - numbersection - 0 for index, 1+ for sectionsorder - sort key (part.chapter.section)Step 3: Sort and Group
order field (ascending)part_title to create part sectionschapter numberStep 4: Generate Markdown
# Table of Contents
## Part 1: Foundations
### Chapter 1: Foundations
- [Foundations](chapters/1-foundations/_index.md)
- [Twelve Leverage Points](chapters/1-foundations/1-twelve-leverage-points.md)
### Chapter 2: Prompt
- [Prompt](chapters/2-prompt/_index.md)
...
Step 5: Write Output
Write to: TABLE_OF_CONTENTS.md (overwrites existing)
Step 6: Report
### TOC Generation Complete
Generated from {file_count} files across {part_count} parts.
**Output:** TABLE_OF_CONTENTS.md
**Chapters:** {count}
**Sections:** {count}
When exploring book content conversationally:
Step 1: Parse Input
Step 2: Determine Scope
Step 3a: Direct Response
For straightforward questions:
Grep: {key concepts}Step 3b: Complex Exploration
For relationship mapping:
Step 4: Format Response
The book addresses this through [concept] in Chapter X...
From `chapters/X/Y.md`:
> [relevant quote or paraphrase]
This connects to [related concept] because [explanation].
Want to explore [specific angle]? I can also map how this relates to [other topics].
Grounding Rules:
When validating frontmatter across book:
Step 1: Define Scope
Step 2: Scan Files
Glob: chapters/**/*.md
Glob: appendices/**/*.md
Step 3: Check Each File
Required Fields:
title - present, non-emptypart - numericpart_title - matches part number consistentlychapter - numericsection - numeric (0 for index, 1+ for sections)order - format X.Y.Z, matches part.chapter.sectionOptional Fields (if present):
description - non-emptycreated - YYYY-MM-DD formatlast_updated - YYYY-MM-DD, >= createdtags - array, no duplicatesstatus - seedling | growing | mature | evergreenConsistency Checks:
part_titleorder matches part.chapter.section pattern_index.mdStep 4: Categorize Issues
Critical:
Warnings:
Info:
Step 5: Report
### Metadata Validation Report
**Scope:** {description}
**Files Checked:** {count}
#### Critical Issues ({count})
| File | Issue | Fix Needed |
|------|-------|------------|
| {path} | Missing 'order' | Add order: X.Y.Z |
#### Warnings ({count})
| File | Issue | Recommendation |
|------|-------|----------------|
| {path} | Part title mismatch | Standardize to "{title}" |
#### Summary
- Valid: {count} files
- Warnings: {count} files
- Critical: {count} files
TOC Generation Algorithm
order field, never filenameChat Grounding Rules
Validation Priority
File Naming Conventions
_index.md - Chapter introductions (section: 0)_questions.md - Question scaffolding (skip in TOC)1-topic.md - Numbered sectionsRequest: "Regenerate table of contents"
Execute:
- Glob chapters/ and appendices/
- Extract frontmatter from 45 files
- Sort by order field
- Generate markdown structure
Output:
- TABLE_OF_CONTENTS.md updated
- 4 parts, 9 chapters, 32 sections
- 2 files skipped (missing frontmatter)
Request: "How does the book cover prompt caching?"
Execute:
- Grep: "prompt caching", "cache"
- Find mentions in chapters 4 and 7
- Read relevant sections
Response:
"Chapter 4 (Context) discusses prompt caching in the strategies section...
From `chapters/4-context/2-context-strategies.md`:
> Caching system prompts reduces latency significantly...
The Practices chapter also touches on this from a cost perspective.
Want me to map all the performance-related content?"
Request: "Validate frontmatter for chapter 6"
Execute:
- Glob: chapters/6-patterns/*.md
- Check 4 files
Findings:
- 1 warning: inconsistent part_title
- 1 info: missing status field
- 2 valid
Report with fix recommendations
Request: "What does the book say about fine-tuning?"
Execute:
- Grep: "fine-tuning", "fine tuning"
- No direct coverage found
- Check _questions.md files
Response:
"The book doesn't currently cover fine-tuning in depth.
Chapter 3 (Model) has a placeholder question about when fine-tuning beats prompting.
This could be a good topic to capture. Want to explore related model behavior content instead?"
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer