brain-pdf
Generate a publication-quality PDF from any brain page via the gstack make-pdf binary. Strips YAML frontmatter, sanitizes emoji, applies running headers and page numbers. Brain page is always the source of truth; PDF is a rendering.
What this skill does
# brain-pdf — Render a Brain Page to Publication-Quality PDF
> **Convention:** see [conventions/quality.md](../conventions/quality.md) for
> output rules. The PDF is a rendering — never the primary artifact. If a
> PDF exists, the source brain page exists behind it.
## The rule
The brain page is ALWAYS the source of truth. The PDF is a rendering of
it, never a standalone artifact. If a PDF exists somewhere, the brain
page must exist behind it.
## What this does
Renders a brain page (markdown with frontmatter) into a
publication-quality PDF using the gstack `make-pdf` binary. Output is
suitable for:
- Sharing a personalized book mirror via email or Telegram
- Delivering a strategic-reading playbook as a clean read
- Producing a briefing or report with running headers and page numbers
- Archiving a long-form essay in a portable format
## Prerequisite: gstack make-pdf
This skill depends on the gstack `make-pdf` binary at:
```
$HOME/.claude/skills/gstack/make-pdf/dist/pdf
```
The user must have gstack co-installed. If absent, the skill cannot run.
A future v0.26+ may bundle a fallback PDF renderer; for v0.25.1 gstack
is a soft prereq.
Verify it exists before invoking:
```bash
P="$HOME/.claude/skills/gstack/make-pdf/dist/pdf"
[ -x "$P" ] || { echo "make-pdf not installed; install gstack" >&2; exit 1; }
```
## Workflow
```
1. RESOLVE → Confirm the brain page exists (gbrain get <slug>).
2. STRIP → Remove YAML frontmatter — the renderer would otherwise
dump it as a full page of raw metadata text.
3. RENDER → Invoke make-pdf with sane defaults (no --cover, no --toc).
4. DELIVER → Hand the PDF to the requester via the agent's preferred
channel (do not use raw `MEDIA:` tags on Telegram —
they fail silently).
```
## Invocation
```bash
SLUG="path/to/page"
P="$HOME/.claude/skills/gstack/make-pdf/dist/pdf"
# 1. Confirm the page exists.
gbrain get "$SLUG" > /dev/null || { echo "Page $SLUG not found" >&2; exit 1; }
# 2. Get the raw markdown. Two paths: read from the brain repo (if user
# syncs locally) OR ask gbrain for the body via the API.
BRAIN_DIR=$(gbrain config get sync.repo_path 2>/dev/null || echo)
if [ -n "$BRAIN_DIR" ] && [ -f "$BRAIN_DIR/$SLUG.md" ]; then
RAW="$BRAIN_DIR/$SLUG.md"
else
RAW=$(mktemp /tmp/brain-page-XXXXXX.md)
gbrain get "$SLUG" --raw > "$RAW" # whatever flag exposes raw body
fi
# 3. Strip YAML frontmatter — sed: skip the opening '---' through the
# closing '---' (lines 1..N), then keep everything after.
CLEAN=$(mktemp /tmp/brain-page-clean-XXXXXX.md)
sed '1{/^---$/!q}; /^---$/,/^---$/d' "$RAW" > "$CLEAN"
# 4. Render. NO --cover, NO --toc by default — they look corporate
# and waste space. Add them only if explicitly requested.
OUT="/tmp/$(basename "$SLUG").pdf"
CONTAINER=1 "$P" generate "$CLEAN" "$OUT"
echo "Rendered: $OUT"
```
`CONTAINER=1` is mandatory in containerized environments — it tells
Playwright to skip Chromium sandboxing. Harmless on bare-metal.
## Common patterns
```bash
# Default — clean PDF, no cover, no TOC
brain-pdf <slug>
# Draft watermark for in-progress work
CONTAINER=1 "$P" generate --watermark DRAFT "$CLEAN" "$OUT"
# Optional cover + TOC if the user explicitly asks
CONTAINER=1 "$P" generate --cover --toc "$CLEAN" "$OUT"
# Custom title + author override (otherwise pulled from frontmatter)
CONTAINER=1 "$P" generate --title "Custom Title" --author "Custom Author" "$CLEAN" "$OUT"
```
## Defaults: NO cover, NO TOC
These flags are off by default because they look corporate and waste
space on most personal-knowledge content. Only add them when the user
explicitly asks for "formal" output (e.g., something they're sending to
a board or printing as a deliverable).
## Font requirements
The renderer needs:
- `fonts-liberation` (Helvetica/Arial substitute)
- `fonts-noto-cjk` (Chinese/Japanese/Korean characters)
- Minimum body font size: 10pt (page chrome 9pt)
- Body text: 11pt
If running in an environment without these fonts, install them via the
host's package manager (`apt install fonts-liberation fonts-noto-cjk` on
Debian/Ubuntu containers).
## Delivery
After rendering, deliver via the agent's preferred channel:
- **Telegram:** use the `message` tool with `filePath="/tmp/<slug>.pdf"`
attachment. NEVER use raw `MEDIA:` tags — they fail silently.
- **Email:** attach via the host's email tool.
- **Direct file response:** print the PDF path; the user can pull it
manually.
Always include the brain page link in the delivery message so the user
can also see it on GitHub / locally. The PDF is a rendering; the source
is the artifact.
## Anti-Patterns
- ❌ Generating a PDF without first confirming the brain page exists.
No source = no PDF.
- ❌ Skipping the frontmatter strip. The renderer dumps frontmatter as
raw text on the first page; ugly.
- ❌ Skipping emoji sanitization. Emoji that don't map to the rendering
font show up as `□` boxes.
- ❌ Adding `--cover` or `--toc` by default. Off unless asked.
- ❌ Using raw `MEDIA:` tags for Telegram delivery. Use the `message`
tool with `filePath`.
## Related skills
- `skills/book-mirror/SKILL.md` — produces a brain page that's a
natural input to brain-pdf (chapter-by-chapter personalized analysis).
- `skills/strategic-reading/SKILL.md` — same shape, problem-lens variant.
- `skills/publish/SKILL.md` — share brain pages as password-protected
HTML (different rendering target).
## Contract
This skill guarantees:
- Routing matches the canonical triggers in the frontmatter.
- Output written under the directories listed in `writes_to:` (when applicable).
- Conventions referenced (`quality.md`, `brain-first.md`, `_brain-filing-rules.md`) are followed.
- Privacy contract preserved: no real names, no fork-specific filesystem path literals, no upstream-fork references.
The full behavior contract is documented in the body sections above; this section exists for the conformance test.
## Output Format
The skill's output shape is documented inline in the body sections above (see "Output", "Brain page format", or equivalent). The literal section header here exists for the conformance test (`test/skills-conformance.test.ts`).
Related in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.