Manage-Refs Skill
You are routing reference-handling work for a medical manuscript. The user is
somewhere in the lifecycle — drafting, building a circulation DOCX, swapping
CSL after a journal rejection, fixing a cross-reference defect surfaced by
QC, or wiring up live Zotero field codes for a co-author Word workflow. Pick
the right tool from the decision table; do not invent a parallel pipeline.
Why This Skill Exists
Reference handling spans every late-stage skill: /write-paper builds the
first DOCX, /revise rebuilds it after each reviewer round, /peer-review
emits a critique that quotes references back, /sync-submission packages the
final tarball, /find-journal informs CSL swaps on rejection cascade, and
/verify-refs audits the bibliography. Until 2026-05-01 these scripts lived
under skills/write-paper/scripts/, which made /revise and /sync-submission
silently depend on a sibling skill — a layering inversion that broke when
/write-paper was loaded into a non-research project. Moving the
lifecycle tools here turns reference handling into a first-class concern
with one decision tree, one set of CSL files, and one provenance file
(NOTICE.md) for the vendored Zotero CWYW writer.
Validated 2026-05-01 against a 21-reference meta-analysis manuscript
(a meta-analysis project's submission) for both pandoc-citeproc and Zotero-CWYW paths.
Anti-Hallucination Guarantees
Citekey discipline (Phase 0): every in-text citation must be
[@bibkey] resolvable in refs.bib. scripts/check_citation_keys.py is
a hard gate — UNDEFINED keys exit non-zero and block the build.
[@NEW:topic] placeholder convention: while drafting, /write-paper
may emit [@NEW:topic_slug] markers for citations the author still needs
to source. check_citation_keys.py classifies these as NEW_PLACEHOLDER
(not UNDEFINED) and exits 0 — the build is allowed to proceed during
drafting. Phase 7.6 (DOCX render) is a hard gate: zero NEW_PLACEHOLDER
entries must remain. Resolve each by adding the citation to Zotero (then
/lit-sync refreshes refs.bib) and replacing the placeholder with the
real [@bibkey]. Never let a [@NEW:...] reach a rendered DOCX.
No hand-typed References list — references are always rendered by
pandoc citeproc + journal CSL or by the Zotero Word plugin (CWYW). See
~/.claude/rules/manuscript-references.md.
Zotero metadata is never invented — inject_zotero_cwyw.py fetches
item data live from http://localhost:23119. Any HTTP failure aborts
with a non-zero exit so partial bibliographies never reach the user.
Marker conversion is mapping-driven — md_marker_convert.py will
never guess a Zotero key for a number; unmapped markers stay as [N]
and are reported on stderr.
Cross-reference QC is a submission gate — scripts/check_xref.py
--strict exits 1 on any MISSING_DOCX / MISSING_BODY / MISMATCH,
blocking pipelines that try to ship a DOCX whose Table/Figure citations
don't match captions.
Audit boundary: this skill writes; bibliographic correctness against
PubMed/CrossRef stays in /verify-refs. Always invoke /verify-refs
after a render before signing off — one read-only audit, one writer.
Decision Tree
| Situation |
Tool |
Why |
Validate [@bibkey] ↔ refs.bib (UNDEFINED / UNUSED keys) |
scripts/check_citation_keys.py |
Hard build gate, runs in seconds |
| Single-author submission lockdown, frozen output |
scripts/render_pandoc.sh -j <journal> |
Reproducible, CI-friendly |
| Cascade rejection (e.g., ER → JVIR → CVIR) |
render_pandoc.sh with new -j |
CSL swap reformats references in seconds |
| Reviewer revision: add 1–2 refs to a Word doc with co-authors live |
Zotero Word plugin (user GUI) |
Minimal disruption to track-changes flow |
| Reviewer revision: bulk reference change |
Edit markdown SSOT, re-run render_pandoc.sh |
Consistency, no cherry-pick risk |
Migrate [N] numeric markers → [@key] for pandoc |
scripts/md_marker_convert.py --to-keys |
Mapping-driven, partial conversion safe |
Convert [@key] → [N] for round-trip / debug |
scripts/md_marker_convert.py --to-numbers |
Same map, opposite direction |
| Wire native Zotero CWYW field codes into a .docx (live Refresh in Word) |
scripts/inject_zotero_cwyw.py |
Co-author Word workflow, post-circulation editability |
| Manuscript ↔ rendered DOCX cross-reference QC |
scripts/check_xref.py --strict |
Submission gate (P0 blocker on mismatch) |
| Bibliographic audit against PubMed / CrossRef |
delegate to /verify-refs |
Audit-only — keep writer/auditor separation |
Workflows
A. Pandoc citeproc (default for solo authors and final submissions)
User provides manuscript.md with [@bibkey] citations + refs.bib.
- Gate:
python "${CLAUDE_SKILL_DIR}/scripts/check_citation_keys.py" manuscript.md refs.bib
— exits non-zero on UNDEFINED keys. Fix and re-run.
- Render:
"${CLAUDE_SKILL_DIR}/scripts/render_pandoc.sh" \
-j european-radiology \
-i manuscript.md \
-b refs.bib \
-o manuscript_final.docx
Bundled CSLs (in citation_styles/): european-radiology, radiology,
american-journal-of-roentgenology, cardiovascular-and-interventional-radiology,
korean-journal-of-radiology, vancouver, vancouver-superscript,
springer-basic-brackets, springer-vancouver-brackets. Use
radiology for RYAI; use vancouver for JVIR (no dedicated CSL).
- QC:
python3 "${CLAUDE_SKILL_DIR}/scripts/check_xref.py" \
--md manuscript.md --docx manuscript_final.docx \
--out qc/xref_audit.json --strict
Treat submission_safe: false as a halt. Route fixes by symptom — see
the table in references/check_xref_symptoms.md.
- Audit hand-off: invoke
/verify-refs for the PubMed/CrossRef audit
before sign-off.
B. Zotero CWYW (co-author Word workflow)
User has a markdown SSOT and wants reviewers to edit citations directly in
Word. Each reference must already exist as a Zotero item; the user supplies
a [N] → ZoteroKey mapping.
- Convert markers:
python3 "${CLAUDE_SKILL_DIR}/scripts/md_marker_convert.py" \
--input manuscript.md --output manuscript_keys.md \
--map ref_map.json --to-keys
Optionally stage with --active-ns 1,2,3,4,19 for a sample build first
(validated on an active meta-analysis project: 5-ref sample reduces Word Refresh blast radius
when debugging).
- Render to .docx with pandoc (workflow A) so the body has plain text
[@key] markers, OR pre-build a .docx some other way that still contains
plain [@key] text.
- Inject CWYW:
python3 "${CLAUDE_SKILL_DIR}/scripts/inject_zotero_cwyw.py" \
--input manuscript_keys.docx --output manuscript_cwyw.docx \
--user-id 16613550 --keys-from keys.txt
The script fetches Zotero metadata via the local connector (port 23119);
any HTTP failure aborts with non-zero exit.
- First-build instruction (REQUIRED — see Known Limitation #1): open
the output in Word → Zotero tab → Add/Edit Bibliography once. After
that, Refresh keeps citations and bibliography in sync as authors
edit.
- Surgical patches are unsafe: for ref additions in later rounds, edit
the markdown SSOT and rebuild the whole .docx instead of regex-patching
the post-CWYW file. Zotero's rendered
[N] superscripts can collide
with plain [N] markers and corrupt the field codes.
C. Cascade rejection re-render (find-journal hand-off)
User got rejected from journal A and /find-journal recommended journal B.
- Confirm the new CSL exists in
citation_styles/ (or fetch from
https://citationstyles.org/styles and drop in).
- Re-run
render_pandoc.sh -j <new-csl> against the same manuscript.md +
refs.bib.
- Re-run
check_xref.py --strict.
- Re-run
/verify-refs if any new references were added during the
inter-journal revision.
D. Cross-reference QC only
User shipped a manuscript and a reviewer flagged a Table/Figure mismatch.
- Run
check_xref.py --strict on the current manuscript.md + .docx.
- Inspect
qc/xref_audit.json. Body caption is the SSOT — fix manuscript.md
and rebuild, never patch the .docx by hand.
- See
references/check_xref_symptoms.md for the
MISSING_BODY / MISSING_DOCX / MISMATCH triage table.
Quality Gates
This skill defines three submission gates and one user approval gate:
- Gate 1 (citekey integrity):
check_citation_keys.py exits non-zero on
UNDEFINED keys. The pipeline halts; the user reviews and fixes.
- Gate 2 (cross-reference integrity):
check_xref.py --strict exits 1 on
any MISSING_DOCX / MISSING_BODY / MISMATCH row. The user reviews
qc/xref_audit.json and resolves before proceeding.
- Gate 3 (audit hand-off): before sign-off, the user must run
/verify-refs and confirm submission_safe: true in
qc/reference_audit.json. This skill never marks the bibliography
audited on its own.
- User approval gate (CWYW first build): the user must perform Word →
Zotero → Add/Edit Bibliography manually after the first
inject_zotero_cwyw.py build. The skill cannot automate this and warns
on stderr that it is required.
Provenance
scripts/_vendor_citation_writer.py is vendored from
alisoroushmd/zotero-mcp @ ed5dfb71, MIT licensed. See
NOTICE.md and LICENSE.zotero-mcp.
Related
~/.claude/rules/manuscript-references.md — global rule (decision tree
this skill implements)
~/.claude/rules/agent-skill-routing.md — skill router (this skill is the
reference-handling row)
~/.claude/rules/zotero-workflow.md — BBT auto-export, MCP setup
/verify-refs — read-only audit (PubMed / CrossRef + first-author
cross-check)
/lit-sync — Zotero ↔ Obsidian sync, refs.bib provider
/write-paper Phase 7.6 — calls this skill (one-line delegation)
/revise, /sync-submission, /find-journal — call this skill on
rebuild / re-render / cascade
Known Limitations
- First-build empty BIBL field (CWYW):
inject_zotero_cwyw.py writes a
stub ADDIN ZOTERO_BIBL field; Word's Zotero Refresh treats an empty
stub as user-customized and refuses to populate it. User must run
Add/Edit Bibliography once. Subsequent Refresh works as expected.
Validated on Word for Mac, an active meta-analysis project.
- Webpage / non-journal item types: handled by the patched
zotero_to_csl_json that fetches Zotero's native CSL-JSON; do not bypass
this patch.
- Surgical post-build regex patches are unsafe — see Workflow B step 5.
- Local Zotero required for CWYW — port 23119 must be reachable; no
web-API fallback yet (would need
ZOTERO_API_KEY). On failure the script
aborts with non-zero exit so partial builds never ship.
1---2name: manage-refs3description: >4 Cross-cutting reference manager for medical manuscripts. Single entry point5 for citation-key validation, journal-CSL pandoc rendering, manuscript ↔ DOCX6 cross-reference QC, marker conversion (``[N]`` ↔ ``[@key]``), and native7 Zotero CWYW field-code injection. Replaces the inline reference-handling8 that previously lived in ``/write-paper`` Phase 7.6 and is reused by9 ``/revise``, ``/peer-review``, ``/sync-submission``, and any skill that10 produces a journal submission. Audit-only verification stays in11 ``/verify-refs`` — this skill writes (renders, injects, converts); that12 skill only reads.13triggers: manage-refs, references, citation, citation keys, pandoc citeproc, journal CSL, CSL swap, cascade rejection re-render, cross-reference QC, [@bibkey], Zotero CWYW, ADDIN ZOTERO_ITEM, marker conversion, [N] to [@key], reference manager, render manuscript, check_citation_keys, check_xref14tools: Read, Write, Edit, Bash, Grep, Glob15model: inherit16metadata:17 source: https://skillmd.com/skills/aibot88/manage-refs18---1920# Manage-Refs Skill2122You are routing reference-handling work for a medical manuscript. The user is23somewhere in the lifecycle — drafting, building a circulation DOCX, swapping24CSL after a journal rejection, fixing a cross-reference defect surfaced by25QC, or wiring up live Zotero field codes for a co-author Word workflow. Pick26the right tool from the decision table; do not invent a parallel pipeline.2728## Why This Skill Exists2930Reference handling spans every late-stage skill: `/write-paper` builds the31first DOCX, `/revise` rebuilds it after each reviewer round, `/peer-review`32emits a critique that quotes references back, `/sync-submission` packages the33final tarball, `/find-journal` informs CSL swaps on rejection cascade, and34`/verify-refs` audits the bibliography. Until 2026-05-01 these scripts lived35under `skills/write-paper/scripts/`, which made `/revise` and `/sync-submission`36silently depend on a sibling skill — a layering inversion that broke when37`/write-paper` was loaded into a non-research project. Moving the38lifecycle tools here turns reference handling into a first-class concern39with one decision tree, one set of CSL files, and one provenance file40(`NOTICE.md`) for the vendored Zotero CWYW writer.4142Validated 2026-05-01 against a 21-reference meta-analysis manuscript43(a meta-analysis project's submission) for both pandoc-citeproc and Zotero-CWYW paths.4445## Anti-Hallucination Guarantees46471. **Citekey discipline (Phase 0)**: every in-text citation must be48 `[@bibkey]` resolvable in `refs.bib`. `scripts/check_citation_keys.py` is49 a hard gate — UNDEFINED keys exit non-zero and block the build.5051 **`[@NEW:topic]` placeholder convention**: while drafting, `/write-paper`52 may emit `[@NEW:topic_slug]` markers for citations the author still needs53 to source. `check_citation_keys.py` classifies these as `NEW_PLACEHOLDER`54 (not UNDEFINED) and exits 0 — the build is allowed to proceed during55 drafting. Phase 7.6 (DOCX render) is a hard gate: zero NEW_PLACEHOLDER56 entries must remain. Resolve each by adding the citation to Zotero (then57 `/lit-sync` refreshes refs.bib) and replacing the placeholder with the58 real `[@bibkey]`. Never let a `[@NEW:...]` reach a rendered DOCX.592. **No hand-typed References list** — references are always rendered by60 pandoc citeproc + journal CSL or by the Zotero Word plugin (CWYW). See61 `~/.claude/rules/manuscript-references.md`.623. **Zotero metadata is never invented** — `inject_zotero_cwyw.py` fetches63 item data live from `http://localhost:23119`. Any HTTP failure aborts64 with a non-zero exit so partial bibliographies never reach the user.654. **Marker conversion is mapping-driven** — `md_marker_convert.py` will66 never guess a Zotero key for a number; unmapped markers stay as `[N]`67 and are reported on stderr.685. **Cross-reference QC is a submission gate** — `scripts/check_xref.py`69 `--strict` exits 1 on any `MISSING_DOCX` / `MISSING_BODY` / `MISMATCH`,70 blocking pipelines that try to ship a DOCX whose Table/Figure citations71 don't match captions.726. **Audit boundary**: this skill writes; bibliographic correctness against73 PubMed/CrossRef stays in `/verify-refs`. Always invoke `/verify-refs`74 after a render before signing off — one read-only audit, one writer.7576## Decision Tree7778| Situation | Tool | Why |79|---|---|---|80| Validate `[@bibkey]` ↔ `refs.bib` (UNDEFINED / UNUSED keys) | `scripts/check_citation_keys.py` | Hard build gate, runs in seconds |81| Single-author submission lockdown, frozen output | `scripts/render_pandoc.sh -j <journal>` | Reproducible, CI-friendly |82| Cascade rejection (e.g., ER → JVIR → CVIR) | `render_pandoc.sh` with new `-j` | CSL swap reformats references in seconds |83| Reviewer revision: add 1–2 refs to a Word doc with co-authors live | Zotero Word plugin (user GUI) | Minimal disruption to track-changes flow |84| Reviewer revision: bulk reference change | Edit markdown SSOT, re-run `render_pandoc.sh` | Consistency, no cherry-pick risk |85| Migrate `[N]` numeric markers → `[@key]` for pandoc | `scripts/md_marker_convert.py --to-keys` | Mapping-driven, partial conversion safe |86| Convert `[@key]` → `[N]` for round-trip / debug | `scripts/md_marker_convert.py --to-numbers` | Same map, opposite direction |87| Wire native Zotero CWYW field codes into a .docx (live Refresh in Word) | `scripts/inject_zotero_cwyw.py` | Co-author Word workflow, post-circulation editability |88| Manuscript ↔ rendered DOCX cross-reference QC | `scripts/check_xref.py --strict` | Submission gate (P0 blocker on mismatch) |89| Bibliographic audit against PubMed / CrossRef | **delegate** to `/verify-refs` | Audit-only — keep writer/auditor separation |9091## Workflows9293### A. Pandoc citeproc (default for solo authors and final submissions)9495User provides `manuscript.md` with `[@bibkey]` citations + `refs.bib`.961. **Gate**: `python "${CLAUDE_SKILL_DIR}/scripts/check_citation_keys.py" manuscript.md refs.bib`97 — exits non-zero on UNDEFINED keys. Fix and re-run.982. **Render**:99 ```bash100 "${CLAUDE_SKILL_DIR}/scripts/render_pandoc.sh" \101 -j european-radiology \102 -i manuscript.md \103 -b refs.bib \104 -o manuscript_final.docx105 ```106 Bundled CSLs (in `citation_styles/`): `european-radiology`, `radiology`,107 `american-journal-of-roentgenology`, `cardiovascular-and-interventional-radiology`,108 `korean-journal-of-radiology`, `vancouver`, `vancouver-superscript`,109 `springer-basic-brackets`, `springer-vancouver-brackets`. Use110 `radiology` for RYAI; use `vancouver` for JVIR (no dedicated CSL).1113. **QC**:112 ```bash113 python3 "${CLAUDE_SKILL_DIR}/scripts/check_xref.py" \114 --md manuscript.md --docx manuscript_final.docx \115 --out qc/xref_audit.json --strict116 ```117 Treat `submission_safe: false` as a halt. Route fixes by symptom — see118 the table in `references/check_xref_symptoms.md`.1194. **Audit hand-off**: invoke `/verify-refs` for the PubMed/CrossRef audit120 before sign-off.121122### B. Zotero CWYW (co-author Word workflow)123124User has a markdown SSOT and wants reviewers to edit citations directly in125Word. Each reference must already exist as a Zotero item; the user supplies126a `[N] → ZoteroKey` mapping.1271. **Convert markers**:128 ```bash129 python3 "${CLAUDE_SKILL_DIR}/scripts/md_marker_convert.py" \130 --input manuscript.md --output manuscript_keys.md \131 --map ref_map.json --to-keys132 ```133 Optionally stage with `--active-ns 1,2,3,4,19` for a sample build first134 (validated on an active meta-analysis project: 5-ref sample reduces Word Refresh blast radius135 when debugging).1362. **Render to .docx** with pandoc (workflow A) so the body has plain text137 `[@key]` markers, OR pre-build a .docx some other way that still contains138 plain `[@key]` text.1393. **Inject CWYW**:140 ```bash141 python3 "${CLAUDE_SKILL_DIR}/scripts/inject_zotero_cwyw.py" \142 --input manuscript_keys.docx --output manuscript_cwyw.docx \143 --user-id 16613550 --keys-from keys.txt144 ```145 The script fetches Zotero metadata via the local connector (port 23119);146 any HTTP failure aborts with non-zero exit.1474. **First-build instruction** (REQUIRED — see Known Limitation #1): open148 the output in Word → Zotero tab → **Add/Edit Bibliography** once. After149 that, **Refresh** keeps citations and bibliography in sync as authors150 edit.1515. **Surgical patches are unsafe**: for ref additions in later rounds, edit152 the markdown SSOT and rebuild the whole .docx instead of regex-patching153 the post-CWYW file. Zotero's rendered `[N]` superscripts can collide154 with plain `[N]` markers and corrupt the field codes.155156### C. Cascade rejection re-render (find-journal hand-off)157158User got rejected from journal A and `/find-journal` recommended journal B.1591. Confirm the new CSL exists in `citation_styles/` (or fetch from160 https://citationstyles.org/styles and drop in).1612. Re-run `render_pandoc.sh -j <new-csl>` against the same `manuscript.md` +162 `refs.bib`.1633. Re-run `check_xref.py --strict`.1644. Re-run `/verify-refs` if any new references were added during the165 inter-journal revision.166167### D. Cross-reference QC only168169User shipped a manuscript and a reviewer flagged a Table/Figure mismatch.1701. Run `check_xref.py --strict` on the current `manuscript.md` + `.docx`.1712. Inspect `qc/xref_audit.json`. Body caption is the SSOT — fix `manuscript.md`172 and rebuild, never patch the .docx by hand.1733. See `references/check_xref_symptoms.md` for the174 `MISSING_BODY` / `MISSING_DOCX` / `MISMATCH` triage table.175176## Quality Gates177178This skill defines **three submission gates** and **one user approval gate**:179180- **Gate 1 (citekey integrity)**: `check_citation_keys.py` exits non-zero on181 UNDEFINED keys. The pipeline halts; the user reviews and fixes.182- **Gate 2 (cross-reference integrity)**: `check_xref.py --strict` exits 1 on183 any `MISSING_DOCX` / `MISSING_BODY` / `MISMATCH` row. The user reviews184 `qc/xref_audit.json` and resolves before proceeding.185- **Gate 3 (audit hand-off)**: before sign-off, the user must run186 `/verify-refs` and confirm `submission_safe: true` in187 `qc/reference_audit.json`. This skill never marks the bibliography188 audited on its own.189- **User approval gate (CWYW first build)**: the user must perform Word →190 Zotero → Add/Edit Bibliography manually after the first191 `inject_zotero_cwyw.py` build. The skill cannot automate this and warns192 on stderr that it is required.193194## Provenance195196`scripts/_vendor_citation_writer.py` is vendored from197`alisoroushmd/zotero-mcp` @ `ed5dfb71`, MIT licensed. See198[`NOTICE.md`](./NOTICE.md) and [`LICENSE.zotero-mcp`](./LICENSE.zotero-mcp).199200## Related201202- `~/.claude/rules/manuscript-references.md` — global rule (decision tree203 this skill implements)204- `~/.claude/rules/agent-skill-routing.md` — skill router (this skill is the205 reference-handling row)206- `~/.claude/rules/zotero-workflow.md` — BBT auto-export, MCP setup207- `/verify-refs` — read-only audit (PubMed / CrossRef + first-author208 cross-check)209- `/lit-sync` — Zotero ↔ Obsidian sync, `refs.bib` provider210- `/write-paper` Phase 7.6 — calls this skill (one-line delegation)211- `/revise`, `/sync-submission`, `/find-journal` — call this skill on212 rebuild / re-render / cascade213214## Known Limitations2152161. **First-build empty BIBL field (CWYW)**: `inject_zotero_cwyw.py` writes a217 stub `ADDIN ZOTERO_BIBL` field; Word's Zotero Refresh treats an empty218 stub as user-customized and refuses to populate it. User must run219 Add/Edit Bibliography once. Subsequent Refresh works as expected.220 Validated on Word for Mac, an active meta-analysis project.2212. **Webpage / non-journal item types**: handled by the patched222 `zotero_to_csl_json` that fetches Zotero's native CSL-JSON; do not bypass223 this patch.2243. **Surgical post-build regex patches are unsafe** — see Workflow B step 5.2254. **Local Zotero required for CWYW** — port 23119 must be reachable; no226 web-API fallback yet (would need `ZOTERO_API_KEY`). On failure the script227 aborts with non-zero exit so partial builds never ship.