| name | book-pdf |
| description | Generate and verify a polished PDF containing the full current manuscript of a book in book.db, with title page, ordered parts and chapters, page numbers, metadata, word count, and included text-version IDs. Use for PDF, print copy, reading copy, export book, full manuscript, or compile current version requests. Do not use to edit or approve prose. |
Book PDF
Create a disposable, reproducible reading snapshot from the authoritative current manuscript in book.db. Never edit manuscript prose merely to improve the export.
Use the bundled deterministic helper (path shown for Claude Code; under Codex the same file resolves at .agents/skills/book-pdf/scripts/export_book_pdf.py via a symlink to .claude/skills):
python .claude/skills/book-pdf/scripts/export_book_pdf.py \
--db book.db \
--book book.01 \
--out exports/book-01-current.pdf
The script requires Python and ReportLab. Prefer an existing installation. If ReportLab is absent and environment policy permits package installation, install only that dependency in the active environment; do not add an application framework or permanent build system.
Select the book
Use the book named by the human. Otherwise:
- select the only active book containing current manuscript text;
- when several qualify, use the one with the most recently edited manuscript and report the choice;
- when no manuscript exists, explain that there is nothing to export and identify the nearest draftable unit.
Use --list to inspect exportable books:
python .claude/skills/book-pdf/scripts/export_book_pdf.py --db book.db --list
Export rules
- Export current
manuscript versions, whether draft or approved, because the request is for the current book snapshot.
- Preserve tree order.
- Use book, part, and chapter headings.
- Prefer the smallest current manuscript units and avoid duplicating aggregate chapter/book text when descendant units already contain manuscript text.
- Omit rejected and archived nodes.
- Insert clean scene breaks without exposing internal scene codes.
- Include a title page, author when available, readable typography, sensible page margins, and page numbers.
- Put the output under
exports/ unless the human specifies another path.
- Do not write export-only edits back into
book.db.
Optional flags:
--author "Author Name"
--page-size 6x9|a5|letter
--show-scene-titles
--approved-only
Verification loop
After generation:
- Confirm the script returned
status: ok, a nonzero word count, and the included text-version IDs expected for the book.
- Inspect PDF metadata and page count with
pdfinfo or pypdf when available.
- Render at least the first manuscript page, one middle page, and the final page using
pdftoppm, PyMuPDF, or another available renderer.
- Inspect the renders for clipped text, blank pages, broken glyphs, repeated content, missing chapters, bad scene breaks, and page-number collisions.
- Correct export code or formatting and regenerate if verification fails. Do not alter prose to hide an exporter defect.
- Remove temporary render files from the deliverable directory; leave the final PDF.
For a very short manuscript, inspect every page. For a full novel, also spot-check every chapter opening.
Report
Return:
- the PDF path;
- selected book code/title;
- page and word counts;
- included text-version IDs;
- whether the snapshot includes draft material;
- any missing front matter or metadata that did not block export.
Definition of done
A readable PDF exists at the requested path, its contents match the current ordered manuscript without duplication, representative pages have been visually verified, and the human knows exactly which versions were included.