Skip to content
Back to skills

Brain Pdf

ASecurity

Generate a publication-quality PDF from any brain page via the host agent's PDF renderer. Strips YAML frontmatter, sanitizes emoji, applies running headers and page numbers. Brain page is always the source of truth; PDF is a rendering.

  • 11 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 28, 2026
ai-agentsbash

Works with

  • mcp

Security analysis

A100/100

Scanned October 7, 2026

npx -y skills add timurgaleev/memex --skill brain-pdf --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Brain Pdf?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Brain Pdf
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/timurgaleev-brain-pdf/badge)](https://www.skillsdirectory.com/skills/timurgaleev-brain-pdf)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
---
name: brain-pdf
version: 0.1.0
description: Generate a publication-quality PDF from any brain page via the host agent's PDF renderer. Strips YAML frontmatter, sanitizes emoji, applies running headers and page numbers. Brain page is always the source of truth; PDF is a rendering.
triggers:
  - "make pdf from brain"
  - "brain pdf"
  - "convert brain page to pdf"
  - "publish this page as pdf"
  - "export brain page"
tools:
  - page_get
mutating: false
---

# brain-pdf — Render a Brain Page to Publication-Quality PDF

> **Convention:** see conventions/quality.md (via `get_skill conventions/quality`)
> 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 host agent's PDF renderer (e.g. the
agent harness's `make-pdf` skill or an equivalent markdown-to-PDF
toolchain). Output is suitable for:

- Sharing a personalized book mirror via email or chat
- 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: a host-side PDF renderer

This skill depends on a markdown-to-PDF renderer available on the host
where the agent runs. Memrain itself does not render PDFs — it serves the
page body; rendering is the agent's job.

Verify a renderer is available before invoking (check for the agent
harness's `make-pdf` skill, or a `pandoc`/Chromium-print pipeline). If
none is installed, the skill cannot run — tell the user which
prerequisite is missing instead of improvising a degraded rendering.

## Workflow

```
1. RESOLVE  → Confirm the brain page exists (page_get <slug>).
2. STRIP    → Remove YAML frontmatter — the renderer would otherwise
              dump it as a full page of raw metadata text.
3. RENDER   → Invoke the PDF renderer with sane defaults (no cover,
              no TOC).
4. DELIVER  → Hand the PDF to the requester via the agent's preferred
              file-delivery channel (an explicit attachment tool — not
              inline media markup, which can fail silently).
```

## Invocation

```bash
SLUG="path/to/page"

# 1. Confirm the page exists and pull the raw markdown body.
#    memrain is DB-canonical: there is no repo checkout of the page —
#    the body always comes from the brain over MCP.
RAW=$(mktemp "$TMPDIR/brain-page-XXXXXX.md")
memrain call page_get "{\"slug\":\"$SLUG\"}" > /dev/null \
  || { echo "Page $SLUG not found" >&2; exit 1; }
memrain call page_get "{\"slug\":\"$SLUG\"}" | jq -r '.content' > "$RAW"

# 2. Strip YAML frontmatter — sed: skip the opening '---' through the
#    closing '---' (lines 1..N), then keep everything after.
CLEAN=$(mktemp "$TMPDIR/brain-page-clean-XXXXXX.md")
sed '1{/^---$/!q}; /^---$/,/^---$/d' "$RAW" > "$CLEAN"

# 3. Render. NO cover, NO TOC by default — they look corporate
#    and waste space. Add them only if explicitly requested.
OUT="$TMPDIR/$(basename "$SLUG").pdf"
# invoke the host renderer, e.g. the agent's make-pdf skill:
#   make-pdf "$CLEAN" "$OUT"

echo "Rendered: $OUT"
```

If the renderer is Chromium/Playwright-based and you are in a
containerized environment, enable its no-sandbox mode — harmless on
bare-metal, mandatory in containers.

## Common patterns

```
# Default — clean PDF, no cover, no TOC
brain-pdf <slug>

# Draft watermark for in-progress work
render with --watermark DRAFT (or the renderer's equivalent)

# Optional cover + TOC if the user explicitly asks
render with --cover --toc

# Custom title + author override (otherwise pulled from frontmatter)
render with --title "Custom Title" --author "Custom Author"
```

## 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:

- **Chat / messaging:** use the agent's file-attachment tool with the
  PDF path. NEVER use raw inline media markup — it fails silently on
  some transports.
- **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 slug in the delivery message so the user
can also read it via `page_get`. The PDF is a rendering; the source
is the artifact.

## Anti-Patterns

- ❌ Generating a PDF without first confirming the brain page exists
  (`page_get`). 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 inline media markup for chat delivery. Use the agent's
  attachment tool with a file path.

## 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 host-specific filesystem path literals.

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.

Files in this skill

  • SKILL.md6.5 KB
  • routing-eval.jsonl589 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.