
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.
- Installs
- 203
- Last 24h
- +8
- Trending rank
- #9655
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/garrytan/gbrain --skill brain-pdf- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads brain-pdf automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
brain-pdf — Render a Brain Page to Publication-Quality PDF
Convention: see 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:
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
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" # prints the page as markdown with frontmatter
fi
# 3. Strip the leading YAML frontmatter block only: line 1 '---' through
# the next '---'. A later '---' (a horizontal rule) and a page without
# frontmatter are kept as written. Plain awk, so it behaves the same with
# BSD (macOS) and GNU tools. Stop if nothing is left to render.
CLEAN=$(mktemp /tmp/brain-page-clean-XXXXXX.md)
awk 'NR==1 && /^---[[:space:]]*$/ {f=1; next} f==1 && /^---[[:space:]]*$/ {f=2; next} f!=1' "$RAW" > "$CLEAN"
[ -s "$CLEAN" ] || { echo "brain-pdf: nothing to render for $SLUG after removing frontmatter" >&2; exit 1; }
# 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
# 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
messagetool withfilePath="/tmp/<slug>.pdf"attachment. NEVER use rawMEDIA: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.
When it fails
Follow the agent operator protocol for any gbrain error code, exit code, [AGENT] block or notice block. Specific to this skill:
gbrain get <slug>fails withpage_not_found: stop before rendering and resolve the real slug; report the page missing only after a title search.- The make-pdf binary is missing: this is a gstack dependency, not a gbrain error. Tell the user to install gstack; do not hand-roll a PDF.
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
--coveror--tocby default. Off unless asked. - ❌ Using raw
MEDIA:tags for Telegram delivery. Use themessagetool withfilePath.
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).
FAQ
What does the brain-pdf skill do?
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.
How do I install brain-pdf?
Run npx skills add https://github.com/garrytan/gbrain --skill brain-pdf in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/brain-pdf/ (personal) or .claude/skills/brain-pdf/ (project).
Which AI agents can use brain-pdf?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is brain-pdf safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains brain-pdf?
It is published by garrytan in garrytan/gbrain. It has 203 recorded installs.
More from garrytan/gbrain
brain-ops
garrytan/gbrain
Brain knowledge base operations. The core read/write cycle: brain-first lookup, read-enrich-write loop, source attribution, ambient enrichment, back-linking. Read this before any brain interaction.
query
garrytan/gbrain
Answer questions using the brain's knowledge with 3-layer search, synthesis, and citation propagation. Use when the user asks a question, wants a lookup, or needs information from the brain.
maintain
garrytan/gbrain
Brain health checks: back-link enforcement, citation audit, filing validation, stale info detection, orphan pages, and benchmarks. Use when asked to check brain health, run maintenance, or audit quality.
idea-ingest
garrytan/gbrain
Ingest links, articles, tweets, and ideas into the brain. Fetch content, save to brain with analysis, credit the author (people page only when they pass the notability gate), and cross-link. Use when the user shares a link or says "read this", "save this", "think about this".
enrich
garrytan/gbrain
Enrich brain pages with tiered enrichment protocol. Creates and updates person/company pages with compiled truth, timeline, and cross-links. Use when a new entity is mentioned or an existing page needs updating.
meeting-ingestion
garrytan/gbrain
Ingest meeting transcripts from ANY meeting recorder into brain pages with attendee enrichment, entity propagation, and timeline merge. One unified pipeline: normalize the source into a standard transcript record, split multi-meeting recordings, resolve speakers by evidence, create the page, pass every surprising claim through the consistency check (transcript + brain + plausibility), enrich every entity, then run the verification checklist — substance AND sequence. A meeting is NOT fully ingested until the enrich skill has processed every entity AND the verification checklist passes, including the sequence verify (PASS or explicit user waive).
Popular docs & writing skills
grill-with-docs
mattpocock/skills
A relentless interview to sharpen a plan or design, which also creates docs (ADR's and glossary) as we go.
lark-markdown
open.feishu.cn
飞书 Markdown:查看、创建、上传、编辑和比较飞书中的原生 Markdown 文件。当用户要操作飞书 Markdown 文件,或比较其远端版本及本地草稿时使用。纯本地 Markdown 文件操作不触发本 skill。不负责将 Markdown 导入为飞书在线文档,也不负责文件搜索、权限、评论、移动、删除等云空间管理操作。
writing-beats
mattpocock/skills
Writing, exploit; assemble raw material into a journey of beats, grounding each term before a beat leans on it.
writing-shape
mattpocock/skills
Writing, exploit: shape raw material into an article, paragraph by paragraph.
writing-fragments
mattpocock/skills
Writing, explore: mine raw fragments, no structure yet.
writing-for-agents
mattpocock/skills
Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.