mistral-pdf-to-markdown
Convert PDFs to Markdown with Mistral OCR and extracted images. Use for scanned PDFs or complex layouts where structured text or images matter.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Convert PDFs to Markdown with Mistral OCR and extracted images. Use for scanned PDFs or complex layouts where structured text or images matter.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Economic data-analysis discipline. Use for importing, cleaning, merging, filtering, variables, aggregation, summary stats, regressions, or figures on economic, financial, or panel data.
Codebase integration discipline. Use when refactoring for local conventions, reviewing post-sync quality, auditing project docs, pruning diffs, or using Sync Impact evidence.
Protect key research results with permanent documentation, drift tests, or artifact-appropriate checks. Use when selecting protection, creating or reviewing tests, or guarding important outputs through integration.
Semantic branch integration. Use before git merge, rebase, or cherry-pick, or when syncing branches where conflicts or overlapping intent must be resolved deliberately.
Integrate code-complete superRA work. Requires superRA:using-superra. Use for result protection, base sync, codebase-fit refactors, permanent records, cleanup, or PR preparation.
Proactively plan or update superRA work. Requires superRA:using-superra. Use when starting or changing work, creating/revising superRA/, or reflecting material decisions in the task tree.
| name | mistral-pdf-to-markdown |
| description | Convert PDFs to Markdown with Mistral OCR and extracted images. Use for scanned PDFs or complex layouts where structured text or images matter. |
| user-invocable | true |
Convert PDF documents to Markdown format using Mistral's OCR API. Automatically extracts text, formatting, and images.
Run the conversion script from this skill's directory. In the commands below, <skill-dir> is the directory containing this SKILL.md — substitute the real path so the invocation works regardless of which harness loaded the skill or where it is installed.
# Convert entire PDF
uv run --script <skill-dir>/scripts/convert_pdf_to_markdown.py input.pdf output.md
# Convert specific pages
uv run --script <skill-dir>/scripts/convert_pdf_to_markdown.py input.pdf output.md --pages "1-5"
uv run --script <skill-dir>/scripts/convert_pdf_to_markdown.py input.pdf output.md --pages "1,3,5"
Each conversion is written as a self-contained folder. Passing Output/PDFConversions/paper_alpha.md creates Output/PDFConversions/paper_alpha/paper_alpha.md, with extracted images beside it under images/:
Output/PDFConversions/
├── paper_alpha/
│ ├── paper_alpha.md # references images/img-N.jpeg
│ └── images/
│ ├── img-0.jpeg
│ └── img-1.jpeg
└── paper_beta/
├── paper_beta.md
└── images/
├── img-0.jpeg
└── ...
Passing an existing foldered markdown path such as Output/PDFConversions/paper_alpha/paper_alpha.md keeps that path. Passing a directory creates <directory>/<input-pdf-stem>.md.
from pathlib import Path
import subprocess
# Run conversion script
result = subprocess.run([
"uv", "run", "--script",
"<skill-dir>/scripts/convert_pdf_to_markdown.py",
"input.pdf",
"Output/PDFConversions/output.md",
"--pages", "1-10"
], capture_output=True, text=True)
print(result.stdout)
images/ folder automaticallyThe script requires:
mistralai, python-dotenv, pypdf, pyyaml (declared inline in the script's PEP 723 header)The script checks these locations in order (first match wins):
MISTRAL_API_KEY — recommended for personal use (e.g., add export MISTRAL_API_KEY=your-key to secrets.sh).claude/agent-contract.yaml or ~/.config/agent-contract/config.yaml under paper-reader.mistral_api_keyNotes/.env — add MISTRAL_API_KEY=your-key. This file is gitignored but Dropbox-synced, making it convenient for teams sharing a project folderNever commit API keys to git. Use environment variables or Dropbox-synced
Notes/.envinstead.
uv run --script <skill-dir>/scripts/convert_pdf_to_markdown.py \
"Data/papers/research.pdf" \
"Notes/Paper Markdown/research.md"
# Extract pages 10-20 (introduction and methods)
uv run --script <skill-dir>/scripts/convert_pdf_to_markdown.py \
"paper.pdf" \
"Notes/Paper Markdown/intro_methods.md" \
--pages "10-20"
# Extract pages with figures
uv run --script <skill-dir>/scripts/convert_pdf_to_markdown.py \
"paper.pdf" \
"Notes/Paper Markdown/figures.md" \
--pages "25,27,30,35"
API Key Not Found:
Error: Mistral API key not found
→ See API Key Setup above for three ways to configure it
Page Out of Range:
Warning: Page 100 out of range, skipping
→ Check PDF page count and adjust page selection
API Rate Limit: → Wait a moment and retry, or reduce page count per request
images/ subfolderimages/img-X.jpegpdf skill insteadpdf skill - For local PDF manipulation without API callsreferences/reference.md - Additional details about the Mistral OCR API