Best practices for working on the Harness books repo. Use this skill when editing, restructuring, building, or exporting the books under `book1-claude-code/` and `book2-comparing/`, especially for Honkit, print HTML, Pandoc/XeLaTeX PDF export, build cleanup, TOC issues, naming conventions, and keeping source assets separate from generated outputs.
Use this skill for changes inside this repository's book system.
This repo has two books:
book1-claude-code/book2-comparing/Shared build logic lives in:
tools/book-kit/book_meta.pytools/book-kit/build_pandoc_book.pytools/book-kit/build_print_html.pytools/book-kit/export_book_pdf.pytools/book-kit/export_pdf.pyPrefer changing shared behavior in tools/book-kit/ rather than reintroducing per-book one-off scripts.
Treat book release metadata as structured config, not manuscript text.
release_date in book.json.revision automatically from git in shared tooling instead of maintaining a manual version string.README.md--draft for internal draft exports when you explicitly want today's date plus git revision in the rendered output.assets/ is for source assets only: cover SVG/PDF, hand-maintained source files, reusable static inputs.diagrams/ is for diagram sources and committed generated images used by the books. In this repo, .puml is the source of truth and .png is the embedded artifact.exported/ is for final deliverables only: *.pdf, *-print.html._book/ is a build/cache directory and may be deleted._debug/ and _texdebug/ are disposable debug directories and may be deleted.Do not move exported PDFs into assets/. That mixes source inputs with build outputs and makes cleanup/error analysis harder.
Keep final exports per book under exported/ with stable names:
book1-claude-code/exported/book1-claude-code.pdfbook1-claude-code/exported/book1-claude-code-print.htmlbook2-comparing/exported/book2-comparing.pdfbook2-comparing/exported/book2-comparing-print.htmlIf a new output is added, put it in book.json under outputs.
Do not encode the primary release version only in the output filename. The canonical source of version truth should remain book.json.
All hyperlink colors in the PDF are set to Maroon for a uniform appearance. This is configured via Pandoc -V variables in export_book_pdf.py:
linkcolor=Maroon (internal cross-references)urlcolor=Maroon (external URLs)citecolor=Maroon (citations)filecolor=Maroon (file links)toccolor=Maroon (TOC entries)When adding new link-related Pandoc variables, keep the Maroon convention. Do not leave individual color variables at their Pandoc defaults (Blue, Green, Cyan) as this produces a distracting multi-color link style.
Current PDF export is intentionally:
PandocXeLaTeXctexbookDo not switch PDF generation to Playwright unless the user explicitly asks to change the production path.
Use:
python3 tools/book-kit/export_pdf.py book1-claude-code
python3 tools/book-kit/export_pdf.py book2-comparing
Available cleanup options:
python3 tools/book-kit/export_pdf.py book1-claude-code --clean
python3 tools/book-kit/export_pdf.py book2-comparing --clean-generated
Meaning:
--clean: remove _book/, _debug/, _texdebug/, and old exported outputs before rebuilding--clean-generated: includes --clean behavior and also regenerates diagrams/*.png from diagrams/*.pumlNever let cleanup delete assets/.
Important: PDF TOC layout is owned by LaTeX, not by Pandoc.
Known repo-specific pitfalls:
parskip path for PDF export in this repo.ctexbook setup, parskip patched \@starttoc and caused TOC entries to disappear around page breaks.\renewcommand{\l@chapter} / \renewcommand{\l@section}, place them inside \AtBeginDocument. In this repo, ctexbook applies delayed hooks that can silently override preamble-time TOC customizations.\setstretch{1.0} with \setlength{\parskip}{0pt} in the TOC \pretocmd group. This specific pair triggers a TeX page-break bug where TOC entries near the first page break silently disappear. \setstretch{1.08} or higher does not trigger it — the issue is specific to exactly 1.0 which creates zero-tolerance vertical spacing. The safe approach is to omit \setstretch entirely in the TOC group and only use \parskip=0pt.\AtBeginDocument, and keep the \tableofcontents pre-hook minimal. In practice, \let\thispagestyle\@gobble\pagestyle{empty} has been more stable than adding extra TOC line-spacing tweaks.\setstretch{1.08} as a universal TOC fix. It fixed one page break in book2-comparing, but regressed later chapter breaks in both books by causing subsequent chapter titles to disappear even though the entries were present in .toc.tools/book-kit/export_book_pdf.py, \tocchapterneedspace measures \pagegoal - \pagetotal and forces a page break when the remaining height is too small. This prevents chapter headings from landing at the bottom of a TOC page and avoids losing the following section entries around the break.book1 could still lose 3.4 even after chapter-level protection was added..toc but still disappear from the rendered PDF near a page break. Treat this as a LaTeX pagination problem, not a Pandoc generation problem.第 4 章 in one book can still regress 第 5 章 or a mid-chapter section block in the other book.pdftotext -f 3 -l 6 -layout ... or an equivalent page-scoped extraction to inspect only the TOC pages. Whole-document text extraction can hide TOC regressions because the same heading still exists later in body text.book1-claude-code: 第 3 章 section block around 3.3 to 3.7book1-claude-code: 第 4 章 to 第 5 章book2-comparing: 第 3 章 to 第 4 章book2-comparing: 第 4 章 to 第 5 章.toc file. If the missing headings are present there, debug LaTeX pagination and TOC macros rather than markdown generation.tools/book-kit/export_book_pdf.py over per-book hacks.When debugging TOC issues:
pdftotext..aux/.toc generation.If TOC entries disappear near page breaks, inspect tools/book-kit/export_book_pdf.py first.
book1-claude-code/ or book2-comparing/ unless the chapter is explicitly about repo structure.Harness consistently as the preferred term.references/ in this skill, not inside book1-claude-code/ or book2-comparing/.references/ for background material that helps future editing decisions but should not be treated as buildable manuscript content.references/harness-engineering-book-proposal.md (book1 proposal)references/comparative-book-proposal.md (book2 proposal)tools/book-kit/ for behavior changes.book.json for per-book output naming.book.json for per-book release metadata such as release_date.SUMMARY.md aligned with the actual reading structure when the book uses Honkit navigation.After substantial book or pipeline changes, run enough of this checklist to cover the touched area:
*-print.htmlexported/.md links leak into the merged PDF text.puml is the source, use --clean-generatedassets/ for source and exported/ for output.