agentleFS
raymond802raymond802/md-to-pdf/CLAUDE.md

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
  1. Distinctive:

    AST-first: All markdown → markdown-it-py → internal AST → render.

    line 82
  2. Very specific:

    Single orchestrator: Every render path goes through Pipeline.render(RenderRequest) → RenderResult.

    line 83
  3. Distinctive:

    Prefer simplicity over features

    line 125
  4. Distinctive:

    Ask before implementing things not in the current version

    line 126
  5. Distinctive:

    Check tests first — they document expected behavior

    line 127
  6. Distinctive:

    Don't assume. State assumptions explicitly.

    line 139

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md
<!-- 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)

LayerStatusLocation
Core engine✅ Stablesrc/mdpdf/ (pipeline, cli, markdown/parser, render/reportlab, etc.)
Brand packs✅ Completeexamples/brands/ (schema + 3-layer registry)
Watermarking✅ CompleteL1 (visible) + L2 (XMP metadata)
CJK fonts✅ CompleteNoto Sans SC + font manager in src/mdpdf/fonts/
Tests✅ 443 passingtests/unit/, tests/integration/, tests/golden/
Documentation✅ Livehttps://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 on src/mdpdf/
  • License: Apache-2.0 (patent grant clause; do not change without discussion)
  • Commits: Conventional Commits + DCO sign-off required
  • Branch protection: PRs to main require 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/location

Testing & 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/mdpdf

Architectural 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. RenderEngine ABC with one concrete engine_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-assets flag 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

ArtifactPath
New source codesrc/mdpdf/<module>/
New unit teststests/unit/<module>/
New integration teststests/integration/
Golden/UAT teststests/golden/
Example brandsexamples/brands/
Example inputsexamples/inputs/
Feature specsdocs/superpowers/specs/
Implementation plansdocs/superpowers/plans/
User docsdocs/ (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

  1. Prefer simplicity over features
  2. Ask before implementing things not in the current version
  3. Check tests first — they document expected behavior
  4. Reference the docs site for user-facing behavior
  5. 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.

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.