agentleFS
danielrosehilldanielrosehill/KDP-Publishing-Plugin/skills/kdp-preflight/SKILL.md

kdp-preflight

Skill3 starsChanged 2 days agoMITView on GitHub

Verify a built KDP book mechanically before upload — trim, page parity, gutter against the tiered minimum, font round-trip for silent glyph substitution, and the cover's spine against the interior's real extent. Use before any upload, after any rebuild, and when deciding whether a book is actually ready to print.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every failure this script is built to catch produces a *successful-looking* build.

    line 20
  2. Distinctive:

    If checks fail, say which, and show the output.

    line 68
  3. Distinctive:

    If checks pass, do not describe the book as ready to print.

    line 71

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Pre-flight

python3 ${CLAUDE_PLUGIN_ROOT}/scripts/preflight.py
python3 ${CLAUDE_PLUGIN_ROOT}/scripts/preflight.py --json

Exits non-zero on failure. Everything it checks is something a machine can check; everything it cannot check, it names.

The principle

Check the artifact, not the signal that stands in for it.

Every failure this script is built to catch produces a successful-looking build. Typst exits 0. The PDF opens. KDP accepts the upload. The problem is discovered in a proof copy, which is the most expensive possible place to discover it.

So: read the page geometry out of the PDF rather than trusting book.toml. Read the page count out of the PDF rather than trusting the last build. Derive the cover's spine from the finished wrap rather than recomputing what it should have been. A number that agrees with itself because it came from one place twice has not been verified.

What each check is protecting against

Trim. KDP will accept a file at the wrong trim and print the book with the wrong margins. Nobody sees it until the proof arrives.

Page parity. An odd leaf count means the build is stale — the parity pass did not run or its output was overwritten.

Gutter against the tiered minimum. KDP's minimum inside margin steps up with page count. A book that grew past a boundary since its margins were set has text being swallowed into the bind on every page, and it looks perfectly fine in a PDF viewer because the viewer does not bind anything.

Font round-trip. The important one, and the reason this script exists.

Typst does not warn when a character has no glyph in the requested font. It falls back through the system font list, renders the character in some other face, and exits 0. No error, no warning, nothing anyone would catch by eye across hundreds of pages. On another machine with different fonts installed, the same source produces a different book.

The check enumerates every codepoint in the source, confirms each one survives into the PDF via pdftotext, and lists the fonts actually embedded via pdffonts. A substitution reported here is not necessarily a failure — the fallback is why there is no tofu on the page — but it becomes visible and deliberate rather than discovered in print.

Cover spine against the interior's extent. The second of the two independent routes to the same fact. build-cover.py measured the interior going in; this measures the wrap coming out.

Listing limits. Description over 4,000 characters, more than 7 keywords, more than 3 categories, a quotation mark in a keyword — all rejected by the form, all cheaper to catch here.

Reporting the result

If checks fail, say which, and show the output. Do not describe a build as ready when preflight returned non-zero.

If checks pass, do not describe the book as ready to print. The script says this itself; repeat it rather than dropping it:

  • The gutter still has to be read in KDP's own previewer, page by page. It is the only thing that shows what the press will do.
  • Any font substitution listed still has to be eyeballed in a proof.
  • The proof copy still has to be ordered and read.

Those are not gaps in the script. They are things no script can do, and a report that omits them is telling the user the book is finished when it is not.

Dates

reference/ carries a verification date on every KDP figure. KDP changes them without notice and without a changelog. When a number is about to go into a real upload, quote the date alongside it rather than presenting it as current.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.