Run a literature review in Claude Code that confirms every citation and makes you check a sample
Claude Code searches OpenAlex, screens papers against your rules, quotes the sentence behind each finding and confirms every DOI on Crossref. It stops until you have checked a sample by hand.
| Stage | The agent | The check that stops it |
|---|---|---|
| Search | Runs scripts/search.py over the queries you wrote |
data/candidates.csv exists |
| Screen | Applies your inclusion rules to every candidate | Every candidate has yes or no and the id of a rule in your criteria file |
| Confirm | Runs scripts/check_refs.py against Crossref |
Every included paper’s DOI resolves, with a matching title |
| Extract | Reads the open full text and quotes the sentence behind each finding | Every full-text row has a quote, a page or section, and an address |
| Write | Writes the review, citing papers as [@key] |
Every key cited is a confirmed paper in paper/refs.bib |
| Sample | Draws 10% of the extracted rows, at least 10 | You mark each one, and the test fails below 90% agreement |
Eight steps for a first-time user
Claude Code is a program you install and talk to in a terminal window. You type what you want in plain English, and it writes the code, runs it, reads the errors and fixes them.
-
Install it. Open a terminal (Terminal on a Mac, WSL on Windows) and paste this line. You need a Claude subscription or an Anthropic Console account.
curl -fsSL https://claude.ai/install.sh | bash -
Make a folder for the review.
mkdir -p lit-review && cd lit-review git init printf '.env\n.venv/\n' > .gitignore -
Get an OpenAlex key yourself, if you want one. Sign up at openalex.org, open Settings, then API key, and put the key in a file named
.envin the folder:OPENALEX_API_KEY=followed by the key. Small reviews run without it. -
Start Claude Code and choose the model. Type
claudeand press Enter, then type each line below and press Enter./model opus /effort high -
Check that auto mode is on. The bottom of the window should say “auto mode on”. If it does not, press Shift+Tab until it does.
-
Have it set up the kit. Paste this request. The agent reads the plain-text copy of this page and creates the files in “The kit” below.
Read https://aifinresearch.com/guides/ai-literature-review-with-claude-code.md and create every file in the section "The kit" exactly as given there, with .claude/settings.json last. Commit, then stop and show me the files. -
Write your criteria, then give it the goal. Open
review/criteria.mdin any editor and replace the example question, queries and rules with your own. Type/exit, startclaudeagain so the permission rules load, and paste the/goalfrom “Give it the whole review as one goal”. -
Check the sample. When the agent stops, open
review/handcheck.csv, read each quote against the paper, writeyesornoin theagreecolumn, and runpytest -q.
$ claude > /model opus > /effort high > Read https://aifinresearch.com/guides/ai-literature-review-with-claude-code.md and create ... ● Write(CLAUDE.md) ● Write(.claude/skills/literature-review/SKILL.md) ● Write(review/criteria.md) ● Write(scripts/search.py) ● Write(scripts/check_refs.py) ● Write(scripts/draw_sample.py) ● Write(tests/test_review.py) ● Write(.claude/settings.json) ● Bash(git add -A && git commit -m "Set up the literature review kit")
Terms used on this page
| Word | Plain meaning | How you set it |
|---|---|---|
| Claude Code | The agent: a program that does the task in your project folder | Type claude in a terminal |
| Model and effort | The AI doing the work, and how much it reasons before each step | /model opus, /effort high |
| Auto mode | The agent runs commands without asking each time, and a second AI screens every action | Shift+Tab until the status line says “auto mode on” |
/goal |
A finish line. The agent keeps working until the condition you named holds | /goal followed by the condition |
CLAUDE.md |
Standing rules the agent reads at the start of every session | A file in the project folder |
| Skill | A saved procedure the agent loads when the task calls for it | A folder under .claude/skills/ holding a SKILL.md |
| OpenAlex | A free catalog of research papers with a public API | scripts/search.py |
| Crossref | The registry behind most DOIs. A DOI that resolves there exists | scripts/check_refs.py |
| Deny rule | A file the agent’s own file tools may not read or change | .claude/settings.json |
You write the rules before the agent reads a paper
The criteria file holds the question, the search queries, the years, numbered inclusion and exclusion rules, and the fields to extract from each paper. The agent screens with your rules and cites a rule id for every decision, so a reader of the review can see why each paper is in or out. A deny rule stops the agent’s file tools from editing the criteria, the tests or your answers in the hand check.
Every citation is confirmed on Crossref
A model that writes a bibliography from memory produces papers that do not exist. GPTZero scanned 4,841 papers accepted to NeurIPS 2025 and confirmed 100 fabricated citations in 51 of them. The kit never lets the model write a reference. scripts/check_refs.py looks up each DOI on Crossref, compares the title with the one OpenAlex gave, writes the BibTeX entry from Crossref’s own record and fails if anything does not match.
A run on the example topic in the criteria file, on 5 November 2026, stopped on a DOI whose Crossref title differs from the title OpenAlex lists for it:
$ python scripts/check_refs.py
5 of 6 confirmed on Crossref
FAILED 10.1016/j.jcorpfin.2021.101964 title mismatch: Which buy-side institutions participate in public earnings conference calls? Implications for capital markets and sell-side coverage
The agent cannot finish the goal until it resolves the mismatch, by finding the right DOI or by excluding the paper with a rule.
Check a sample by hand before you trust the table
A 2026 study of LLM-assisted reviews used ChatGPT to read economics papers that use rainfall as an instrument. The models did well at yes-or-no classification, and accuracy fell as the reading needed more context. The authors found that the same error rate barely moves claims about a literature as a whole and badly distorts claims about single papers, “precisely the level of detail that constitutes an LLM’s principal value added over human reviewers.” Our brief on the paper.
scripts/draw_sample.py draws 10% of the extracted rows, at least 10, with a fixed seed. You read each quote against the paper and mark whether the finding is right. The test fails if you agree with fewer than 90%. Raise the bar in tests/test_review.py if your field needs it.
The bibliography goes straight into Zotero
paper/refs.bib is a standard BibTeX file built from Crossref’s records. In Zotero, choose File, then “Import…”, then “A file”, and pick paper/refs.bib. Pandoc reads the same file, so review/review.md with its [@key] citations converts to a formatted draft.
Give it the whole review as one goal
After you have written your criteria and restarted Claude Code, paste this:
/goal Steps 1 to 6 in CLAUDE.md are done, review/review.md answers the
question in review/criteria.md, and pytest -q shows no failures. Print the
pytest summary line as the last thing you write.
The hand-check test is skipped until you fill in the sample, so the goal can finish without you. The review is not finished until pytest -q passes with the sample filled in.
The kit
Instruction file
Save as CLAUDE.md.
# Literature review
The question, the queries and the screening rules are in review/criteria.md.
Only the researcher edits review/criteria.md, tests/ and the agree and note
columns of review/handcheck.csv.
## Steps
Commit after each step whose check passes, with a message that names the step.
1. Search: python3 scripts/search.py writes data/candidates.csv.
2. Screen: use the literature-review skill. Write data/screened.csv.
3. Confirm: python3 scripts/check_refs.py must print "N of N confirmed".
On a failure, find the right DOI or exclude the paper with a rule.
4. Extract: use the literature-review skill. Write review/extraction.csv.
5. Write: review/review.md answers the question, citing papers as [@key].
6. Sample: python3 scripts/draw_sample.py, then stop and ask the researcher
to fill in review/handcheck.csv.
## Rules
- Never invent a paper, DOI, quote, page or number. Write "not reported"
when a paper does not say.
- A quote is copied word for word from the paper, with its page or section.
- Never add an email address or a key to a request yourself. The scripts
read them from .env only if the researcher put them there.
- Install pytest in .venv if it is missing. Run pytest -q before every commit.
Literature review skill
Save as .claude/skills/literature-review/SKILL.md.
---
name: literature-review
description: Screen candidate papers against review/criteria.md and extract the fields it lists, with a quote and location for each finding. Use for steps 2 and 4 of the review.
---
## Screening (step 2)
For every row in data/candidates.csv, read the title and abstract and decide
include yes or no. Give one reason: the id of the rule in review/criteria.md
that decides it (I1, E1 and so on). Include a paper only if every I rule
holds and no E rule applies. With no abstract, read the paper at oa_url.
Write data/screened.csv with columns id, doi, title, year, include, reason.
## Extraction (step 4)
For every entry in paper/refs.bib, write one row of review/extraction.csv
with columns key, doi, design, data, sample, finding, read, quote, where,
source_url. Answer each field as review/criteria.md defines it.
When the full text is open at oa_url, set read to "full text", copy the
sentence that supports the finding word for word into quote, and give the
page or section in where and the address you read in source_url.
When only the abstract is available, set read to "abstract" and leave
quote, where and source_url empty.
Criteria file
Save as review/criteria.md. The example is the one the scripts were run on. Replace it with your own question before the goal.
# Review criteria
Only the researcher edits this file.
## Question
How do finance studies measure tone in earnings calls, and what do they find about returns?
## Years
2015-2025
## Queries
- earnings call tone stock returns
- conference call textual analysis sentiment
## Include
- I1: Empirical study that measures tone or sentiment in earnings or conference calls.
- I2: Reports an association with stock returns, volatility or analyst forecasts.
## Exclude
- E1: Not about earnings or conference calls.
- E2: Method or software paper with no finance outcome.
- E3: Not a research paper (editorial, book review, erratum).
## Extract
- design: the identification or estimation approach, in a few words
- data: the call transcripts' source and the market data used
- sample: market, years and number of calls or firms
- finding: the main result, with its sign
Search script
Save as scripts/search.py.
"""Search OpenAlex for every query in review/criteria.md and write data/candidates.csv."""
import csv, json, os, re, time, urllib.parse, urllib.request
from pathlib import Path
def env(name):
if os.environ.get(name):
return os.environ[name]
if Path('.env').exists():
for line in Path('.env').read_text().splitlines():
if line.startswith(name + '='):
return line.split('=', 1)[1].strip()
return ''
def section(text, title):
m = re.search(rf'^## {title}\n(.*?)(?=^## |\Z)', text, re.M | re.S)
return m.group(1).strip() if m else ''
def abstract(inverted):
if not inverted:
return ''
words = {pos: w for w, places in inverted.items() for pos in places}
return ' '.join(words[i] for i in sorted(words))
criteria = Path('review/criteria.md').read_text()
queries = [line[2:].strip() for line in section(criteria, 'Queries').splitlines() if line.startswith('- ')]
years = section(criteria, 'Years').replace(' ', '')
key = env('OPENALEX_API_KEY')
fields = 'id,doi,display_name,publication_year,primary_location,abstract_inverted_index,best_oa_location,cited_by_count'
rows = {}
for q in queries:
params = {'search': q, 'filter': f'publication_year:{years}', 'per_page': '100', 'select': fields}
if key:
params['api_key'] = key
url = 'https://api.openalex.org/works?' + urllib.parse.urlencode(params)
with urllib.request.urlopen(urllib.request.Request(url, headers={'User-Agent': 'literature-review-script'}), timeout=60) as r:
results = json.load(r)['results']
for w in results:
source = ((w.get('primary_location') or {}).get('source') or {}).get('display_name', '')
oa = (w.get('best_oa_location') or {})
rows.setdefault(w['id'], {
'id': w['id'], 'doi': (w.get('doi') or '').replace('https://doi.org/', ''),
'title': w.get('display_name') or '', 'year': w.get('publication_year'), 'venue': source,
'cited_by': w.get('cited_by_count', 0), 'oa_url': oa.get('pdf_url') or oa.get('landing_page_url') or '',
'abstract': abstract(w.get('abstract_inverted_index')), 'query': q,
})
time.sleep(1)
Path('data').mkdir(exist_ok=True)
with open('data/candidates.csv', 'w', newline='') as f:
writer = csv.DictWriter(f, fieldnames=['id', 'doi', 'title', 'year', 'venue', 'cited_by', 'oa_url', 'abstract', 'query'])
writer.writeheader()
writer.writerows(rows.values())
print(f'{len(rows)} candidates from {len(queries)} queries written to data/candidates.csv')
Reference check script
Save as scripts/check_refs.py.
"""Confirm every included paper on Crossref, write paper/refs.bib and data/refcheck.csv."""
import csv, difflib, json, os, re, sys, time, urllib.parse, urllib.request
from pathlib import Path
def env(name):
if os.environ.get(name):
return os.environ[name]
if Path('.env').exists():
for line in Path('.env').read_text().splitlines():
if line.startswith(name + '='):
return line.split('=', 1)[1].strip()
return ''
def norm(text):
return re.sub(r'[^a-z0-9 ]', '', re.sub(r'<[^>]+>', '', text.lower())).strip()
mailto = env('CROSSREF_MAILTO')
included = [r for r in csv.DictReader(open('data/screened.csv')) if r['include'] == 'yes']
entries, checks, keys = [], [], set()
for row in included:
status, key = 'ok', ''
if not row['doi']:
status = 'no doi'
else:
url = 'https://api.crossref.org/works/' + urllib.parse.quote(row['doi'])
if mailto:
url += '?mailto=' + urllib.parse.quote(mailto)
try:
with urllib.request.urlopen(urllib.request.Request(url, headers={'User-Agent': 'literature-review-script'}), timeout=60) as r:
m = json.load(r)['message']
except Exception as error:
m, status = None, f'not found ({error})'
if m:
title = (m.get('title') or [''])[0]
if difflib.SequenceMatcher(None, norm(title), norm(row['title'])).ratio() < 0.9:
status = 'title mismatch: ' + title
else:
authors = m.get('author') or [{'family': 'Anon'}]
year = ((m.get('issued') or {}).get('date-parts') or [[row['year']]])[0][0]
first = re.sub(r'[^A-Za-z]', '', authors[0].get('family', 'Anon')) or 'Anon'
word = next((w for w in norm(title).split() if len(w) > 3), 'paper')
key = f'{first.lower()}{year}{word}'
while key in keys:
key += 'b'
keys.add(key)
names = ' and '.join(f"{a.get('family', '')}, {a.get('given', '')}".strip(', ') for a in authors)
venue = (m.get('container-title') or [''])[0]
entries.append(f'@article{{{key},\n title = {{{title}}},\n author = {{{names}}},\n journal = {{{venue}}},\n year = {{{year}}},\n doi = {{{row["doi"]}}}\n}}\n')
time.sleep(0.25)
checks.append({'id': row['id'], 'doi': row['doi'], 'key': key, 'status': status})
Path('paper').mkdir(exist_ok=True)
Path('paper/refs.bib').write_text('\n'.join(entries))
with open('data/refcheck.csv', 'w', newline='') as f:
writer = csv.DictWriter(f, fieldnames=['id', 'doi', 'key', 'status'])
writer.writeheader()
writer.writerows(checks)
bad = [c for c in checks if c['status'] != 'ok']
print(f'{len(checks) - len(bad)} of {len(checks)} confirmed on Crossref')
for c in bad:
print(' FAILED', c['doi'] or c['id'], c['status'])
sys.exit(1 if bad else 0)
Sample script
Save as scripts/draw_sample.py.
"""Draw the rows the researcher checks by hand: 10% of review/extraction.csv, at least 10."""
import csv, random
rows = list(csv.DictReader(open('review/extraction.csv')))
random.seed(2026)
sample = random.sample(rows, min(len(rows), max(10, len(rows) // 10)))
with open('review/handcheck.csv', 'w', newline='') as f:
writer = csv.DictWriter(f, fieldnames=['key', 'finding', 'quote', 'where', 'source_url', 'agree', 'note'])
writer.writeheader()
for r in sample:
writer.writerow({k: r.get(k, '') for k in ['key', 'finding', 'quote', 'where', 'source_url']} | {'agree': '', 'note': ''})
print(f'{len(sample)} rows written to review/handcheck.csv. Fill agree with yes or no for each.')
Test file
Save as tests/test_review.py.
"""Checks for the literature review. The agent may not edit this file."""
import csv, re
from pathlib import Path
import pytest
CRITERIA = Path('review/criteria.md').read_text()
RULES = set(re.findall(r'^- ([IE]\d+):', CRITERIA, re.M))
def rows(path):
return list(csv.DictReader(open(path))) if Path(path).exists() else []
def test_every_candidate_was_screened_with_a_rule():
candidates = {r['id'] for r in rows('data/candidates.csv')}
screened = rows('data/screened.csv')
assert candidates and candidates == {r['id'] for r in screened}
for r in screened:
assert r['include'] in ('yes', 'no'), r['id']
assert r['reason'] in RULES, f"{r['id']}: reason {r['reason']!r} is not a rule in criteria.md"
def test_every_included_paper_is_confirmed_on_crossref():
included = {r['id'] for r in rows('data/screened.csv') if r['include'] == 'yes'}
checked = {r['id']: r['status'] for r in rows('data/refcheck.csv')}
assert included, 'no paper was included'
for pid in included:
assert checked.get(pid) == 'ok', f'{pid}: {checked.get(pid, "not checked")}'
def test_every_extraction_row_has_its_evidence():
keys = set(re.findall(r'@article\{([^,]+),', Path('paper/refs.bib').read_text()))
extraction = rows('review/extraction.csv')
assert {r['key'] for r in extraction} == keys, 'extraction.csv must hold one row per entry in refs.bib'
for r in extraction:
for field in ('design', 'data', 'sample', 'finding', 'read'):
assert r[field].strip(), f"{r['key']}: {field} is empty"
assert r['read'] in ('full text', 'abstract'), r['key']
if r['read'] == 'full text':
assert r['quote'].strip() and r['where'].strip() and r['source_url'].startswith('http'), r['key']
def test_review_cites_only_confirmed_papers():
text = Path('review/review.md').read_text()
cited = set(re.findall(r'@([A-Za-z0-9_]+)', text))
keys = set(re.findall(r'@article\{([^,]+),', Path('paper/refs.bib').read_text()))
assert cited, 'review.md cites nothing'
assert cited <= keys, f'cited but not in refs.bib: {sorted(cited - keys)}'
def test_handcheck():
sample = rows('review/handcheck.csv')
if not sample or any(r['agree'] not in ('yes', 'no') for r in sample):
pytest.skip('review/handcheck.csv is not filled in yet')
agreed = sum(r['agree'] == 'yes' for r in sample) / len(sample)
assert agreed >= 0.9, f'you agreed with {agreed:.0%} of the sampled rows; fix the extraction and draw again'
Settings file
Save as .claude/settings.json. The sandbox limits the scripts to OpenAlex, Crossref and the Python package index. Claude Code’s own web reading tool runs outside the sandbox under the permission rules, so the agent can still open a paper’s full text on any site.
{
"permissions": {
"deny": [
"Read(./.env)",
"Edit(./tests/**)",
"Edit(./review/criteria.md)",
"Edit(./review/handcheck.csv)"
]
},
"sandbox": {
"enabled": true,
"network": {
"allowedDomains": ["api.openalex.org", "api.crossref.org", "pypi.org", "files.pythonhosted.org"]
}
}
}
References
- Authentication and rate limits, OpenAlex help.openalex.org
- API recipes, OpenAlex help.openalex.org
- REST API access and authentication, Crossref crossref.org
- How do I import BibTeX or other standardized formats?, Zotero zotero.org
- Mining Meaning: Measurement Error in AI-Assisted Literature Reviews (2026) arxiv.org
- GPTZero finds 100 new hallucinations in NeurIPS 2025 accepted papers, GPTZero (2026) gptzero.me
- Keep Claude working toward a goal, Anthropic code.claude.com
- Extend Claude with skills, Anthropic code.claude.com
- Configure permissions, Anthropic code.claude.com
- Sandboxing, Anthropic code.claude.com