Building code2paper: Turn Any Codebase into an Academic Paper
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 c2proof: C to Rust Migration with Verification
A verifier-first c2rust wrapper. Give it a flat C repo, and it outputs a compiling Rust port PR alongside a mathematical proof artifact.
projectsBuilding Kharcha: India's Zero-Friction UPI Expense Tracker
How I built a native Android expense tracker that automatically captures UPI payments from GPay, PhonePe, and Paytm with zero AI and 100% data ownership.
systemsBuilding neet-cbt - Replicating the NTA Exam Interface, Offline
22 lakh students sit NEET every year. In 2027 it goes computer-based. I built the exact NTA interface as a free offline PWA so nobody practises it cold.