md-to-pdf
CLAUDE.md2 starsChanged 7 months agoApache-2.0View on GitHub
Project guidance for AI agents working in this repo. Read this first. A Markdown → PDF conversion engine with enterprise features: - Brand packs (logo, colours, fonts, footer, compliance text) - Watermarks (L1 visible + L2 XMP) and audit logging - CJK text support (Chinese, Japanese, Korean) - Mermaid diagrams, syntax-highlighted code, embedded images - PDF bookmarks and table of contents - AST-first architecture (markdown-it-py → ReportLab) Status: v0.2.1 Beta — Core features complete. Additional functionality planned for v0.3–v1.0. Current…
- Installs packages
The file
We split this CLAUDE.md into the rules it gives an agent
6 rules. About 0 are common, 5 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 82
AST-first: All markdown → markdown-it-py → internal AST → render.
- Very specific: line 83
Single orchestrator: Every render path goes through Pipeline.render(RenderRequest) → RenderResult.
- Distinctive: line 125
Prefer simplicity over features
- Distinctive: line 126
Ask before implementing things not in the current version
- Distinctive: line 127
Check tests first — they document expected behavior
- Distinctive: line 139
Don't assume. State assumptions explicitly.
≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- AI agent guidance: project conventions, commands, architectural principles. -->CLAUDE.md — md-to-pdf v0.2.1
Project guidance for AI agents working in this repo. Read this first.
What this project is
A Markdown → PDF conversion engine with enterprise features:
- Brand packs (logo, colours, fonts, footer, compliance text)
- Watermarks (L1 visible + L2 XMP) and audit logging
- CJK text support (Chinese, Japanese, Korean)
- Mermaid diagrams, syntax-highlighted code, embedded images
- PDF bookmarks and table of contents
- AST-first architecture (markdown-it-py → ReportLab)
Status: v0.2.1 Beta — Core features complete. Additional functionality planned for v0.3–v1.0.
Repository state
Current version: 0.2.1 (Beta)
| Layer | Status | Location |
| Core engine | ✅ Stable | src/mdpdf/ (pipeline, cli, markdown/parser, render/reportlab, etc.) |
| Brand packs | ✅ Complete | examples/brands/ (schema + 3-layer registry) |
| Watermarking | ✅ Complete | L1 (visible) + L2 (XMP metadata) |
| CJK fonts | ✅ Complete | Noto Sans SC + font manager in src/mdpdf/fonts/ |
| Tests | ✅ 443 passing | tests/unit/, tests/integration/, tests/golden/ |
| Documentation | ✅ Live | https://leiminray.github.io/md-to-pdf/ (mkdocs-material) |
| CI/CD | ✅ 16/16 passing | .github/workflows/ (Python 3.10–3.13 × Linux/macOS/Windows) |
Development conventions
- Language: Python 3.10+ (CI: 3.10–3.13)
- Lint:
ruff(format + lint) +mypy --strict+pyright - Test:
pytest— target ≥80% coverage onsrc/mdpdf/ - License: Apache-2.0 (patent grant clause; do not change without discussion)
- Commits: Conventional Commits + DCO sign-off required
- Branch protection: PRs to
mainrequire passing CI
Common commands
Development environment
# Create venv
python3 -m venv .venv
.venv/bin/pip install -e ".[dev]"
# Render a markdown file
.venv/bin/md-to-pdf input.md -o output.pdf
# With brand pack
.venv/bin/md-to-pdf input.md -o output.pdf --brand-pack path/to/brand
# List available brands
.venv/bin/md-to-pdf brand list
# Migrate v1 brand kit to v0.2.1
.venv/bin/md-to-pdf brand migrate /old/brand_kits/idimsum /new/locationTesting & quality
# Run tests (443 passing)
.venv/bin/pytest -v
# Lint
.venv/bin/ruff check src/ tests/
.venv/bin/ruff format src/ tests/
# Type check
.venv/bin/mypy --strict src/mdpdf
# Get coverage
.venv/bin/pytest --cov=src/mdpdfArchitectural principles
- AST-first. All markdown → markdown-it-py → internal AST → render. Never regex-based markdown.
- Single orchestrator. Every render path goes through
Pipeline.render(RenderRequest) → RenderResult. - Engine abstraction.
RenderEngineABC with one concreteengine_reportlab.py; design for adding engines later. - Schema validation. Brand packs + requests validate via Pydantic v2 before parsing.
- CJK loudly. Fail with clear error if CJK input found but fonts missing. No silent tofu.
- No remote by default. Remote assets rejected unless
--allow-remote-assetsflag set. - Atomic writes. PDFs written to temp file, fsync'd, then renamed atomically.
- Determinism contract. With
SOURCE_DATE_EPOCH+ same input/brand/options, output is bit-identical.
Where to put new things
| Artifact | Path |
| New source code | src/mdpdf/<module>/ |
| New unit tests | tests/unit/<module>/ |
| New integration tests | tests/integration/ |
| Golden/UAT tests | tests/golden/ |
| Example brands | examples/brands/ |
| Example inputs | examples/inputs/ |
| Feature specs | docs/superpowers/specs/ |
| Implementation plans | docs/superpowers/plans/ |
| User docs | docs/ (mkdocs-material) |
Roadmap
v0.2.1 (current): AST core, brand v2, watermarks, CJK support, audit logging ✅
v0.3–v1.0: Multiple rendering engines, template packs, advanced watermarking, MCP server, GitHub Actions
Future (v0.2.1+): Policy-based brand locking, PDF/A-2b, encryption, digital signatures
See roadmap spec for full vision.
Working with the user
- User works on macOS, VS Code + Claude Code, Cursor
- Chinese (Simplified) + English — CJK rendering quality is critical
- Appreciates detailed spec discussions
- Prefers focused scope over premature features
- Respects the boundary between current release and future roadmap
When you're unsure
- Prefer simplicity over features
- Ask before implementing things not in the current version
- Check tests first — they document expected behavior
- Reference the docs site for user-facing behavior
- Minimal changes for bugs; surgical edits only
Appendix · General LLM Behavioural Guidelines
Guidelines from forrestchang/andrej-karpathy-skills.
1. Think Before Coding
Don't assume. State assumptions explicitly. Surface tradeoffs before implementing.
2. Simplicity First
Minimum code that solves the problem. No speculative features, abstractions, or error handling for impossible scenarios.
3. Surgical Changes
Touch only what you must. Match existing style. Remove only the orphans your changes created.
4. Goal-Driven Execution
Define success criteria. Turn vague requests ("make it work") into verifiable goals ("write a test, make it pass").
These guidelines work if: fewer unnecessary changes, fewer rewrites, and clarifying questions come before coding.
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
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.

