pdf-to-qmd

pdf-to-qmd is a command for Claude Code, Cursor from AI-Learning-Gems/AI-Learning-Gems.github.io. It costs 23 tokens per session (4,457 once invoked), scanned C, original, MIT.

A workflow that transcribes a PDF into Quarto Markdown files with LaTeX. It aims to preserve the source’s wording, order, equations, and formatting rather than rewrite the content.

In plain words
What is it for?
Use it to convert handwritten notes, textbooks, or academic papers into .qmd files.
Why use it?
It saves manual transcription work while keeping notes, textbooks, or papers close to the original PDF.

Command for Claude CodeCursor

Written for Cursor and Claude Code: installed under .cursor/, but also a Claude Code command (commands/*.md). Also seen: mentions subagents.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is - ../_extensions/pandoc-ext/diagram/diagram.lua.

Good fit Use it to convert handwritten notes, textbooks, or academic papers into .qmd files.

Compare 6 commands from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/AI-Learning-Gems/AI-Learning-Gems.github.io
agentmods
npx agentmods add commands/ai-learning-gems/ai-learning-gems.github.io/pdf-to-qmd

Made for: Claude Code, Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pdf-to-qmd

README.md
[![agentmods](https://agentmods.dev/badge/commands/ai-learning-gems/ai-learning-gems.github.io/pdf-to-qmd.svg)](https://agentmods.dev/commands/ai-learning-gems/ai-learning-gems.github.io/pdf-to-qmd)
Your own site
<a href="https://agentmods.dev/commands/ai-learning-gems/ai-learning-gems.github.io/pdf-to-qmd"><img src="https://agentmods.dev/badge/commands/ai-learning-gems/ai-learning-gems.github.io/pdf-to-qmd.svg" alt="Measured on agentmods" height="20"></a>
Per session 23 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 4,457 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00023 $0.04457
Opus 5 $0.00012 $0.02228
Sonnet 5 $0.00005 $0.00891
Haiku 4.5 $0.00002 $0.00446

Measured 8d ago against content hash 4d15f2c778fe, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade C, and why

pdf-to-qmd scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

rm -rf "OUTPUT_DIR/pages/"
.cursor/commands/pdf-to-qmd.md · 395 lines

How it starts

The opening of the file, as written. The whole thing — 395 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are a PDF-to-Quarto conversion agent. Your goal is to faithfully reproduce the content of a PDF as Markdown with embedded LaTeX, organized into Quarto .qmd files. This is a transcription workflow, not a writing workflow: the output must match the source PDF as closely as possible. Do not rephrase, reorder, or editorialize.

=== USER INPUT ===

The user will provide:

  • PDF path: Path to the PDF file to convert
  • Output location: (Optional) Where to put the output. Default: a subfolder next to the PDF, named after the PDF.

=== EXECUTION CONTEXT ===

This prompt is designed for agentic execution in Cursor, Windsurf, Antigravity, or similar coding-agent IDEs with vision capabilities. The agent should execute the entire workflow autonomously without asking for user confirmation at any step.

Key principles:

  • No confirmation needed: Do NOT ask the user to confirm anything. Just execute.
  • Faithfulness over style: Reproduce the PDF content exactly. Writing style rules (writing-style.mdc) do NOT apply. Even if the content has poor grammar or unusual formatting, preserve it.
  • File-based output: All content goes to .qmd files, never the chat.
  • Parallel extraction: Use subagents for parallel page conversion (max 5 concurrent) for handwritten PDFs only.

=== MANDATORY RULES RE-READ ===

Read these files before starting:

# File to Read What It Contains When It Matters
1 web-source-fetching.md PDF extraction strategies (OneNote vs rendered) Step 0 (PDF analysis)
2 quarto-conventions.mdc Folder structure, heading levels, LaTeX formatting Step 3 (file creation)
3 visualization-standards.mdc D2 diagram template, hvplot/bokeh two-cell pattern Step 2A (recreating handwritten plots)
4 python-env.mdc Conda environment activation Any terminal commands

Rules that do NOT apply to this workflow:

  • writing-style.mdc — This is transcription, not authoring. Reproduce content as-is.
  • exercise-syntax.mdc — Not relevant for transcription.

=== WHAT "FAITHFUL REPRODUCTION" MEANS ===

  1. Text: Reproduce all text content verbatim. Preserve the author's wording, sentence structure, and paragraph breaks.
  2. Equations: Convert all mathematical content to LaTeX. Use $...$ for inline and $$...$$ for display equations. Numbered equations get {#eq-label} tags.
  3. Headings: Preserve the heading hierarchy from the PDF. Map chapter titles to ##, sections to ###, subsections to ####.
  4. Lists: Preserve numbered and bulleted lists exactly.
  5. Tables: Reproduce tables in Markdown table format.
  6. Figures/Diagrams (rendered PDFs): Mistral OCR extracts these automatically. They are saved in the images/ folder and referenced in the markdown.
  7. Figures/Diagrams (handwritten PDFs): Recreate plots and diagrams programmatically where possible (see Step 2A). For complex figures that cannot be recreated, crop from the page PNG.
  8. Color annotations / highlights: Note these as bold or use ::: callout blocks for boxed/highlighted content.
  9. Footnotes: Preserve as Markdown footnotes [^1].
  10. Cross-references: If the PDF references "Section 3.2" or "Equation (5)", preserve these as-is in the text (they can be converted to @sec- / @eq- references in a later editing pass).

=== STEP 0: Analyze the PDF ===

Run the analysis script to determine the PDF type:

$(conda info --base)/envs/ai-learning-gems/bin/python -c "
import fitz
doc = fitz.open('PDF_PATH')
print(f'Pages: {len(doc)}')
for i in range(min(len(doc), 5)):
    page = doc[i]
    rect = page.rect
    text = page.get_text()
    drawings = page.get_drawings()
    images = page.get_images()
    print(f'Page {i}: {rect.width:.0f}x{rect.height:.0f}pt ({rect.width/72:.1f}x{rect.height/72:.1f}in)')
    print(f'  Text: {len(text)} chars, Drawings: {len(drawings)}, Images: {len(images)}')
print(f'File size: {doc.stream.tell() if hasattr(doc, \"stream\") else \"?\"} bytes')
"

Read the full file on GitHub · 395 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 395 lines · 23 tokens per session scan C 4d15f2c778fe

Subscribe to this mod's changes

pdf-to-qmd is a command published in the GitHub repository AI-Learning-Gems/AI-Learning-Gems.github.io (23 stars, last pushed 3mo ago), licensed MIT. It adds 23 tokens to every session and 4,457 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.