# Paper2code

Converts an arxiv paper into a minimal, citation-anchored Python implementation.

- Repository: https://github.com/PrathamLearnsToCode/paper2code (1541 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-04-03
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add PrathamLearnsToCode/paper2code --skill paper2code -g -a claude-code -y`
Codex: `npx skills add PrathamLearnsToCode/paper2code --skill paper2code -g -a codex -y`
Cursor: `npx skills add PrathamLearnsToCode/paper2code --skill paper2code -g -a cursor -y`
Gemini CLI: `npx skills add PrathamLearnsToCode/paper2code --skill paper2code -g -a gemini-cli -y`

## Description

Converts an arxiv paper into a minimal, citation-anchored Python implementation. Trigger when user runs /paper2code with an arxiv URL or paper ID, says "implement this paper", or pastes an arxiv link asking for implementation. Flags all ambiguities honestly. Never invents implementation details not stated in the paper.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# paper2code, Orchestration

You are executing the paper2code skill. This file governs the high-level flow. Each stage dispatches to a detailed reasoning protocol in `pipeline/`. Do NOT skip stages. Do NOT combine stages. Execute them in order.

## Parse arguments

Extract from the user's input:
- `ARXIV_ID`: the arxiv paper ID (e.g., `2106.09685`). Strip any URL prefix.
- `MODE`: one of `minimal` (default), `full`, `educational`.
- `FRAMEWORK`: one of `pytorch` (default), `jax`, `numpy`.

If the user provided a full URL like `https://arxiv.org/abs/2106.09685`, extract the ID `2106.09685`.
If the user provided a versioned ID like `2106.09685v2`, keep the version.

## Set up working directory

Create a temporary working directory: `.paper2code_work/{ARXIV_ID}/`
This is where intermediate artifacts go. The final output goes in the current directory under `{paper_slug}/`.

## Install dependencies

Run via Bash:
```bash
pip install pymupdf4llm pdfplumber requests pyyaml
```

## Execute pipeline

### Stage 1, Paper Acquisition and Parsing
Read and follow: `pipeline/01_paper_acquisition.md`

Run the helper script to fetch and parse the paper:
```bash
python skills/paper2code/scripts/fetch_paper.py {ARXIV_ID} .paper2code_work/{ARXIV_ID}/
```
Then run structure extraction:
```bash
python skills/paper2code/scripts/extract_structure.py .paper2code_work/{ARXIV_ID}/paper_text.md .paper2code_work/{ARXIV_ID}/
```
Verify the outputs exist before proceeding. If extraction failed, follow the fallback protocol in `pipeline/01_paper_acquisition.md`.

The script also searches for official code repositories (in the paper text and on the arxiv page) and saves any found links to `paper_metadata.json` under the `official_code` key. Verify these links before relying on them, see Step 8 in `pipeline/01_paper_acquisition.md`.

### Stage 2, Contribution Identification
Read and follow: `pipeline/02_contribution_identification.md`

The rest: https://github.com/PrathamLearnsToCode/paper2code/blob/HEAD/skills/paper2code/SKILL.md
