agentleFS
hamzafarooqhamzafarooq/claude-code-starter/.claude/skills/md-to-pdf/SKILL.md

md-to-pdf

Skill145 starsChanged 7 months agoMITView on GitHub

Convert any markdown file to a clean PDF. Use when asked to make a PDF from a .md file, export a document, or convert markdown to PDF.

  • Installs packages

8 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 3 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When the user asks to convert a markdown file to PDF, follow these steps exactly:

    line 6
  2. Very specific:

    Ask the user for the path to the .md file if not already provided.

    line 10
  3. Distinctive:

    Run this command (replace INPUT and OUTPUT paths):

    line 14
  4. Distinctive:

    Delete the intermediate HTML file:

    line 52
  5. Very specific:

    If pandoc is not found: tell the user to run brew install pandoc

    line 68
  6. Very specific:

    If Chrome is not at the expected path: check with ls /Applications/ | grep -i chrome and adjust the path

    line 69
  7. Very specific:

    If the PDF is 0 bytes: the file:// URL likely has unencoded spaces — encode them as %20

    line 70

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

When the user asks to convert a markdown file to PDF, follow these steps exactly:

Step 1 — Confirm the input file

Ask the user for the path to the .md file if not already provided. Confirm the output PDF path (default: same folder, same name, .pdf extension).

Step 2 — Convert markdown to styled HTML

Run this command (replace INPUT and OUTPUT paths):

pandoc "INPUT.md" \
  -o "OUTPUT.html" \
  --standalone \
  --metadata title="Document" \
  --css=/dev/stdin <<'EOF'
body { font-family: "Helvetica Neue", Arial, sans-serif; max-width: 800px; margin: 40px auto; padding: 0 40px; font-size: 13px; line-height: 1.7; color: #1a1a1a; }
h1 { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
h2 { font-size: 16px; font-weight: 700; margin-top: 32px; border-bottom: 1px solid #e0e0e0; padding-bottom: 6px; }
strong { font-weight: 600; }
table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 12px; }
th { background: #f5f5f5; padding: 8px; text-align: left; border: 1px solid #ddd; }
td { padding: 8px; border: 1px solid #ddd; }
hr { border: none; border-top: 1px solid #e0e0e0; margin: 24px 0; }
ul, ol { padding-left: 20px; }
li { margin-bottom: 6px; }
EOF

Step 3 — Print HTML to PDF using Chrome

"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
  --headless \
  --disable-gpu \
  --no-sandbox \
  --print-to-pdf="OUTPUT.pdf" \
  --print-to-pdf-no-header \
  --no-pdf-header-footer \
  "file://OUTPUT.html"

Note: encode spaces in the file path as %20 in the file:// URL.

Step 4 — Clean up and confirm

Delete the intermediate HTML file:

rm "OUTPUT.html"

Tell the user the PDF is ready and give them the full path.

Requirements

  • pandoc must be installed (which pandoc to check)
  • Google Chrome must be at /Applications/Google Chrome.app/ (standard Mac install)
  • Works on macOS only in this configuration

Error handling

  • If pandoc is not found: tell the user to run brew install pandoc
  • If Chrome is not at the expected path: check with ls /Applications/ | grep -i chrome and adjust the path
  • If the PDF is 0 bytes: the file:// URL likely has unencoded spaces — encode them as %20

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.