agentleFS
redfriesredfries/paper2tex/AGENTS.md

paper2tex

AGENTS.md1 starsChanged 3 months agoMITView on GitHub

If you are an AI agent (Claude Code, Cursor, OpenCode, Windsurf, Copilot, etc.), this file tells you how to use this tool. Read this first. You are converting a student's .docx paper to conference-formatted .tex. You have a full deterministic extraction pipeline. Your only creative job is assembling the extracted content into the template structure. Everything else is scripted. Before running extraction, ask the user: "Do you have a dedicated figures/ folder with high-resolution or vector images (e.g., ./figures), or…

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,736 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repositoryOne other file it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

9 rules. About 0 are common, 4 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before running extraction, ask the user:

    line 15
  2. Very specific:

    If the user replies 'extract': Run extraction without --figures-dir.

    line 18
  3. Distinctive:

    If anything is missing, install it (the script prints exact install commands).

    line 27
  4. Very specific:

    Use python scripts/assemble.py work/ for 100% deterministic assembly with template-aware subfigures (\subfloat in IEEEtran, subcaption in …

    line 55
  5. Very specific:

    Cross-references: use \cref{label} from manifest.json cross_ref_map

    line 61
  6. Very specific:

    Citations: use \cite{key} from references.bib keys

    line 62
  7. Distinctive:

    If errors remain after auto-fix, read the error, fix markup only (never content), recompile.

    line 71
  8. Distinctive:

    NEVER regenerate math: Use the registry values byte-for-byte.

    line 101
  9. Very specific:

    NEVER skip verification: Run verify.py before delivering.

    line 103

≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Agent Instructions for paper2tex

If you are an AI agent (Claude Code, Cursor, OpenCode, Windsurf, Copilot, etc.), this file tells you how to use this tool. Read this first.

TL;DR

You are converting a student's .docx paper to conference-formatted .tex. You have a full deterministic extraction pipeline. Your only creative job is assembling the extracted content into the template structure. Everything else is scripted.

Step-by-Step

0. Mandatory Upfront Figure Clarification (ASK THE USER FIRST)

Before running extraction, ask the user:

"Do you have a dedicated figures/ folder with high-resolution or vector images (e.g., ./figures), or should I extract the embedded images directly from the Word document? (Reply with your folder path or simply 'extract')"

  • If the user replies 'extract': Run extraction without --figures-dir. The pipeline will automatically extract, normalize, and auto-rotate all embedded drawings from .docx.
  • If the user provides a path (e.g., ./figures): Pass --figures-dir <path> to extraction. The pipeline will reconcile vector (.pdf, .svg) and high-res raster assets automatically.

1. Run preflight check

python scripts/preflight.py

If anything is missing, install it (the script prints exact install commands).

2. Run the main extraction pipeline

python scripts/extract.py <paper.docx> work/ [--figures-dir <path>]

This creates work/manifest.json and all registry files:

  • work/content.md — full document text as Markdown
  • work/content.tex — Pandoc's LaTeX output (reference only)
  • work/math_registry.json — all equations as LaTeX
  • work/table_registry.json — all tables as LaTeX \begin{tabular} blocks
  • work/figures/ — all figures, best quality available, properly rotated and normalized
  • work/figures_registry.json — figure metadata, subcaptions, aspect ratios
  • work/references.bib — bibliography in BibTeX format
  • work/manifest.json — counts, cross-ref map, special chars, warnings

3. Analyze the template

python scripts/template_spec.py "<conference name or template.zip>" work/

This creates work/template-spec.json with document class, packages, author format, bib style.

4. Assemble main.tex (Deterministic AST or LLM Assembly)

Use python scripts/assemble.py work/ for 100% deterministic assembly with template-aware subfigures (\subfloat in IEEEtran, subcaption in ACM/LNCS), or manually assemble following the 10 hard rules:

  1. Text is VERBATIM from content.md — zero rewording
  2. Math is COPIED from math_registry.json — never rewrite equations
  3. Tables are COPIED from table_registry.json — never restructure
  4. Figures use paths from the work/figures/ directory
  5. Cross-references use \cref{label} from manifest.json cross_ref_map
  6. Citations use \cite{key} from references.bib keys
  7. Ambiguous content → % TODO(paper2tex): describe issue comment

5. Compile

python scripts/compile.py work/main.tex

If errors remain after auto-fix, read the error, fix markup only (never content), recompile.

6. Verify

python scripts/verify.py work/main.tex
python scripts/visual_qa.py work/main.pdf work/

This produces work/report.md and renders PDF pages for visual inspection.

7. Package for delivery

# Copy final files to submission/
mkdir work/submission
copy work/main.tex work/submission/
copy work/references.bib work/submission/
xcopy work/figures work/submission/figures/ /E

# Create Overleaf zip
python scripts/overleaf_export.py work/submission/

Present report.md to the student.

ABSOLUTE RULES (non-negotiable)

  • ALWAYS ask about the figures folder before extraction.
  • NEVER rewrite, improve, or edit the student's text. Verbatim only.
  • NEVER regenerate math. Use the registry values byte-for-byte.
  • NEVER invent citation keys or labels. Registry keys only.
  • NEVER skip verification. Run verify.py before delivering.
  • When in doubt, add % TODO(paper2tex): ... comment. Don't guess.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.