Book Publishing Skill
End-to-end pipeline: markdown manuscript → arXiv-compliant / KDP-ready PDF, using parallel agent swarms for each stage.
Pipeline Overview
Markdown Source
│
├─── [Skeleton Builder] → main.tex skeleton (FIRST, blocking)
├─── [BibTeX Extractor] → references.bib (parallel)
│
├─── [Chapter Converters × N] → chapters/ch*.tex (after skeleton)
├─── [Front Matter] → front/ (after skeleton)
├─── [Appendix Converter] → appendices/ (after skeleton)
├─── [Citation Index] → cite_index.tex (after bibtex)
├─── [Design Consultant] → typography/styles (after skeleton)
│
├─── [Diagram Engineer] → TikZ + Mermaid .mmd (parallel)
├─── [Market Analyst] → matplotlib charts/PDF (parallel)
├─── [Wardley Mapper] → Wardley .mmd files (parallel)
├─── [Research Verifier] → citation verification (parallel)
│
├─── [Image Upcycler] → Gemini-enhanced PNGs (after diagrams)
│
└─── [Build + Verify] → latexmk + PDF preview (final)
Stage 1: Skeleton Builder (Blocking — runs first)
Creates the root main.tex with:
- Document class:
memoir(12pt, a4paper, twoside) - Package imports (fontspec, microtype, biblatex, hyperref)
- Chapter
\include{}stubs - Front/back matter structure
All other converters wait for skeleton before starting.
Full memoir/biblatex package list, UK typography rules (spaced endash, scene breaks, drop caps), chapter-style code, and the arXiv folder layout are in references/latex-conventions.md — load it before building the skeleton or hand-editing a chapter.
Stage 2: Parallel Foundation
Run simultaneously after skeleton:
# BibTeX Extractor
# Scans all markdown footnotes, extracts URLs and references
# Outputs: references.bib + cite_mapping.json
# cite_mapping.json format: {chapter: {footnote_num: cite_key}}
# Full pattern, footnote-vs-cite-key decision rule, and worked example:
# references/latex-conventions.md#cite_mappingjson-pattern
# Chapter Converters — split into batches of 6
# Batch A: chapters 1–6
# Batch B: chapters 7–12
# Batch C: chapters 13–18
# (etc.)
# Each converter: markdown → LaTeX, respecting cite_mapping.json
# URL-only footnotes → \footnote{\href{...}{...}}
# Multi-use citations → \cite{key}
Stage 3: Parallel Content Generation
All run simultaneously:
| Agent | Output | Notes |
|---|---|---|
| Diagram Engineer | TikZ .tex files |
Compile standalone, include via \includegraphics |
| Market Analyst | matplotlib .pdf charts |
Python script, PDF for vector quality |
| Wardley Mapper | .mmd + rendered .png |
See Wardley Maps skill |
| Research Verifier | verification report | Web search, flag unverifiable claims |
Stage 4: Image Upcycling
After diagrams exist, upscale them for print. A Gemini image path exists when
GOOGLE_API_KEY is provisioned — see art/references/diagram-upcycling.md
for the current nano-banana model ids and the route-through-the-skill's-own-tool
pattern; otherwise the offline ImageMagick pass is the default, deterministic and never
hallucinates text:
convert diagram.png -resize 200% -unsharp 0x1.0 diagram_hires.png
Prefer regenerating charts as vector PDF over raster upscaling where possible. Even with a provisioned key, an AI-enhanced diagram must be visually diffed against the source before shipping — its output can alter text/data. Full guardrails: references/image-upcycling.md.
Stage 5: Build and Verify
# Full build
latexmk -xelatex -biber -interaction=nonstopmode main.tex
# Visual verification via browser sidecar
# Navigate to output PDF, screenshot pages for review
browser_navigate({ url: "file:///path/to/main.pdf" })
browser_take_screenshot({ filename: "page_verify.png", fullPage: false })
Swarm Topology (claude-flow)
// Initialize swarm
mcp__claude-flow__swarm_init({
topology: "hierarchical",
maxAgents: 15,
strategy: "book-conversion"
})
// Stage 1: skeleton (blocking)
await mcp__claude-flow__agent_spawn({
agentType: "coder",
name: "skeleton-builder",
task: "Build main.tex skeleton with memoir class, all chapter stubs, preamble"
})
// Stage 2: parallel foundation (after skeleton signals complete)
await Promise.all([
mcp__claude-flow__agent_spawn({ agentType: "coder", name: "bibtex-extractor", ... }),
mcp__claude-flow__agent_spawn({ agentType: "coder", name: "chapter-conv-A", ... }),
mcp__claude-flow__agent_spawn({ agentType: "coder", name: "chapter-conv-B", ... }),
mcp__claude-flow__agent_spawn({ agentType: "coder", name: "chapter-conv-C", ... }),
mcp__claude-flow__agent_spawn({ agentType: "coder", name: "front-matter", ... }),
mcp__claude-flow__agent_spawn({ agentType: "coder", name: "appendix-conv", ... }),
mcp__claude-flow__agent_spawn({ agentType: "coder", name: "design-consultant", ... }),
mcp__claude-flow__agent_spawn({ agentType: "coder", name: "diagram-engineer", ... }),
mcp__claude-flow__agent_spawn({ agentType: "analyst", name: "market-analyst", ... }),
mcp__claude-flow__agent_spawn({ agentType: "researcher", name: "research-verifier", ... }),
mcp__claude-flow__agent_spawn({ agentType: "coder", name: "wardley-mapper", ... }),
])
// Stage 3: after diagrams
await mcp__claude-flow__agent_spawn({ agentType: "coder", name: "image-upcycler", ... })
Publication Targets
arXiv
- memoir class, XeLaTeX, biber-compiled
.bbl - All fonts embedded, no shell-escape
- Submit: source
.tex+.bbl+ figures (PDF/PNG/JPG) - Full compliance checklist: references/latex-conventions.md
KDP (Kindle Direct Publishing)
- PDF/X-1a or PDF/X-4 for print
- Bleed: 3mm all sides (
\setlrmarginsandblockin memoir) - Cover: separate high-res PDF (300 DPI minimum)
- Interior: 6×9 inch (memoir
[6in,9in])
Print-on-Demand (general)
- Trim size specified in
\setstocksize{9in}{6in} - Spine calculation: pages × 0.002252 inches (60gsm paper)
Quality Gates
Before shipping:
-
latexmkexits 0 (no errors) - Zero overfull hbox warnings > 10pt
- All
\cite{}keys resolve (biber reports 0 unresolved) - All
\includegraphicspaths exist - PDF opens and pages render correctly (browser sidecar check)
- First 3 and last 3 chapters spot-checked visually
Related Skills
wardley-maps— Wardley map generation with LaTeX integrationart— Gemini API image enhancement (diagram upcycling)browser— PDF preview, Mermaid rendering workaroundlatex-documents— general LaTeX compilation outside the book pipeline
LaTeX conventions, memoir class packages, UK typography, and citation patterns
(formerly the latex-book skill) now live in
references/latex-conventions.md; latex-book is a
deprecated redirect stub.