Building code2paper: Turn Any Codebase into an Academic Paper
A stdlib Python CLI and Claude Agent Skill to convert an entire codebase into a readable academic paper in Typst, LaTeX, PDF, and HTML.
Codebases are getting larger, and understanding them from raw files or scattered markdown is tedious. I wanted a way to distill a repository into a single, cohesive academic-style paper.
That's why I built code2paper. It turns any codebase into a structured document in multiple formats: Typst, LaTeX, PDF, and WebPaper HTML.
The Problem
When you onboard onto a new project or review a massive PR, you are forced to jump between files, grep for types, and read disconnected docstrings. Documentation generators build wikis, but wikis lack the linear, narrative flow of an academic paper.
I needed a tool that takes a repository and outputs a single readable document.
How code2paper Works
At its core, code2paper is a standard library Python CLI. No heavy dependencies, no massive node_modules folder.
- Extraction: It traverses the codebase, applying gitignore rules and skipping binary/irrelevant files.
- Analysis: It extracts the structure, functions, classes, and comments.
- Generation: It generates a high-quality academic paper format. You get Typst for fast modern typesetting, LaTeX for traditional academic pipelines, PDF for immediate reading, and HTML for the web.
Claude Agent Skill Integration
I didn't just build this as a standalone CLI. I packaged it as a Claude Agent Skill. This allows AI coding agents to read an entire repository as a single structured document, significantly improving context retention and reasoning over the codebase compared to raw file dumps.
Why Typst?
Typst is fast, Rust-based, and compiles instantly compared to LaTeX. Supporting it out-of-the-box means you get beautiful PDFs without fighting a huge TeX Live installation.
What's Next
The next step is improving the summarization logic. Instead of just concatenating and formatting, integrating a local LLM step to write actual prose explaining the architecture before diving into the code blocks.
Written in Python. Single CLI. Available as a Claude Agent Skill.
More Essays
Building jev-curate: Fast Synthetic Dataset Sifter in Rust
Filtering synthetic training data with TypeSafe AI Jev: streaming JSONL and Parquet rows through calibrated System One gates at 70ms latency with zero memory accumulation. � 5 min
systemsBuilding jev-git: Sub-Second Git Reflex Gate in Rust
Screening staged git diffs for leaked secrets, destructive payloads, and AI hallucinations in 80ms using TypeSafe AI Jev System One. � 4 min
systemsBuilding jev-scout: Zero-Hallucination Crate and Repo Scout
Preventing AI package hallucinations: discovering real crates and GitHub repositories using live registry APIs and TypeSafe Jev speculative fan-out scoring. � 4 min