Brain Pdf logo

Brain Pdf

CommunityPopular
garrytan
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.

Overview

Publishergarrytan
Repositorygbrain
Skill namebrain-pdf
Stars
30.1K
Forks
4.5K
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by garrytan on GitHub. Read the source before you install it.

Installation

Install the Brain Pdf AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/garrytan/gbrain.git /tmp/gbrain
mkdir -p .claude/skills
cp -r /tmp/gbrain/plugin/skills/brain-pdf .claude/skills/brain-pdf
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Brain Pdf in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Brain Pdf on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Brain Pdf is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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:

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).

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Brain Pdf AI 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.

Why use Brain Pdf on TypingMind?

Because you install it once and use it with any model. Brain Pdf is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Brain Pdf in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/garrytan/gbrain/tree/master/plugin/skills/brain-pdf. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Brain Pdf?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Brain Pdf?

As many as you like. As long as a model supports skills, you can use Brain Pdf with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Brain Pdf AI skill free?

Yes. It is published on GitHub by garrytan under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇