Add paper CLI: download academic papers by DOI and convert to markdown

Downloads PDFs from LibGen (primary) or Anna's Archive API (fallback),
converts to markdown via marker_single, and prints to stdout. Includes
XDG-compliant caching, nix flake with marker-pdf packaging, and a
Claude Code skill for paper-reader integration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ellie 2026-02-19 22:54:30 -08:00
commit f82b738db7
10 changed files with 2860 additions and 0 deletions

41
skill/SKILL.md Normal file
View file

@ -0,0 +1,41 @@
---
name: paper-reader
description: Fetch and read academic papers by DOI. Use when (1) the user mentions a DOI (e.g., 10.1038/nature12373), asks to read/summarize/analyze a research paper, or references a paper they want to work with, or (2) Claude needs to consult a specific paper as part of research — e.g., a web search returns a relevant DOI, or a cited paper would help answer the user's question. Converts PDFs to markdown so the paper content can be read and discussed.
---
# Paper Reader
Fetch academic papers by DOI using the `paper` CLI, which downloads PDFs and converts them to markdown via `marker_single`.
## Usage
```bash
# Fetch a paper and save to a temp file, then read it
paper <DOI> > /tmp/paper.md
# Bypass cache to re-download
paper --no-cache <DOI> > /tmp/paper.md
```
Output goes to stdout (markdown). Progress/status goes to stderr. DOIs can be passed with or without the `https://doi.org/` prefix.
## Workflow
1. Extract the DOI from the user's message (look for patterns like `10.xxxx/...`)
2. Run `paper <DOI> > /tmp/paper-<sanitized-doi>.md` via Bash
3. Read the resulting markdown file
4. Respond to what the user asked (summarize, explain, answer questions, etc.)
## Caching
Results are cached at `~/.cache/paper/<DOI>.md`. Subsequent requests for the same DOI return instantly. Use `--no-cache` only when the user explicitly wants a fresh conversion.
## Download Sources
The tool tries LibGen first (free, no authentication), then falls back to Anna's Archive fast download API if `ANNAS_ARCHIVE_KEY` is set.
## Errors
- **"marker_single not found"**: The `marker_single` Python tool is not installed. Run `pip install marker-pdf` or use the nix devshell in `~/proj/paper`.
- **"no results found on LibGen"**: The DOI may not be in LibGen's collection. Verify the DOI is correct.
- **"all download sources failed"**: Neither LibGen nor Anna's Archive had the paper. The user may need to find it manually.