Session guide: venv usage, convert.py workflow, whole-file synthesis convention (read all md/<topic>/, save syntheses back in-folder), git habits, and the pymupdf4llm pin + plain-text fallback gotchas. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3.0 KiB
3.0 KiB
CLAUDE.md
Operating guide for Claude Code in this repo. See README.md for the full
project description.
What this is
An AI-assisted research center. Source material lives by topic, gets converted to markdown, and you read whole markdown files to cross-reference and synthesize across a topic. This is deliberately not chunked RAG — read entire files.
Repo map
pdfs/<topic>/*.pdf— source PDFs. Gitignored (large, often copyrighted). Local only.md/<topic>/*.md— converted markdown and syntheses you write. This is what you read.convert.py— batch PDF→markdown converter.requirements.txt— pinspymupdf4llm==0.3.4(lightweight line; see Gotchas).needs-ocr.txt— generated list of no-text-layer PDFs. Gitignored..venv/— virtualenv. Gitignored.
Environment
Always use the venv. It is already built.
source .venv/bin/activate # or call ./.venv/bin/python directly
If a package is missing, pip install -r requirements.txt.
Converting PDFs
./.venv/bin/python convert.py # pdfs/ -> md/, idempotent (skips current files)
./.venv/bin/python convert.py --force # reconvert everything
- Idempotent on mtime — safe to rerun; only new/changed PDFs convert.
- Adding a topic:
mkdir pdfs/<topic>, drop PDFs in, runconvert.py. - After converting, check the summary line and
needs-ocr.txtfor anything flagged.
Doing synthesis (the main job)
When asked to synthesize a topic:
- Read every file under
md/<topic>/— full files, not snippets. - Cross-reference across documents; cite using page boundaries (
-----separators mark PDF pages) and the source name in each file's header. - Save the result as a new markdown file in that topic folder, e.g.
md/<topic>/<slug>-synthesis.md, unless told otherwise. - Syntheses are part of the record — they get committed.
Git conventions
- Treat this repo as code: everything goes in git except what
.gitignoreexcludes (PDFs,.venv/,.claude/,needs-ocr.txt). - Commit converted markdown and syntheses. Do not commit source PDFs.
- Commit when a unit of work is done (a topic converted, a synthesis written). Don't push unless asked.
Gotchas
- pymupdf4llm is pinned to
0.3.4on purpose. The1.27.xreleases bundle an ML layout/OCR pipeline (onnxruntime + Tesseract) that fails on plain text PDFs without a tessdata install. Don't "upgrade" it without testing a full conversion pass. - Plain-text fallback: on some PDFs pymupdf4llm emits near-empty markdown
despite a real text layer.
convert.pydetects this and falls back to plain per-page text (logged[plain-text fallback]). Those files lose heading/table structure but keep all text — still fine to read. - For poor conversions or scans: use
marker-pdf/docling(OCR + layout) ormarkitdown(DOCX/PPTX/XLSX/HTML) on the single problem file, then drop the result into the matchingmd/<topic>/path. See README → Fallbacks.