bib-filter
Skill150 starsChanged 10 days agoMITView on GitHub
Filter a LaTeX project's bibliography to the entries actually cited, with Overleaf-source resolution, temporary staging, validation, approval-gated canonical replacement, and compilation. Use when a manuscript's bibliography carries uncited entries, typically before submission or after a large revision. Not for checking citation keys or DOIs; use $bib-validate.
In this repository89 other files it gives its agents.
- AGENTS.mdAGENTS.md
- docs/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- beamer-deckSkill
- bib-coverageSkill
- bib-parseSkill
- brief-compliance-checkSkill
- camera-readySkill
- causal-designSkill
- checkpointSkill
- code-archaeologySkill
- compile-knowledgeSkill
- computational-experimentsSkill
- cross-language-checkSkill
- data-analysisSkill
- devils-advocateSkill
- docs-consistencySkill
- docxSkill
- experiment-designSkill
- grill-meSkill
- handoffSkill
- ideasSkill
- init-project-courseSkill
- init-project-lightSkill
- init-project-orchestrationSkill
- init-projectSkill
- insights-deckSkill
- interview-meSkill
- knowledge-lintSkill
- latex-diffSkill
- latex-health-checkSkill
- latex-polishSkill
- latex-postersSkill
- latex-scaffoldSkill
- latexSkill
- latex-templateSkill
- lean-checkSkill
- math-proofSkill
- mcp-builderSkill
- method-auditSkill
- multi-perspectiveSkill
- numerical-checkSkill
- pdfSkill
- pipeline-manifestSkill
- playwright-cliSkill
- postmortemSkill
- pre-commit-auditSkill
- pre-submission-reportSkill
- project-deckSkill
- project-safetySkill
- proof-readabilitySkill
- proofreadSkill
- python-envSkill
- quarto-deckSkill
- reorgSkill
- replication-auditSkill
- replication-packageSkill
- retarget-journalSkill
- review-clusterSkill
- review-responseSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
21 rules. About 0 are common, 9 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Before submission — strip unused references from the bibliography
- Very specific: line 15
When a shared .bib (e.g., Paperpile/Paperpile export) contains hundreds of entries but the paper cites a subset
- Distinctive: line 23
If given a directory, resolve the actual manuscript source first:
- Very specific: line 25
Read \bibliography{...} or \addbibresource{...} from the canonical driver and resolve the referenced .bib relative to that source tree.
- Distinctive: line 26
Do not select a project-root export, backup, or stale wrapper copy merely because it has the same filename.
- Very specific: line 32
If given a specific .tex file, derive the .bib from it.
- Very specific: line 65
Read the .bib file. For each entry (@article{key,, @book{key,, @inproceedings{key,, etc.):
- Distinctive: line 66
If the entry's key is in the cited set → include in output
- Very specific: line 72
Write a temporary candidate beside the canonical bibliography, using a collision-safe name such as .references.filtered.<timestamp>.bib.
- Very specific: line 82
If any cited keys are not found in the .bib, list them as warnings and recommend the configured bibliography validator or manual …
- Distinctive: line 86
Before asking to replace anything:
- Very specific: line 88
verify every cited key is present, including crossref parents.
- Distinctive: line 89
run the configured bibliography validator against the candidate.
- Distinctive: line 94
If any cited key is missing or validation/compilation fails, leave the canonical bibliography unchanged and stop.
- Very specific: line 98
Ask: “Replace <canonical-bib-path> with the validated cited-only candidate?” Only an explicit approval authorizes replacement.
- Distinctive: line 105
remove the temporary candidate after successful verification.
- Very specific: line 108
Do not retain both references.bib and filtered.bib in the Overleaf tree.
- Very specific: line 117
Empty result: If no citations found in .tex, warn and do not write an empty file
- Distinctive: line 118
Concurrent Overleaf change: if the canonical hash changes between staging and replacement, discard the replacement attempt, re-resolve, and …
- Very specific: line 128
Write manifest to <project>/.claude/state/outputs-manifest-<UTC-timestamp>.json listing every file this skill claims to have written in …
- Very specific: line 137
If the verifier exits non-zero, do not commit — surface the missing-files list to the user and stop.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Bibliography Filter
Produce and validate a cited-only bibliography, then replace the manuscript's canonical .bib only after explicit approval. In an Overleaf-linked project, the resolved Overleaf bibliography is canonical; a wrapper-local copy is not a second authority.
When to Use
- Before submission — strip unused references from the bibliography
- When a shared
.bib(e.g., Paperpile/Paperpile export) contains hundreds of entries but the paper cites a subset - To reduce
.bibfile size for Overleaf or arXiv upload - As a cleanup step after major revision (removed sections may leave orphan citations)
Process
Step 1: Locate files
If given a directory, resolve the actual manuscript source first:
- For
paper-<arm>/paper, runrealpath/readlinkand inspect the resolved Overleaf target before declaring a bibliography missing. - Read
\bibliography{...}or\addbibresource{...}from the canonical driver and resolve the referenced.bibrelative to that source tree. - Do not select a project-root export, backup, or stale wrapper copy merely because it has the same filename.
Then find the main .tex and .bib files:
.tex: Glob for*.texin the directory (andpaper/subdirectory if it exists). The main file is the one containing\begin{document}..bib: Look for\bibliography{...}or\addbibresource{...}in the main.texto find the bib filename. Fall back to globbing*.bib.
If given a specific .tex file, derive the .bib from it.
Step 2: Extract all citation keys from .tex
Scan all .tex files in the project (main + any \input{}/\include{} files) for citation commands:
\cite{key1,key2}
\citep{key1,key2}
\citet{key1}
\citealt{key1}
\citealp{key1}
\citeauthor{key1}
\citeyear{key1}
\citetext{key1}
\parencite{key1,key2}
\textcite{key1}
\autocite{key1}
\footcite{key1}
\fullcite{key1}
\nocite{key1}Handle:
- Multiple keys in one command:
\cite{key1,key2,key3}→ extract all three - Whitespace around commas:
\cite{key1, key2}→ trim - Optional arguments:
\cite[p.~5]{key1}or\citep[see][]{key1}→ extractkey1 \nocite{*}→ special case: means "include everything", sofiltered.bib= full.bib(warn and stop)
Collect into a deduplicated set of cited keys.
Step 3: Parse .bib and filter
Read the .bib file. For each entry (@article{key,, @book{key,, @inproceedings{key,, etc.):
- If the entry's key is in the cited set → include in output
- If not → exclude
- Preserve
@string{},@preamble{}, and@comment{}blocks (they may be needed by included entries)
Step 4: Stage a cited-only candidate
Write a temporary candidate beside the canonical bibliography, using a collision-safe name such as .references.filtered.<timestamp>.bib. Do not create a durable second bibliography authority.
Report:
Original: N entries
Cited: M keys found in .tex
Filtered: M entries written to <temporary candidate>
Removed: N-M unused entriesIf any cited keys are not found in the .bib, list them as warnings and recommend the configured bibliography validator or manual reconciliation.
Step 5: Validate before replacement
Before asking to replace anything:
- verify every cited key is present, including
crossrefparents; - run the configured bibliography validator against the candidate;
- compile the manuscript in a temporary build/output directory using the candidate;
- compare bibliography entry count and rendered reference count with the expected cited set;
- report the exact canonical target, its current hash, the candidate hash, kept keys, dropped keys, and validation result.
If any cited key is missing or validation/compilation fails, leave the canonical bibliography unchanged and stop.
Step 6: Approval-gated canonical replacement
Ask: “Replace <canonical-bib-path> with the validated cited-only candidate?” Only an explicit approval authorizes replacement.
After approval:
- recheck the canonical file hash to detect concurrent Overleaf changes;
- atomically replace the canonical
.bibat the resolved Overleaf path; - compile again from the canonical source and confirm no missing citations or bibliography errors;
- remove the temporary candidate after successful verification;
- report the final canonical path and hash.
Do not retain both references.bib and filtered.bib in the Overleaf tree.
Dropped but strategically important comparator records belong in the literature authority, Paperpile, or a registered literature review packet—not in the live manuscript bibliography merely for safekeeping.
Edge Cases
- Multiple
.bibfiles: preserve the driver's declared multi-file structure unless the user separately approves consolidation; stage one filtered candidate per canonical source \nocite{*}: Warn that all entries are cited and stop — filtering would be a no-op- Cross-references: Some
.bibentries usecrossref = {parent-key}. If a cited entry cross-references another, include the parent even if it's not directly cited - Empty result: If no citations found in
.tex, warn and do not write an empty file - Concurrent Overleaf change: if the canonical hash changes between staging and replacement, discard the replacement attempt, re-resolve, and repeat validation
Output Verification (Guard)
This skill writes files. Before any auto-commit, emit an outputs manifest and run the shared verifier. See skills/_shared/verify-outputs.md for the full protocol.
Required tail steps (before git commit):
- Write manifest to
<project>/.claude/state/outputs-manifest-<UTC-timestamp>.jsonlisting every file this skill claims to have written in this invocation (paths relative to the project root). Run:
uv run python "<skills-root>/_shared/verify_outputs.py" \ --manifest "$MANIFEST" \ --project-root "$PROJECT_ROOT"- If the verifier exits non-zero, do not commit — surface the missing-files list to the user and stop. The verifier has already logged an
errorentry to~/.local/state/ai-workflows/skill-outcomes.jsonl, which feeds the shared skill-health dashboard.
Why: closes the "hallucinated outputs" failure class (commit b2cff75, 2026-04-18).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

