|
1 | 1 | --- |
2 | 2 | name: mdbook |
3 | | -description: Use this skill when creating, editing, validating, or converting KDP-ready book manuscripts with mdBook as the source workflow, or when working with mdBook documentation projects, including book.toml, SUMMARY.md, mdbook init/build/serve/watch/test/clean, Markdown formatting, mdBook configuration, themes, preprocessors, renderers/backends, MathJax, search, custom themes, CI deployment, GitHub Pages, GitLab Pages, or Rust mdBook developer APIs. |
| 3 | +description: Create, edit, validate, and publish mdBook projects or mdBook-based KDP manuscripts. Use for book.toml, SUMMARY.md, themes, preprocessors, CI, and manuscript conversion. |
4 | 4 | --- |
5 | 5 |
|
6 | 6 | # mdBook |
7 | 7 |
|
8 | | -Use this skill to create KDP-ready manuscripts with mdBook as the source format and to create, configure, build, theme, validate, and deploy mdBook projects. |
| 8 | +Use mdBook as the source workflow for documentation books and KDP manuscripts. |
9 | 9 |
|
10 | 10 | ## Workflow |
11 | 11 |
|
12 | | -1. Identify the mdBook topic from the user's request. |
13 | | -2. Read the matching reference file before giving detailed guidance or editing files. |
14 | | -3. Use correct TOML for `book.toml` and correct Markdown structure for `SUMMARY.md`. |
15 | | -4. Prefer the local reference files because they mirror the official mdBook guide. |
16 | | -5. Use `scripts/generate-references.sh` only when the bundled references need to be refreshed from upstream mdBook docs. |
17 | | -6. When the references are insufficient and current docs are required, fetch the matching file from `https://raw.githubusercontent.com/rust-lang/mdBook/master/guide/src/<path>.md`. |
18 | | - |
19 | | -## KDP Manuscript Workflow |
20 | | - |
21 | | -Use mdBook as the manuscript source when creating Kindle or print-ready books: |
22 | | - |
23 | | -1. Keep manuscript source in Markdown under `src/`. |
24 | | -2. Use `src/SUMMARY.md` as the canonical table of contents and chapter order. |
25 | | -3. Use `book.toml` for title, author, language, source directory, HTML output, and any preprocessing. |
26 | | -4. Build with `mdbook build` and inspect the generated `book/` output before conversion. |
27 | | -5. Convert or package the generated content into the requested KDP target, usually EPUB for Kindle and PDF for print. |
28 | | -6. Validate links, images, chapter breaks, metadata, fonts, and table of contents before delivery. |
29 | | - |
30 | | -### KDP Structure |
31 | | - |
32 | | -Use a simple, review-friendly book structure unless the user provides a manuscript-specific structure: |
33 | | - |
34 | | -1. Title page |
35 | | -2. Copyright page |
36 | | -3. Table of contents, optional for print |
37 | | -4. Preface or introduction, optional |
38 | | -5. Chapters |
39 | | -6. About the author |
40 | | -7. Additional resources, optional |
41 | | - |
42 | | -### KDP Output Guidance |
43 | | - |
44 | | -- Prefer EPUB for Kindle eBooks. |
45 | | -- Prefer PDF for print books. |
46 | | -- Keep heading hierarchy consistent. |
47 | | -- Use one clear book title and chapter-level headings. |
48 | | -- Use relative image paths. |
49 | | -- Use high-resolution images for print, preferably 300 DPI. |
50 | | -- Avoid excessive styling that may fail KDP review or convert poorly. |
51 | | -- Embed fonts for print PDFs when required. |
52 | | -- Do not include crop marks unless specifically requested. |
53 | | - |
54 | | -### KDP Validation Checklist |
55 | | - |
56 | | -- Metadata is complete. |
57 | | -- Cover dimensions match the target format. |
58 | | -- Table of contents links work. |
59 | | -- Internal and external links are not broken. |
60 | | -- Images are present and appropriate resolution. |
61 | | -- EPUB passes validation when EPUB is requested. |
62 | | -- PDF pages render correctly when PDF is requested. |
63 | | -- Fonts are embedded where required. |
64 | | -- Chapter breaks are correct. |
65 | | -- Final upload notes call out any remaining KDP risks. |
66 | | - |
67 | | -## References |
68 | | - |
69 | | -- [Overview](references/overview.md): mdBook purpose and general introduction. |
70 | | -- [Installation](references/installation.md): installing mdBook with Cargo, prebuilt binaries, or source builds. |
71 | | -- [Creating a Book](references/creating-a-book.md): `mdbook init`, project layout, and first-book workflow. |
72 | | -- [Reading Books](references/reading-books.md): navigating generated mdBook output. |
73 | | -- [CLI](references/cli.md): `init`, `build`, `watch`, `serve`, `test`, `clean`, and completions. |
74 | | -- [SUMMARY Format](references/summary-format.md): `src/SUMMARY.md` syntax and nesting. |
75 | | -- [Markdown](references/markdown.md): supported Markdown syntax and extensions. |
76 | | -- [mdBook Specific](references/mdbook-specific.md): hiding code lines, including files, playgrounds, and mdBook-only features. |
77 | | -- [MathJax](references/mathjax.md): math rendering support. |
78 | | -- [Configuration](references/configuration.md): `book.toml`, preprocessors, renderers, environment variables, and output options. |
79 | | -- [Theme](references/theme.md): custom themes, `index.hbs`, syntax highlighting, editor support, and theme files. |
80 | | -- [Continuous Integration](references/continuous-integration.md): GitHub Actions, GitLab CI, and deployment patterns. |
81 | | -- [For Developers](references/for-developers.md): custom preprocessors, renderers/backends, and Rust API details. |
82 | | - |
83 | | -## Scripts |
84 | | - |
85 | | -- [generate-references.sh](scripts/generate-references.sh): refresh the `references/` files from the upstream mdBook guide. Run it from the skill directory. |
86 | | - |
87 | | -## Quick Commands |
88 | | - |
89 | | -Create and preview a book: |
90 | | - |
91 | | -```bash |
92 | | -mdbook init my-book |
93 | | -cd my-book |
94 | | -mdbook serve --open |
95 | | -``` |
96 | | - |
97 | | -Build and validate: |
98 | | - |
99 | | -```bash |
100 | | -mdbook build |
101 | | -mdbook serve |
102 | | -mdbook watch |
103 | | -mdbook test |
104 | | -mdbook clean |
105 | | -``` |
106 | | - |
107 | | -## Project Layout |
108 | | - |
109 | | -```text |
110 | | -my-book/ |
111 | | -├── book.toml |
112 | | -├── src/ |
113 | | -│ ├── SUMMARY.md |
114 | | -│ ├── chapter_1.md |
115 | | -│ └── chapter_2/ |
116 | | -│ ├── section_1.md |
117 | | -│ └── section_2.md |
118 | | -└── book/ |
119 | | -``` |
120 | | - |
121 | | -## SUMMARY.md Basics |
122 | | - |
123 | | -```markdown |
124 | | -# Summary |
125 | | - |
126 | | -[Introduction](README.md) |
127 | | - |
128 | | -- [Chapter 1](chapter_1.md) |
129 | | - - [Section 1.1](chapter_1/section_1.md) |
130 | | -- [Chapter 2](chapter_2.md) |
131 | | - |
132 | | ---- |
133 | | - |
134 | | -[Appendix](appendix.md) |
135 | | -``` |
136 | | - |
137 | | -## book.toml Basics |
138 | | - |
139 | | -```toml |
140 | | -[book] |
141 | | -title = "My Book" |
142 | | -authors = ["Author Name"] |
143 | | -language = "en" |
144 | | -src = "src" |
145 | | - |
146 | | -[build] |
147 | | -build-dir = "book" |
148 | | - |
149 | | -[output.html] |
150 | | -default-theme = "light" |
151 | | -preferred-dark-theme = "ayu" |
152 | | -git-repository-url = "https://github.com/user/repo" |
153 | | -``` |
154 | | - |
155 | | -## Topic Guidance |
156 | | - |
157 | | -- For setup or install questions, read [Installation](references/installation.md) and [Creating a Book](references/creating-a-book.md). |
158 | | -- For command behavior, flags, or troubleshooting build commands, read [CLI](references/cli.md). |
159 | | -- For table of contents or chapter structure issues, read [SUMMARY Format](references/summary-format.md). |
160 | | -- For Markdown rendering, includes, hidden lines, playgrounds, or code blocks, read [Markdown](references/markdown.md) and [mdBook Specific](references/mdbook-specific.md). |
161 | | -- For `book.toml`, preprocessors, renderers, search, output options, or environment variables, read [Configuration](references/configuration.md). |
162 | | -- For custom CSS, JavaScript, templates, highlighting, or editor integration, read [Theme](references/theme.md). |
163 | | -- For MathJax or equation rendering, read [MathJax](references/mathjax.md). |
164 | | -- For GitHub Pages, GitLab Pages, or automated builds, read [Continuous Integration](references/continuous-integration.md). |
165 | | -- For custom preprocessors or renderers/backends, read [For Developers](references/for-developers.md). |
| 12 | +1. Inspect the repository instructions, `book.toml`, `src/SUMMARY.md`, source |
| 13 | + tree, preprocessors, custom theme, and deployment configuration. |
| 14 | +2. Determine whether the task concerns ordinary mdBook output, custom tooling, |
| 15 | + deployment, or a KDP manuscript, then read only the matching references. |
| 16 | +3. Preserve the existing chapter hierarchy, URLs, output contracts, and pinned |
| 17 | + mdBook version unless the task requires changing them. |
| 18 | +4. Make the smallest source or configuration change and use valid TOML and |
| 19 | + mdBook Markdown. |
| 20 | +5. Build the requested outputs and inspect representative rendered pages or |
| 21 | + publication artifacts rather than relying only on command success. |
| 22 | +6. Report exact validation, skipped checks, and remaining publication or |
| 23 | + deployment risks. |
| 24 | + |
| 25 | +## Reference routing |
| 26 | + |
| 27 | +- For KDP ebook or print work, read [references/kdp.md](references/kdp.md). |
| 28 | +- For installation and project creation, read |
| 29 | + [references/installation.md](references/installation.md) and |
| 30 | + [references/creating-a-book.md](references/creating-a-book.md). |
| 31 | +- For CLI behavior, read [references/cli.md](references/cli.md). |
| 32 | +- For chapter structure, read |
| 33 | + [references/summary-format.md](references/summary-format.md). |
| 34 | +- For Markdown, includes, playgrounds, or hidden lines, read |
| 35 | + [references/markdown.md](references/markdown.md) and |
| 36 | + [references/mdbook-specific.md](references/mdbook-specific.md). |
| 37 | +- For `book.toml`, preprocessors, renderers, search, or environment variables, |
| 38 | + read [references/configuration.md](references/configuration.md). |
| 39 | +- For themes, MathJax, CI, or developer APIs, read only the corresponding file: |
| 40 | + [theme](references/theme.md), [MathJax](references/mathjax.md), |
| 41 | + [CI](references/continuous-integration.md), or |
| 42 | + [developer APIs](references/for-developers.md). |
| 43 | + |
| 44 | +The generated references are snapshots of the official mdBook guide. Check the |
| 45 | +version metadata in `references/.wiki-version` against the project or current |
| 46 | +official documentation when behavior may have changed. |
| 47 | + |
| 48 | +## Reference maintenance |
| 49 | + |
| 50 | +Run `scripts/generate-references.sh` from this skill directory to refresh the |
| 51 | +bundled upstream references. The script rewrites relative documentation links |
| 52 | +to versioned official URLs so the flattened reference files remain navigable. |
| 53 | + |
| 54 | +## Validation |
| 55 | + |
| 56 | +- `mdbook build` succeeds for the intended configuration. |
| 57 | +- `mdbook test` passes when the book contains testable Rust examples. |
| 58 | +- The table of contents, internal links, images, search, and changed theme |
| 59 | + behavior work in representative rendered output. |
| 60 | +- CI or hosted output is checked when deployment behavior changed. |
| 61 | +- KDP deliverables pass the format-specific checks in `references/kdp.md`. |
0 commit comments