/legal-research:build-libraryfrom Legal Research Skills
Builds or extends a Zotero collection with verified sources found via web, catalogs, and HeinOnline. Adds items with full metadata via the Zotero Web API and runs a deterministic anti-hallucination check on every item.
Ships in Legal Research Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Populate a Zotero collection with sources for a project. Two-layer defense against fabricated sources: (1) verify every candidate against a real source before adding; (2) after adding, run the bundled deterministic checker — no item ships unverified. All global authority rules (never invent a cite; flag uncertainty) apply throughout.
Before scoping, before searching, before proposing a single candidate, dump the target library and read all of it:
python3 ${CLAUDE_PLUGIN_ROOT}/skills/build-library/library_inventory.py --group <ID> # or --user
python3 ${CLAUDE_PLUGIN_ROOT}/skills/build-library/library_inventory.py --group <ID> --grep <terms>
One line per top-level item: year, PDF-or-not, authors, title, publication, item key. The PDF
column is true only when a child attachment with content type application/pdf exists (a
child note or an HTML snapshot does not count); child_count is Zotero's raw child total.
A 100-item library is well under 3k tokens. There is no budget reason to skip this and no
substitute for it. For a large library (thousands of items), save the full dump to a file and
read the relevant --grep slices plus the overall shape — but the coordinator still owns the
check, and a slice that was never grepped is not evidence of absence.
This is step zero rather than part of the dedup screen because knowing the library changes what you go looking for. A run that skips it will propose things the user already owns, describe them as "newly identified," and make false claims about gaps in the collection.
Four hard rules, each from a real failure (2026-08-01, on a 105-item group library):
The library is also evidence. When the task is "what's missing," what the user already owns tells you what they care about and often reframes the answer. In the run that prompted this rule, the user's library turned out to hold a deep shelf of criminal-law scholarship on exactly the topics the memo had just described as unaddressed — which changed the finding from "nobody has written about this" to "these two literatures don't cite each other." Read the inventory for what it says about the project, not just for duplicate-matching.
The zotero / zotero-group MCP tools are read-only (good for duplicate checks and
search). All writes go through the Zotero Web API v3 with the key from the zotero entry
in ~/.claude.json (env.ZOTERO_API_KEY; verified to have write access to the personal
library, <USER_ID>, and any group libraries you use).
GET /users/<USER_ID>/collections?limit=100 → find the target key; create
with POST /collections if the user wants a new one (confirm name first).POST /items as a backstop — it catches items added earlier in the same run and
exact-edition collisions the earlier screens miss. For one-off lookups mid-run,
library_inventory.py --grep <terms> beats mcp__zotero__zotero_search_items, because
it searches the list you already hold rather than issuing a fresh narrow query.POST /users/<USER_ID>/items with a JSON array (≤50/request). Check the
response's success/failed maps. Get a blank template from
GET https://api.zotero.org/items/new?itemType=book when unsure of fields.contributor creators plus an
extra note (Zotero books have no illustrator role); editors → editor; put the
edition's real publisher/imprint (e.g. Sentinel, not “Penguin”); full pub date when
verified, year otherwise; ISBN always for books, DOI always for articles.Claude creates items via the Web API, so it can get these right where the user's Zotero Connector reliably gets them wrong. Apply to every law-review article added; Hein (§4a) shows the correct data, so take the fields from there.
The Common Law, never the Connector's sort-inverted Common Law, The.Are Judges Political?, not Are Judges Political.<i>…</i>, e.g. The Real Meaning of <i>Erie</i> or
Rethinking <i>Chevron</i> Deference. Zotero renders and exports these as italics (this is
the <i>case name</i> the user otherwise adds by hand).extra. The Connector tacks designations onto the title — Essay,
Comment, Note, Foreword, Book Review, Symposium: <name>, etc. Keep only the
article's actual title as it heads the piece / appears in the Bluebook cite. If unsure
whether trailing text is a real subtitle vs. an appended label, check the first page.
Recent Development, Essay, Foreword, Book Review, etc.): don't just
discard the label. Record it in the item's extra field as a genre: line — genre: Note
for a student note, genre: Comment for a comment (title-case; the style title-cases it
regardless, but store it clean). The Bluebook style then inserts it in the right place
(Jane Doe, Note, <i>Title</i>, 120 Harv. L. Rev. 1627 (2007)). Strip it from the title
as above and add the genre: line — the two go together for these pieces.genre: Note. If the extra field already carries other lines (e.g. Verified-URL:),
add genre: Note on its own newline — don't overwrite them.! on the suffix controls whether a comma is rendered before it (citeproc-js
markup, per the author):
firstName: "John,Jr.", lastName: "Smith"firstName: "John,!Jr.", lastName: "Smith"
The given name incl. any middle name/initial goes before the comma (e.g. John B.,Jr.).
Same mechanism for numerals/other suffixes — John,III vs John,!III, John,Sr. etc.
Match whichever comma form the author/source uses.journalAbbreviation
field ("Journal Abbr" in the UI) with the journal's Bluebook abbreviation (Table T13) in
normal mixed case — Colum. L. Rev., Harv. L. Rev., Nw. U. L. Rev., J. Sup. Ct. Hist., Sup. Ct. Rev. — NOT all caps. The citation style applies the small caps itself, so
store Colum. L. Rev., never COLUM. L. REV. Full name stays in publicationTitle; the
abbreviation goes in journalAbbreviation. Hein's citation display renders it in caps/small
caps ("62 COLUM. L. REV. 633") — use it for the wording but convert to mixed case; for an
unfamiliar journal, verify the T13 form rather than guessing. For an online companion/
supplement, append the supplement name abbreviated per Bluebook — Forum → F. (e.g.
Harv. L. Rev. F.), while Colloquy has no short form (Nw. U. L. Rev. Colloquy).
Known name-specific exceptions (don't "correct" these): California Law Review → Calif. L. Rev. (not Cal., even though California is Cal. in reporters and elsewhere). The Calif.
oddity is specific to that journal — contrast Southern California Law Review → S. Cal. L. Rev., where California takes the usual Cal.Scope with the user if the request is open-ended (which justices/scholars/era; books only or articles too; trade books vs. casebooks/treatises — flag judgment calls in the report rather than silently deciding). Do this after §0, never before — the inventory tells you what the user already has, which changes what is worth looking for.
Search in parallel: WebSearch; Open Library (search.json?title=&author= beats bare
q=); Wikipedia infoboxes (/w/index.php?title=<page>&action=raw, grep the infobox)
for publisher/date/ISBN of notable books; publisher pages. For legal scholarship, HeinOnline
(§4). Google Books API is a shared anonymous quota that is often
exhausted — treat it as bonus, not backbone.
With the inventory in hand, dedup the candidate list before the expensive
verify → download → add pipeline (§3+). Verifying metadata and pulling PDFs (Hein curl
chains, attach_pdf.py) is the costly part of a run; doing it for a source already
in the library is pure waste.
Only the survivors go through §3. The pre-add backstop in §1 then catches within-run duplicates and exact-edition collisions.
If you do create a duplicate, merge before deleting. The pre-existing item may hold
the user's PDF, annotations, tags, and collection memberships; your new one may hold
better metadata. PATCH the good fields onto the existing item, then DELETE yours. Never
delete the older record. (In the 2026-08-01 cleanup this recovered a real defect: the
user's Kahan item had the string "10.2307" sitting in its issue field and no DOI.)
Workflow rule (author, 2026-07-16): resolve every law-review source through HeinOnline. Hein is the clean autonomous path (§4a: IP-authenticated, no bot wall, no gate). A source that Hein does not carry and that no open repository serves is reported as such (§5) rather than added without a verified record.
Before adding: every field you write must come from a fetched source — an Open
Library edition record (/isbn/<isbn>.json), a publisher page, a Wikipedia infobox, a
bookseller listing. Never write a plausible ISBN/date/publisher from memory. Beware
corrupt OL edition records (a wrong book behind an ISBN happens); cross-check any
surprise against a second source.
After adding, run the bundled checker on exactly what landed in Zotero:
python3 ${CLAUDE_PLUGIN_ROOT}/skills/build-library/check_source.py --collection <KEY> # whole collection
python3 ${CLAUDE_PLUGIN_ROOT}/skills/build-library/check_source.py --keys K1,K2,K3 # just new items
It resolves each item's ISBN through five independent catalogs (Open Library edition +
search index, Google Books, Harvard Library, Library of Congress) or its DOI through
Crossref, and does normalized whole-token comparison of title/authors/year (a claimed
surname must match a whole name token, so Smith is not Smithson; the PASS detail names which
fields the catalog actually supplied). Verdicts: PASS, FAIL (resolved but mismatched),
UNRESOLVED (every catalog completed a search and none has the identifier — a prompt to
re-verify, not proof of fabrication: catalogs are incomplete), UNAVAILABLE (at least one
catalog could not be searched — HTTP error, timeout, bad JSON — and nothing resolved; the
detail lists what failed and what was searched; lack of access is not evidence of
nonexistence, so retry later or verify by hand), BAD_ISBN (checksum), NO_IDENTIFIER.
--stdin accepts a JSON array of Zotero-shaped items to pre-check candidates before
adding. The Zotero fetch itself is reconciled: a --collection run follows pagination and
checks the declared total, and a --keys run requires every requested key back exactly
once; any shortfall exits 2 with nothing verified rather than passing vacuously.
--library user:<ID>|group:<ID> and --server <mcp-server-name> pick the library when
the environment does not say (the default reads the zotero entry setup wrote in
~/.claude.json).
Every item you added must end PASS. Playbook for non-PASS:
FAIL on one source only → usually catalog corruption; the checker already tries the
other sources, so a persistent FAIL usually means your data is wrong — re-verify against
an opened authoritative page and PATCH the item (send If-Unmodified-Since-Version: <item version>). If the opened page confirms your data, record it as Verified-URL:
and say so in the report rather than "fixing" correct metadata to match a catalog.UNRESOLVED/too-new-for-catalogs (books <~1 yr old) → add a fetchable authoritative
page as Verified-URL: <https://…> in the item's extra (or the item url); the
checker then requires ISBN + title + every author surname on that page. IndieCommerce
bookstore pages (politics-prose.com/book/) fetch cleanly; simonandschuster.com
and strandbooks.com 403 bots.NO_IDENTIFIER → find the ISBN/DOI and PATCH it in; if none exists (older law review
articles), verify by eye against Hein and say so explicitly in the report.To put the actual PDF on a Zotero item — not merely the citation — use the bundled
attach_pdf.py, which runs the Zotero Web API file-upload protocol (create attachment
child → request upload authorization with md5/size → upload bytes → register):
python3 ${CLAUDE_PLUGIN_ROOT}/skills/build-library/attach_pdf.py --item <KEY> --url <https://…pdf> # Tier 1
python3 ${CLAUDE_PLUGIN_ROOT}/skills/build-library/attach_pdf.py --item <KEY> --file <~/Downloads/x.pdf> # Tier 3
It refuses non-PDF bytes (a bot-wall/login page starts with HTML, not %PDF-), so a
failed fetch fails loudly instead of attaching garbage. It resolves the library (type, id,
key) only when it runs — from --library user:<ID>|group:<ID>, else the ZOTERO_*
environment variables, else the Zotero MCP server entry in ~/.claude.json (--server
or the default zotero) — uses /groups/<id> for a group library, and after registering
reads the attachment back to confirm its parent, library, content type and md5 before
printing PASS; anything else is FAIL with exit 1. Three tiers, because getting the
bytes is the hard part (verified 2026-07-16):
--url fetches with a browser UA and uploads. Fully
autonomous. This is the default; try it for every added scholarly source.attach_pdf.py --file.saveItems POST to http://127.0.0.1:23119/connector/saveItems
makes the running Zotero desktop fetch the PDF itself. Works on campus IP; does NOT
work for WAF-walled repos, and it creates a NEW
item in Zotero's selected collection (reconcile/dedupe afterward).cgi/viewcontent
endpoints): the Claude-in-Chrome extension, driving the user's real browser, suppresses ALL
browser downloads — blob, same-origin anchor, and even a genuine click on Edge's own
PDF-viewer save button produce nothing on disk. (Cowork can download because it runs its
own Chrome inside a VM with a host-mounted ~/Downloads.) So for these: a human clicks the
Zotero connector once, or a Cowork task downloads to ~/Downloads; then attach_pdf.py --file.On a campus network or your institution's VPN, no proxy is needed — heinonline.org authenticates by IP; use the direct URL. So: navigate to the direct site first and check whether it shows subscriber access (Hein: "Provided By: "). Only fall back to the proxy flow below if it doesn't. For Hein on an institutional IP, prefer the pure-curl flow in §4a (no browser needed at all).
Off campus, Hein works through the library proxy when the user has an active proxy session. The proxy login is institutional SSO with two-factor, so the session cannot be established by automation (and never enter credentials regardless). If a proxied page shows the SSO/2FA login screen, pause and ask the user to complete the login in the browser themselves, then resume — that's the expected flow, not an error. Use claude-in-chrome, in the browser the user designates (ask via the list_connected_browsers flow):
https://<proxy-host>/login?url=<target> — rewrites to
<host-with-dashes>.<proxy-host> (e.g. access-heinonline-com.…).extra, verify fields by eye, and flag as hand-verified.When the machine's public IP is your institution's (check curl -s ipinfo.io/json against your institution's ASN), Hein needs no browser. All requests: browser UA + one
persistent cookie jar (-b/-c the same file). Hein chains JavaScript redirects that
curl -L won't follow — extract each window.location="…" target and fetch it yourself:
GET https://heinonline.org/HOL/Welcome → lands on access.heinonline.com; page should
say "Provided By: " (if not, you're not IP-authenticated —
fall back to §4).GET /HOL/OneBoxCitation?cit_string=110+Harv.+L.+Rev.+815 → returns a
"Secure Request and Redirect" page with a tokenized /HOL/mojo?…auth_token=… URL →
fetch it (sets session cookies) → re-fetch the OneBoxCitation URL → JS redirect to a
Page?…handle=hein.journals/<vol>…&page=<firstpage> URL (relative to /HOL/).PrintRequest?collection=journals&handle=hein.journals/hlr110&div=37&id=833&print=section&format=PDFsearchable&submit=Print%2FDownload
(the div is the article section; the most-repeated id= on the page is the current
section's).PDFsearchable?handle=… URL →
fetch that → the PDF bytes (application/pdf; verify %PDF- magic / file says PDF).
Note the PDF opens with a Hein citation cover page.attach_pdf.py --item <KEY> --file <downloaded.pdf> (don't use --url here — the
script doesn't carry the cookie jar).End with: items added (grouped sensibly), the checker's summary line (verbatim verdict counts), any hand-verified or flagged items, judgment calls made (inclusions/exclusions), and anything the user should prune or decide. If the deliverable is a memo file, the global provenance-header rule applies.
Sources not added (per the §2 workflow rule): list any source that neither Hein nor an open repository could supply with a verified record, with its best URL, so the user can decide whether to add it by hand. Say plainly that it was left out and why.
What SKILL.md sets; muted values are Claude Code's defaults
7 skills in this plugin
/case-prepGather the full document set for a SCOTUS case being prepped for a podcast episode, class, or article — cert-stage filings, merits briefs, lower-court opinion, questions presented, and oral-argument transcript — and load them onto the user's reMarkable in a per-case folder. Manual trigger — use when the user says "prep <case>", "grab the briefs for <case>", "load up <case>", or similar./cite-checkVerify every citation and quotation in an article draft against the real sources — cases via CourtListener + official reporters, scholarship via the user's Zotero library then the open web — and return a graded, footnote-by-footnote report with a "needs your attention" section first, an advisory subsequent-history and treatment section (Bluebook R. 10.7 history the draft omits; cases a later decision overruled or limited), a "since the last report" diff on re-runs, plus a citation-form section (short cites per Bluebook R. 10.9/4.2 and italics/small caps per R. 2.1(a)) decided from the draft alone, and an OPT-IN proposition-support pass that reads each unquoted cite at its pincite and says whether it supports the sentence it hangs on (overstatement is reported as a confirm item, never an error). Trigger when the user wants a draft cite-checked ("cite-check this", "check the citations/quotes in this draft", "run cite-check on <file>"). Input: a .docx with real Word footnotes (markdown/plain-text fallback). Not a full Bluebook linter — signal order, citation order and cite composition stay out.npx claudepluginhub danepps/legal-research-skills --plugin legal-researchOther plugins' skills for the same job