Install
$ agentstack add skill-mathpluscode-bibtools-bibtidy ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
About
Use this skill for any request to validate, check, clean up, or fix a BibTeX .bib file.
If the request includes a .bib path, operate on it. If the path is missing or does not exist, ask for it.
Assumptions:
- Process entries one by one.
- Only brace-style BibTeX like
@article{...}is supported; reject parenthesized@article(...). - Preserve
@string,@preamble, and@commentblocks verbatim.
Resolve Tools
All bundled scripts live in tools/ next to this file. Resolve TOOLS_DIR once:
for d in \
"${CODEX_HOME:-$HOME/.codex}/skills/bibtidy/tools" \
"$HOME/.claude/skills/bibtidy/tools" \
"${CLAUDE_PLUGIN_ROOT:-/dev/null}/skills/bibtidy/tools"; do
[ -f "$d/crossref.py" ] && TOOLS_DIR="$d" && break
done
Useful commands:
python3 $TOOLS_DIR/compare.py [--key KEY]python3 $TOOLS_DIR/crossref.py doipython3 $TOOLS_DIR/crossref.py search ""python3 $TOOLS_DIR/crossref.py bibliographic ""python3 $TOOLS_DIR/duplicates.pypython3 $TOOLS_DIR/edit.py
Patch Rules
Use edit.py for all actual .bib changes. Do not edit the file directly with agent editing tools and do not rewrite the whole file.
fixpatch: includekey,action,urls,explanation, andfields;entry_typeis optional.- In
fields, set a field tonullto remove it; omit a field to leave it unchanged. not_found: comment out the original entry; do not add URL lines.duplicate: add% bibtidy: DUPLICATE of — consider removingabove the original entry; no URL lines.review: add one or more% bibtidy:lines plus% bibtidy: REVIEW,above the unchanged entry.- Clean entries get no comments.
For fix patches, edit.py should produce:
- fully commented original entry
- one
% bibtidy:line per source - one
% bibtidy:line - corrected entry
Use source values verbatim. If the bib entry uses and others and a verified source provides the full author list, replace it with the full list.
Workflow
Each entry has a web-search budget of 1 total, used in at most one of Wave A or Wave B.
- Read the file and note the path.
- Clear the platform log:
> .bib.cc.login Claude Code or> .bib.codex.login Codex. - Back up the file:
cp .bib .bib.orig - Run
python3 $TOOLS_DIR/duplicates.pybefore metadata fixes. - Run
python3 $TOOLS_DIR/compare.pyfor CrossRef candidates. - Wave A web search: every entry with
errorset or nocandidatesmust be web-verified. Those entries have spent their budget. - After each wave, classify every entry as one of:
Clean: confirmed, no changesFix: confident correctionEscalate: still ambiguous and budget unusedNot found: no paper found after required searchReview: budget spent and still uncertain
- Wave B web search: only entries marked
Escalateand not yet searched. After Wave B, final outcomes are onlyClean,Fix,Not found, orReview. - Write a real
patches.jsonfile and apply fixes withpython3 $TOOLS_DIR/edit.py patches.json. - Run
python3 $TOOLS_DIR/duplicates.pyagain. Resolve everyunresolved same-key collisionswarning and rerun until the warning is gone. - Manually review likely related entries after fixes. Strong clues: repeated citation keys, repeated DOIs, same normalized title with overlapping authors, obvious preprint→published pairs. If two entries should be linked but not auto-removed, apply a
duplicatepatch. - Validate format, delete the backup, and print a summary table with rows: total entries, verified, fixed, not found, needs review, exact duplicates removed, near-duplicates flagged.
For files with more than 30 entries, work in batches of about 15 and report progress. Entry count must match before and after.
Compare Carefully
compare.py returns raw CrossRef candidates plus discrepancies. Treat them as hints, not truth.
- A missing candidate field is not evidence that the bib field should be removed.
- If a verified candidate supplies a missing standard venue field such as volume, issue, or pages, add it.
- Never add a
doifield when the bib entry currently lacks one. - Treat
authorvsauthorsandjournalvsbooktitleas schema mismatches until verified. - If a preprint has a verified published version, update title, venue, year, volume, number, and pages together.
- When the published title differs, replace the title verbatim; do not partially edit it.
- Use
--for BibTeX page ranges. - Missing
pagesis not automatically an error for venues that do not publish page numbers.
Web Verification
Use subagents when available; otherwise do the same work sequentially. Cap at 6 subagents per wave and distribute entries evenly.
Each web-search subagent should return only JSON with:
keysource_urlsfieldsnotes
Rules for subagents:
fieldsis either a fix-patch dict ornull.- Use
nullinsidefieldsto remove a stale field. - Verify against authoritative pages when possible: DOI page, publisher page, venue page, arXiv, OpenReview, etc.
- Check title, full author list, year, journal/booktitle, volume, number/issue, pages, and DOI.
- Put a value in
fieldswhen the verified source disagrees with the bib entry or when the bib entry is missing a standard field that the venue publishes. - Do not add a missing
doifield just because you found one; mention it innotesif useful. - If a standard field is genuinely unavailable, say so in
notes.
Preserve
- Entry order
- All unchanged fields
- Empty lines between entries
- User
%comments that are not% bibtidy: @string,@preamble, and@commentblocks- LaTeX macros and brace-protected capitalization in titles
If rate-limited, note it and continue with the next entry.
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: mathpluscode
- Source: mathpluscode/bibtools
- License: MIT
- Homepage: https://bib.tools/
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.