You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: skills/bibtidy/SKILL.md
+19-12Lines changed: 19 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,16 +3,18 @@ name: bibtidy
3
3
description: Use when the user wants to validate, check, or fix a BibTeX (.bib) reference file — wrong authors, stale arXiv preprints, incorrect metadata, duplicate entries, formatting issues
4
4
metadata:
5
5
short-description: Validate and fix BibTeX reference files
Use this skill whenever the user wants to validate, check, clean up, or fix a BibTeX `.bib` file.
11
10
12
-
If invoked with an argument, operate on this file: `$ARGUMENTS`.
11
+
If the user request or skill invocation includes an explicit `.bib` path, operate on that file.
13
12
14
-
If the file path is missing or does not exist, ask for the path. In Claude Code slash-command usage, the fallback is:
15
-
"Usage: /bibtidy <path-to-file.bib>"
13
+
If the file path is missing or does not exist, ask for the path.
14
+
15
+
Usage examples:
16
+
- Claude Code slash command: `/bibtidy <path-to-file.bib>`
17
+
- Codex request: `Use the bibtidy skill to validate and fix <path-to-file.bib>`
16
18
17
19
You are a meticulous academic reference checker. Process the .bib file entry by entry, verifying each against external sources and fixing errors in-place.
18
20
@@ -48,7 +50,7 @@ Use `$TOOLS_DIR` in every invocation.
48
50
49
51
## Output Format for Changed Entries
50
52
51
-
Each targeted edit MUST contain the original entry, one or more source URLs, an explanation, and the corrected entry. Include URLs for all sources used (CrossRef, DOI, venue page), each on its own `% bibtidy:` line.
53
+
For `fix` patches, each targeted edit MUST contain the original entry, one or more source URLs, an explanation, and the corrected entry. Include URLs for all sources used (CrossRef, DOI, venue page), each on its own `% bibtidy:` line.
52
54
53
55
```
54
56
% @<type>{<key>,
@@ -70,6 +72,10 @@ Each targeted edit MUST contain the original entry, one or more source URLs, an
70
72
-**Part 3** — `% bibtidy: ` followed by explanation of what changed.
71
73
-**Part 4** — corrected entry.
72
74
75
+
Exceptions:
76
+
-`not_found` entries get the `% bibtidy: NOT FOUND ...` line plus the fully commented-out original entry. Do NOT add a URL line.
77
+
-`duplicate` entries get `% bibtidy: DUPLICATE of <other_key> — consider removing` above the original entry. Do NOT add URL or explanation lines unless the tool behavior changes.
78
+
73
79
For unchanged entries, do NOT add any comments or URLs.
74
80
75
81
## Workflow
@@ -79,16 +85,16 @@ For unchanged entries, do NOT add any comments or URLs.
4. Run duplicate detection: `python3 $TOOLS_DIR/duplicates.py <file.bib>`
81
87
5.**Run field comparison**: `python3 $TOOLS_DIR/compare.py <file.bib>` — this programmatically compares every entry against CrossRef and returns exact field-level mismatches. Do NOT skip this step or rely on visual comparison alone. The output is a JSON list; each element has `key`, `versions` (a list of CrossRef matches, each with `mismatches`, `url`, `doi`, etc.), and `error`. **Skip rule**: if an entry has zero mismatches across all versions and no error in the compare.py output, skip it entirely — do NOT investigate, modify, or add comments to it. Only proceed with entries that compare.py flagged (mismatches, errors, or duplicates from step 4).
82
-
6.**Verify every planned modification with web search** — for entries that compare.py flagged with mismatches or errors, and for entries flagged as duplicates, gather a source URL and double-check the modification via web search. Entries where `compare.py` returned an error (e.g. "No exact title match") still need full verification — the subagent should search for the paper and check all fields. **Important: subagents MUST NOT override `compare.py` field values.** CrossRef is the authoritative source for metadata (pages, volume, number, etc.) because it receives data directly from publishers via DOI registration. When web search finds a conflicting value (e.g. different page numbers on a conference website), always use the CrossRef value and add `% bibtidy: REVIEW` if desired — but do NOT keep the old value.
88
+
6.**Verify every planned modification with web search** — for entries that compare.py flagged with mismatches or errors, and for entries flagged as duplicates, verify the planned action via web search. For `fix` patches, gather one or more source URLs. Entries where `compare.py` returned an error (e.g. "No exact title match") still need full verification — the verification agent should search for the paper and check all fields. **Important: verification agents MUST NOT override `compare.py` field values.** CrossRef is the authoritative source for metadata (pages, volume, number, etc.) because it receives data directly from publishers via DOI registration. When web search finds a conflicting value (e.g. different page numbers on a conference website), always use the CrossRef value and add `% bibtidy: REVIEW` if desired — but do NOT keep the old value.
83
89
7.**Flag hallucinated/non-existent references** — if compare.py returned an error (e.g. "No CrossRef results found" or "No exact title match in CrossRef results") AND web search also finds no matching paper, the reference likely does not exist. Add `% bibtidy: NOT FOUND — no matching paper on CrossRef or web search; verify this reference exists` above the entry, then comment out the entire entry (prefix every line with `% `). Do NOT add a URL line.
84
-
8. Apply fixes **sequentially** with targeted edits — do NOT rewrite the entire file. You MUST apply **every** mismatch reported by `compare.py` — do not skip any field (including `number`, `pages`, `volume`). Use the `crossref_value` exactly as given (do NOT rephrase, reformat, or partially apply it). For title mismatches on preprint→published upgrades, replace the entire title with the CrossRef title — do NOT try to edit parts of the old title. Never reject a CrossRef value because another source disagrees. **URL rule**: for every changed entry, include `% bibtidy: <url>` lines so the user can verify the correction. Include the CrossRef URL from compare.py's `url` field when available, plus any other authoritative source (DOI URL, venue page) found via web search.
90
+
8. Apply fixes **sequentially** using `edit.py` — do NOT edit the .bib file directly with agent editing tools (for example, Claude Code Edit or Codex `apply_patch`), and do NOT rewrite the entire file. Build a patches.json for each entry (or batch) and run `python3 $TOOLS_DIR/edit.py <file.bib> <patches.json>`. This ensures the commented original, source URLs, and explanation are always included. You MUST apply **every** mismatch reported by `compare.py` — do not skip any field (including `number`, `pages`, `volume`). Use the `crossref_value` exactly as given (do NOT rephrase, reformat, or partially apply it). For title mismatches on preprint→published upgrades, replace the entire title with the CrossRef title — do NOT try to edit parts of the old title. Never reject a CrossRef value because another source disagrees. Every patch MUST include `urls` (list of source URLs) and `explanation` (what changed and why). Include the CrossRef URL from compare.py's `url` field when available, plus any other authoritative source (DOI URL, venue page) found via web search.
85
91
9. Run format validation; fix violations and re-run until clean
86
92
10. Delete backup: `rm <file>.bib.orig`
87
93
11. Print a Markdown summary table with headers `Metric | Count` and exactly these rows: total entries, verified, fixed, not found. Do NOT include a separate "needs manual review" row.
88
94
89
95
## Parallel Verification with Subagents
90
96
91
-
Use subagents, when available, to verify multiple entries concurrently. This dramatically reduces wall-clock time (e.g., 7 entries: ~1 min parallel vs ~5 min sequential; 100 entries: ~3 min vs ~40 min).
97
+
Use subagents, when available, to verify multiple entries concurrently. This dramatically reduces wall-clock time (e.g., 7 entries: ~1 min parallel vs ~5 min sequential; 100 entries: ~3 min vs ~40 min). If subagents are unavailable, do the same verification work sequentially yourself.
92
98
93
99
**Step 1 — Dispatch verification agents:** For entries that `compare.py` flagged with mismatches or errors, and any duplicate entries you plan to annotate, launch a subagent that:
94
100
- For mismatches: uses web search to confirm the CrossRef data (especially for preprint upgrades and author changes)
@@ -97,11 +103,11 @@ Use subagents, when available, to verify multiple entries concurrently. This dra
97
103
98
104
**When CrossRef fails**, find the paper's official venue page via web search. Many venues (JMLR, NeurIPS, CVPR, etc.) provide a downloadable `.bib` file — fetch it directly when possible. An official `.bib` is the most reliable source: it has exact title, authors, volume, number, and pages with no guessing.
99
105
100
-
Launch all agents in a single message so they run concurrently. Group into batches of ~10 if there are many entries.
106
+
Launch verification subagents in one batch so they run concurrently. Group into batches of ~10 if there are many entries.
101
107
102
108
**Step 2 — Collect results:** Read each agent's returned summary.
103
109
104
-
**Step 3 — Apply edits sequentially:** Using the lookup results, apply one targeted editat a time. Edits MUST be sequential (parallel edits to the same file cause conflicts).
110
+
**Step 3 — Apply edits sequentially using `edit.py`:** Using the lookup results, build a patches.json and run `python3 $TOOLS_DIR/edit.py <file.bib> <patches.json>` one entry at a time. Do NOT edit the .bib file directly with agent editing tools such as Claude Code Edit or Codex `apply_patch`. Edits MUST be sequential (parallel edits to the same file cause conflicts).
105
111
106
112
**Example agent prompt:**
107
113
```
@@ -160,13 +166,14 @@ For each `@article`, `@inproceedings`, `@book`, etc.:
160
166
| Missing `% bibtidy:` URL | Every changed entry needs a URL — use DOI URL or venue page |
161
167
| Incomplete commented original | Comment out ALL lines of the original, including closing `}`|
162
168
| Adding comments to unchanged entries | Only changed entries get bibtidy comments — if compare.py reports zero mismatches and no error, do not touch the entry |
163
-
| Rewriting entire file | Use one targeted edit per entry|
169
+
| Rewriting entire file | Use `edit.py` with one entry or a small batch at a time; never rewrite the `.bib` file directly|
164
170
| Deleting duplicate entries | Flag with comment only — never delete |
| Single hyphen in page ranges | Always use `--` (double hyphen) for BibTeX page ranges |
167
173
| Partially applying title changes | When CrossRef title differs (e.g. preprint→published), replace the ENTIRE title with the CrossRef value — do not edit substrings |
168
174
| Ignoring `number` field mismatches |`compare.py` reports `number` mismatches — apply them |
169
175
| Adding `doi` when entry didn't have one | Never inject a `doi` field into an entry that lacks one |
176
+
| Using agent editing tools instead of `edit.py`| Always use `edit.py` to apply changes, never edit the .bib file directly with Claude Code Edit, Codex `apply_patch`, or similar tools. Direct edits skip the commented original, URLs, and explanation |
Copy file name to clipboardExpand all lines: tests/bibtidy/fixtures/expected.bib
+20Lines changed: 20 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -153,6 +153,26 @@ @article{khader2022medical
153
153
year={2023}
154
154
}
155
155
156
+
% Author list uses "and others" instead of full list
157
+
% @inproceedings{kirillov2023segment,
158
+
% title={Segment anything},
159
+
% author={Kirillov, Alexander and Mintun, Eric and Ravi, Nikhila and Mao, Hanzi and Rolland, Chloe and Gustafson, Laura and Xiao, Tete and Whitehead, Spencer and Berg, Alexander C and Lo, Wan-Yen and others},
160
+
% booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision},
% bibtidy: expanded author list from "and others" to full list
167
+
@inproceedings{kirillov2023segment,
168
+
title={Segment anything},
169
+
author={Kirillov, Alexander and Mintun, Eric and Ravi, Nikhila and Mao, Hanzi and Rolland, Chloe and Gustafson, Laura and Xiao, Tete and Whitehead, Spencer and Berg, Alexander C and Lo, Wan-Yen and Doll{\'a}r, Piotr and Girshick, Ross},
170
+
booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision},
171
+
pages={3992--4003},
172
+
year={2023},
173
+
doi={10.1109/ICCV51070.2023.00371}
174
+
}
175
+
156
176
% Published article should not be downgraded to preprint
157
177
@article{tzou2022coronavirus,
158
178
title={Coronavirus Resistance Database (CoV-RDB): SARS-CoV-2 susceptibility to monoclonal antibodies, convalescent plasma, and plasma from vaccinated persons},
Copy file name to clipboardExpand all lines: tests/bibtidy/fixtures/input.bib
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -96,6 +96,16 @@ @article{khader2022medical
96
96
year={2022}
97
97
}
98
98
99
+
% Author list uses "and others" instead of full list
100
+
@inproceedings{kirillov2023segment,
101
+
title={Segment anything},
102
+
author={Kirillov, Alexander and Mintun, Eric and Ravi, Nikhila and Mao, Hanzi and Rolland, Chloe and Gustafson, Laura and Xiao, Tete and Whitehead, Spencer and Berg, Alexander C and Lo, Wan-Yen and others},
103
+
booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision},
104
+
pages={3992--4003},
105
+
year={2023},
106
+
doi={10.1109/ICCV51070.2023.00371}
107
+
}
108
+
99
109
% Published article should not be downgraded to preprint
100
110
@article{tzou2022coronavirus,
101
111
title={Coronavirus Resistance Database (CoV-RDB): SARS-CoV-2 susceptibility to monoclonal antibodies, convalescent plasma, and plasma from vaccinated persons},
0 commit comments