Metadata-Version: 2.4
Name: citepair
Version: 0.1.3
Summary: Pair each LaTeX citation with the local source PDF so an agent can judge whether the source supports the sentence.
License-Expression: MIT
Project-URL: Homepage, https://github.com/shiven2001/citepair
Project-URL: Issues, https://github.com/shiven2001/citepair/issues
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pypdf>=4.0
Dynamic: license-file

<div align="center">

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/shiven2001/citepair/main/docs/logo-dark.png">
  <img src="https://raw.githubusercontent.com/shiven2001/citepair/main/docs/logo-light.png" width="620" alt="CitePair: Does the cited paper actually say that?">
</picture>

[![PyPI](https://img.shields.io/pypi/v/citepair?color=2f44c8)](https://pypi.org/project/citepair/) ![Python](https://img.shields.io/badge/python-3.9%2B-3776ab) [![License: MIT](https://img.shields.io/badge/license-MIT-0b9c8f)](https://github.com/shiven2001/citepair/blob/main/LICENSE) [![Agent Skill](https://img.shields.io/badge/agent%20skill-Claude%20Code%20%C2%B7%20Codex%20%C2%B7%20Cursor-f59e0b)](https://agentskills.io)

### "A citation is a promise. Check it."

</div>

- CitePair is a final check before you submit: does each source you cite actually say what your sentence says? It is an open-source [Agent Skill](https://agentskills.io) for LaTeX papers.
- Sentences drift. You write "the method handles shadows and mortar lines [12]", but [12] only covers shadows. CitePair marks that **partial**, quotes what [12] does say with its page number, and suggests a sentence that matches it.
- For every citation you get a verdict for that one sentence: **supported** (with the quote and page), **partial**, **not supported**, or **no data found**.
- It looks every reference up on Crossref, OpenAlex, Semantic Scholar, and arXiv, and flags references that look **hallucinated**, are **missing fields**, or were **retracted**.
- **Fix the sentence, not the citation.** It never edits your paper and never goes looking for a new paper to prop up a claim. It suggests rewording the sentence to match the source, or removing the citation, and you decide.
- It works in Claude Code, Codex, Cursor, and any other agent that reads `SKILL.md` skills. It is free and MIT licensed.

> Note: the verdict is the AI agent's judgment, so it can be wrong. Every verdict comes with the quote and page number, so you can check it in seconds.

<p>
<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/shiven2001/citepair/main/docs/demo.png">
  <img src="https://raw.githubusercontent.com/shiven2001/citepair/main/docs/demo-light.png" width="760" alt="CitePair checking five citations in the demo paper: two supported with quotes and page numbers, one partial, one not supported, and one hallucinated reference whose DOI points to a different paper.">
</picture>
</p>

The output above comes from the [demo paper](https://github.com/shiven2001/citepair/tree/main/examples/demo-paper), which you can run yourself.

## Who it's for

- **Authors, before submitting.** It catches a misremembered result, the wrong paper with a similar title, or a sentence that grew during editing.
- **Supervisors and co-authors** checking a student's or a colleague's sections.
- **Reviewers and editors** checking the key citations in a submission.
- **Anyone who drafts with AI tools** and wants every citation checked against the source.

It does not replace reading the papers you cite. It tells you what to read, and where: each verdict comes with the passage and page number, and the citations that don't hold up are marked so you read those first.

## Set up

```bash
git clone https://github.com/shiven2001/citepair.git
mkdir -p ~/.agents/skills
ln -sfn "$PWD/citepair/skills/citepair" ~/.agents/skills/citepair   # Codex and other agents
```

`~/.agents/skills` is the shared folder many agents read. Some use their own folder instead, so link there too:

```bash
ln -sfn "$PWD/citepair/skills/citepair" ~/.claude/skills/citepair   # Claude Code
ln -sfn "$PWD/citepair/skills/citepair" ~/.cursor/skills/citepair   # Cursor
```

For any other agent, link `skills/citepair` into its skills folder. An agent without skill support can still use it: ask it to read `skills/citepair/SKILL.md` and follow it.

It needs Python 3.9 or later with `pypdf`, or `uv`. Nothing else has to be installed.

## Use

1. Compile the paper once, so the `.aux` or `.bbl` file exists.
2. Put the PDFs of the cited works in a `references/` folder inside the paper. File names do not matter: each PDF is matched by its bib key or its title.
3. Ask in plain words:

- "Does [12] support the sentences it's cited in?"
- "Check the citations in the second paragraph of the introduction."
- "Is mills2009defect a real reference? Was it retracted?"
- "Check every citation in the paper and write a report."

A question about one citation is answered in the conversation. A full check writes a report to `reports/`.

To try it first, run `examples/demo-paper/fetch-pdfs.sh` and ask: "Check the citations in examples/demo-paper."

## Verdicts

Each sentence gets its own verdict, because one source can support one sentence and not another.

- **supported**: the source states the claim (quoted, with its page number)
- **partial**: the source covers the topic, but the sentence says more than the source does
- **not supported**: the source says something else, or the work was retracted
- **no data found**: no PDF, or the PDF is a different work

References are looked up on Crossref, OpenAlex, Semantic Scholar, and arXiv. A reference counts as hallucinated only when its DOI or arXiv id points to a different paper, or when nothing close to it exists.

## Limitations

- **LaTeX only.** Word, Google Docs, and Markdown papers are not supported.
- **You supply the PDFs.** It does not download papers for you, so a reference without a local PDF gets no data found.
- **The agent can be wrong.** The verdict is the AI agent's judgment. It always shows the quote and page number so you can check it in seconds.
- **Text only.** A claim stated only in a figure, table, or equation, or a scanned PDF with no text layer, usually comes back as no data found.
- **Not every real reference has a record.** Software, datasets, and standards often have none. They are marked not confirmed, never hallucinated.
- **What leaves your machine.** Online lookups send only reference titles, DOIs, and arXiv ids, plus your email if you set `CITEPAIR_MAILTO`. Your paper's text is read by whichever AI agent you use.

## Command line (optional)

```bash
pip install citepair
citepair PAPER_DIR --ref 12 -o -                         # one reference, printed
citepair PAPER_DIR --file 1_intro.tex --paragraphs 2 -o -
citepair PAPER_DIR --online -o reports/paper.md          # whole paper, with online lookups
```

The tool collects the evidence. The agent decides the verdict. `citepair --help` lists every option, and `config.example.json` shows the same settings as a config file. For faster online lookups, set `CITEPAIR_MAILTO=you@example.org`.

## Tests

```bash
PYTHONPATH=skills/citepair/scripts python3 -m unittest discover -s tests
```

## License

MIT. See [LICENSE](https://github.com/shiven2001/citepair/blob/main/LICENSE).
