Agent Docs: Export to Branded PDF
You convert a markdown file into a professionally styled PDF using a bundled PEP 723 renderer script. The PDF features a branded cover page, navy/orange color scheme, table of contents, and consistent typography.
User Input
$ARGUMENTS
Expected: a path to a .md file (absolute or relative to the working directory).
Step 1: Validate Input File
- Resolve the file path from
$ARGUMENTS
- If no argument provided: ask the user for the path to their markdown file
- If path doesn't end in
.md: ask if they meant a different file
- Check the file exists using
ls
- If not found: STOP — tell the user the file was not found
Step 2: Read Frontmatter and Check Required Fields
- Read the markdown file
- Look for a YAML frontmatter block at the top (between
--- delimiters)
- Check for these required fields:
title — OR check if there is exactly one # H1 Heading in the body (if so, it becomes the title automatically via heading-demotion)
organization
client
classification
- Note which required fields are missing
Step 3: Prompt for Missing Required Fields
For each missing required field from Step 2, use AskUserQuestion to gather the value:
- title (only if no frontmatter
title: AND the document does NOT have exactly one H1): "What is the document title?"
- organization: "What is the organization name?" — the skill ships no default.
.context/README.md carries no organization key (its frontmatter is output_path and docs_path only), so do not look there. If a previously exported document's frontmatter or the git remote's owner suggests a name, offer it as the first option; otherwise ask freeform
- client: "What is the client name? (e.g., 'Acme Corp')"
- classification: "What is the document classification? (e.g., 'Confidential', 'Internal', 'Public')"
If ALL required fields are present in frontmatter (or title is covered by a single H1): skip prompting entirely.
Step 4: Check Environment
Check that uv is available:
which uv
- If not found: STOP — print: "This skill requires
uv. Install it with: curl -LsSf https://astral.sh/uv/install.sh | sh"
Check for optional mmdc (Mermaid CLI):
which mmdc
- If not found: note (do NOT stop): "Note: Mermaid diagrams will render as code blocks. Install
npm install -g @mermaid-js/mermaid-cli to render them as images."
Step 5: Invoke Renderer
Print: "Installing PDF renderer dependencies (first time only)..." before the first invocation.
Determine the script path — it is the render_template.py sibling file in this skill's directory:
.claude/skills/ai-util-export-pdf/render_template.py
Resolve relative to the project root (the repo root where .claude/ lives).
Build the command. Start with:
uv run --script <script_path> "<input_file>"
Append CLI overrides for any values gathered in Step 3:
--title "VALUE" (if title was prompted)
--organization "VALUE" (if organization was prompted)
--client "VALUE" (if client was prompted)
--classification "VALUE" (if classification was prompted)
Run the command.
Step 6: Report Result
After successful execution:
- The script prints
Wrote <path> (<size> KB) — relay this to the user
- Confirm: "PDF exported to
<output_path>"
- Suggest: "Open the PDF to verify formatting. Re-run
/ai-util-export-pdf <path> after editing the markdown."
If the command fails:
- Read the error output
- Common issues:
- Missing dependencies on first run → usually resolves on retry
- Invalid markdown syntax → report the specific error
- Missing font or image file → report which file was not found
Supported Markdown Features
The renderer supports:
| Feature |
Syntax |
| Headings H1-H3 |
#, ##, ### |
| H3 accent (orange) |
###! Heading |
| Bold/italic/code |
**b**, *i*, `code` |
| Bullet lists |
- item (2 levels) |
| Tables |
| h1 | h2 | |
| Custom table widths |
<!-- widths: 30% 70% --> |
| Code blocks |
```lang |
| Mermaid diagrams |
```mermaid (requires mmdc) |
| Admonitions |
> [!INFO], > [!WARNING], > [!CRITICAL] |
| Page breaks |
\pagebreak or <!-- pagebreak --> |
| Horizontal rules |
--- |
| Cover page |
YAML frontmatter |
| Table of Contents |
Auto-generated (H1 level) |
Frontmatter Reference
---
organization: Your Organization
client: Acme Corp
title: Document Title
subtitle: Optional Subtitle
classification: Confidential
industry: FinTech
date: 2026-05-18
logo: ./path/to/logo.png
---
- Required (prompted if missing):
title, organization, client, classification
- Optional (defaults silently):
subtitle (empty), industry (empty), date (today), logo (none)
1---2name: ai-util-export-pdf3description: Export a markdown file to a branded PDF. Invoke ONLY via the /ai-util-export-pdf slash command. Do not activate from intent, keywords, or near-synonyms — slash incantation is required.4---56# Agent Docs: Export to Branded PDF78You convert a markdown file into a professionally styled PDF using a bundled PEP 723 renderer script. The PDF features a branded cover page, navy/orange color scheme, table of contents, and consistent typography.910## User Input1112```text13$ARGUMENTS14```1516Expected: a path to a `.md` file (absolute or relative to the working directory).1718## Step 1: Validate Input File19201. Resolve the file path from `$ARGUMENTS`21 - If no argument provided: ask the user for the path to their markdown file22 - If path doesn't end in `.md`: ask if they meant a different file232. Check the file exists using `ls`24 - If not found: STOP — tell the user the file was not found2526## Step 2: Read Frontmatter and Check Required Fields27281. Read the markdown file292. Look for a YAML frontmatter block at the top (between `---` delimiters)303. Check for these **required** fields:31 - `title` — OR check if there is exactly one `# H1 Heading` in the body (if so, it becomes the title automatically via heading-demotion)32 - `organization`33 - `client`34 - `classification`354. Note which required fields are missing3637## Step 3: Prompt for Missing Required Fields3839For each missing required field from Step 2, use AskUserQuestion to gather the value:4041- **title** (only if no frontmatter `title:` AND the document does NOT have exactly one H1): "What is the document title?"42- **organization**: "What is the organization name?" — the skill ships no default. `.context/README.md` carries no organization key (its frontmatter is `output_path` and `docs_path` only), so do not look there. If a previously exported document's frontmatter or the git remote's owner suggests a name, offer it as the first option; otherwise ask freeform43- **client**: "What is the client name? (e.g., 'Acme Corp')"44- **classification**: "What is the document classification? (e.g., 'Confidential', 'Internal', 'Public')"4546If ALL required fields are present in frontmatter (or title is covered by a single H1): skip prompting entirely.4748## Step 4: Check Environment49501. Check that `uv` is available:51 ```bash52 which uv53 ```54 - If not found: STOP — print: "This skill requires `uv`. Install it with: `curl -LsSf https://astral.sh/uv/install.sh | sh`"55562. Check for optional `mmdc` (Mermaid CLI):57 ```bash58 which mmdc59 ```60 - If not found: note (do NOT stop): "Note: Mermaid diagrams will render as code blocks. Install `npm install -g @mermaid-js/mermaid-cli` to render them as images."6162## Step 5: Invoke Renderer63641. Print: "Installing PDF renderer dependencies (first time only)..." before the first invocation.65662. Determine the script path — it is the `render_template.py` sibling file in this skill's directory:67 ```68 .claude/skills/ai-util-export-pdf/render_template.py69 ```70 Resolve relative to the project root (the repo root where `.claude/` lives).71723. Build the command. Start with:73 ```bash74 uv run --script <script_path> "<input_file>"75 ```76774. Append CLI overrides for any values gathered in Step 3:78 - `--title "VALUE"` (if title was prompted)79 - `--organization "VALUE"` (if organization was prompted)80 - `--client "VALUE"` (if client was prompted)81 - `--classification "VALUE"` (if classification was prompted)82835. Run the command.8485## Step 6: Report Result8687After successful execution:88891. The script prints `Wrote <path> (<size> KB)` — relay this to the user902. Confirm: "PDF exported to `<output_path>`"913. Suggest: "Open the PDF to verify formatting. Re-run `/ai-util-export-pdf <path>` after editing the markdown."9293If the command fails:941. Read the error output952. Common issues:96 - Missing dependencies on first run → usually resolves on retry97 - Invalid markdown syntax → report the specific error98 - Missing font or image file → report which file was not found99100## Supported Markdown Features101102The renderer supports:103104| Feature | Syntax |105|---------|--------|106| Headings H1-H3 | `#`, `##`, `###` |107| H3 accent (orange) | `###! Heading` |108| Bold/italic/code | `**b**`, `*i*`, `` `code` `` |109| Bullet lists | `- item` (2 levels) |110| Tables | `\| h1 \| h2 \|` |111| Custom table widths | `<!-- widths: 30% 70% -->` |112| Code blocks | ` ```lang ` |113| Mermaid diagrams | ` ```mermaid ` (requires mmdc) |114| Admonitions | `> [!INFO]`, `> [!WARNING]`, `> [!CRITICAL]` |115| Page breaks | `\pagebreak` or `<!-- pagebreak -->` |116| Horizontal rules | `---` |117| Cover page | YAML frontmatter |118| Table of Contents | Auto-generated (H1 level) |119120## Frontmatter Reference121122```yaml123---124organization: Your Organization125client: Acme Corp126title: Document Title127subtitle: Optional Subtitle128classification: Confidential129industry: FinTech130date: 2026-05-18131logo: ./path/to/logo.png132---133```134135- **Required** (prompted if missing): `title`, `organization`, `client`, `classification`136- **Optional** (defaults silently): `subtitle` (empty), `industry` (empty), `date` (today), `logo` (none)