Hook in academic
citation-guard
A PostToolUse hook that checks every cite key in a .tex or .md file Claude just edited against the project's .bib and reports the ones that do not exist, and after a .bib edit reports duplicate keys and entries with no DOI, arXiv id, or URL. Catches an invented citation in the same step it was written. Use when drafting a thesis, paper, or proposal with AI assistance, where a fabricated reference is the one unrecoverable error.
Install
As a plugin
Bundled in the thesis plugin. Add the marketplace once, then install the bundle; it updates with the marketplace.
/plugin marketplace add KhaledSaeed18/dotclaude/plugin install thesis@dotclaudeAs a single item
Run from the project root; the hook lands under .claude/. Copy it to ~/.claude/ to make it global.
npx shadcn@latest add KhaledSaeed18/dotclaude/citation-guardInstalled as a single item, a hook still needs the settings block documented below added to .claude/settings.json. The plugin route wires it automatically.
Files installed
.claude/hooks/citation-guard/HOOK.md.claude/hooks/citation-guard/citation-guard.mjs
What it does
citation-guard
A Claude Code hook that makes the first level of citation-verifier continuous. Every time a chapter file is edited, the cite keys in it are checked against the bibliography; a key with no entry is reported immediately as context, with the instruction to add it from a real identifier via bibtex-manager rather than to invent one.
- Recognises LaTeX (
\cite,\citep,\citet,\parencite,\textcite,\autocite,\footcite,\citeauthor,\citeyear, with optional arguments and stars) and Pandoc Markdown ([@key],[@a; @b, p. 3], in-text@key). Code blocks and emails are ignored. - Finds the .bib from
citationGuard.bibFilein config, else the nearest.bibwalking up from the edited file, else any.bibin the project (four levels deep). No.bibmeans silence. - On a .bib edit, reports duplicate keys and entries with no
doi,eprint,url, orhowpublished, whichcitation-verifierwill not be able to check. - Context, not a block. The edit already happened; Claude sees the problem and fixes it next.
- Fails open, zero dependencies (
node >= 18).
Files
| File | Purpose |
|---|---|
citation-guard.mjs |
The hook script. |
HOOK.md |
This file. |
Activate it (required manual step)
Add this to .claude/settings.json (project) or ~/.claude/settings.json (global):
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write|MultiEdit",
"hooks": [
{
"type": "command",
"command": "node \"$CLAUDE_PROJECT_DIR/.claude/hooks/citation-guard/citation-guard.mjs\""
}
]
}
]
}
}
Installing the thesis plugin from the dotclaude marketplace wires this automatically.
Verify it
printf 'See \\cite{ghost2099}.\n' > chapters/test.tex
echo '{"tool_name":"Edit","tool_input":{"file_path":"'$PWD'/chapters/test.tex"},"cwd":"'$PWD'"}' \
| node .claude/hooks/citation-guard/citation-guard.mjs
You should see a JSON object whose additionalContext names ghost2099 as undefined.
Tune it
{
"citationGuard": {
"enabled": true,
"bibFile": "references.bib"
}
}
Set bibFile when the project has several .bib files and only one is the thesis bibliography.
Hooks run arbitrary commands on your machine with your credentials whenever their event fires. Read any hook script (including this one) before enabling it.
This is the hook as installed, rendered from its source on GitHub. Read it as Markdown.
More in academic
- academic-writingWrite or revise thesis and paper prose section by section (abstract, introduction, related work, method, results, discussion, conclusion) with the...
- benchmark-reportingReport computational benchmarks and experimental comparisons the way examiners and reviewers expect: fair baselines run under the same conditions...
- bibtex-managerMaintain the thesis .bib file as a single source of truth: fetch verified BibTeX from a DOI, arXiv id, or title via CrossRef and arXiv, normalise citation...
- citation-graphExpand a set of key papers into the literature around them by walking the citation graph with the Semantic Scholar and OpenAlex APIs: backward...
- citation-verifierAudit every citation in a chapter, paper, or proposal against the .bib file and the real world: each cite key must exist, each entry must resolve to a...
- design-science-methodologyStructure a thesis whose contribution is a built artifact (tool, system, method, model) using design science research: explicit problem and requirements...