Skill Tracer
Skills › Scientific Agent Skills › citation-management › script_reference.md

script_reference.md

254 lines · skills/citation-management/references/script_reference.md at 5f2bc03

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1# Bundled Script Reference
2
3Purpose, arguments, and usage examples for each script in `scripts/`:
4`search_openalex.py`, `search_pubmed.py`, `search_google_scholar.py`,
5`extract_metadata.py`, `validate_citations.py`, `format_bibtex.py`, and
6`doi_to_bibtex.py`.
7
8`_common.py` is not a command. It holds the brace-aware BibTeX parser, the
9entry renderer, the page-range normaliser, and the citation-key scheme that
10every script above shares — which is what lets entries found through different
11databases deduplicate against each other.

Bundled Script Reference

Purpose, arguments, and usage examples for each script in scripts/: search_openalex.py, search_pubmed.py, search_google_scholar.py, extract_metadata.py, validate_citations.py, format_bibtex.py, and doi_to_bibtex.py.

_common.py is not a command. It holds the brace-aware BibTeX parser, the entry renderer, the page-range normaliser, and the citation-key scheme that every script above shares — which is what lets entries found through different databases deduplicate against each other.

Raw lines 1 to 12
13## Tools and Scripts

Tools and Scripts

Raw lines 13 to 14
15### search_openalex.py
17Search OpenAlex across disciplines. Casual keyless use is supported; an optional account key raises the available budget.
19**Features**:
20- Keyless REST API with cursor pagination
21- Year range and work-type filtering
22- Sort by relevance or citation count
23- Abstracts reconstructed from OpenAlex's inverted index
24- Open-access status on every record
25- Export to JSON or BibTeX
27**Usage**:
28```bash
29# Basic search
30python scripts/search_openalex.py "quantum computing"
32# Most-cited work in a window
33python scripts/search_openalex.py "quantum computing" \
34 --year-start 2020 \
35 --year-end 2024 \
36 --limit 100 \
37 --sort-by citations \
38 --output quantum_papers.json
40# Reviews only, straight to BibTeX
41python scripts/search_openalex.py "CRISPR gene editing" \
42 --type review \
43 --limit 50 \
44 --format bibtex \
45 --output crispr_reviews.bib
46```
48Set `OPENALEX_API_KEY` for your account budget; it is sent in the Authorization header. `OPENALEX_EMAIL`/`--email` supplies optional contact information. The client uses the supported 100-record page limit and exits with an error if any requested page fails, preventing a partial bibliography from being reported as complete.

search_openalex.py

Search OpenAlex across disciplines. Casual keyless use is supported; an optional account key raises the available budget.

Features:

  • Keyless REST API with cursor pagination
  • Year range and work-type filtering
  • Sort by relevance or citation count
  • Abstracts reconstructed from OpenAlex's inverted index
  • Open-access status on every record
  • Export to JSON or BibTeX

Usage:

# Basic search
python scripts/search_openalex.py "quantum computing"

# Most-cited work in a window
python scripts/search_openalex.py "quantum computing" \
  --year-start 2020 \
  --year-end 2024 \
  --limit 100 \
  --sort-by citations \
  --output quantum_papers.json

# Reviews only, straight to BibTeX
python scripts/search_openalex.py "CRISPR gene editing" \
  --type review \
  --limit 50 \
  --format bibtex \
  --output crispr_reviews.bib

Set OPENALEX_API_KEY for your account budget; it is sent in the Authorization header. OPENALEX_EMAIL/--email supplies optional contact information. The client uses the supported 100-record page limit and exits with an error if any requested page fails, preventing a partial bibliography from being reported as complete.

Raw lines 15 to 49
Runs code python scripts/search_openalex.py :30
50### search_google_scholar.py
52Search Google Scholar and export results.
54**Features**:
55- Optional unofficial `scholarly` scraper; Google offers no bulk API
56- Pagination support
57- Year range filtering
58- Export to JSON or BibTeX
59- Citation count information
61**Usage**:
62```bash
63# Basic search
64python scripts/search_google_scholar.py "quantum computing"
66# Advanced search with filters
67python scripts/search_google_scholar.py "quantum computing" \
68 --year-start 2020 \
69 --year-end 2024 \
70 --limit 100 \
71 --sort-by citations \
72 --output quantum_papers.json
74# Export directly to BibTeX
75python scripts/search_google_scholar.py "machine learning" \
76 --limit 50 \
77 --format bibtex \
78 --output ml_papers.bib
79```
81`--sort-by citations` sorts only the retrieved sample; it is not a global
82Google Scholar sort. Year bounds are passed to `scholarly.search_pubs`.
83Blocked/failed searches return no bibliography.

search_google_scholar.py

Search Google Scholar and export results.

Features:

  • Optional unofficial scholarly scraper; Google offers no bulk API
  • Pagination support
  • Year range filtering
  • Export to JSON or BibTeX
  • Citation count information

Usage:

# Basic search
python scripts/search_google_scholar.py "quantum computing"

# Advanced search with filters
python scripts/search_google_scholar.py "quantum computing" \
  --year-start 2020 \
  --year-end 2024 \
  --limit 100 \
  --sort-by citations \
  --output quantum_papers.json

# Export directly to BibTeX
python scripts/search_google_scholar.py "machine learning" \
  --limit 50 \
  --format bibtex \
  --output ml_papers.bib

--sort-by citations sorts only the retrieved sample; it is not a global Google Scholar sort. Year bounds are passed to scholarly.search_pubs. Blocked/failed searches return no bibliography.

Raw lines 50 to 84
Runs code python scripts/search_google_scholar.py :64
85### search_pubmed.py
87Search PubMed using E-utilities API.
89**Features**:
90- Complex query support (MeSH, field tags, Boolean)
91- Date range filtering
92- Publication type filtering
93- Batch retrieval with metadata
94- Export to JSON or BibTeX
96**Usage**:
97```bash
98# Simple keyword search
99python scripts/search_pubmed.py "CRISPR gene editing"
101# Complex query with filters
102python scripts/search_pubmed.py \
103 --query '"CRISPR-Cas Systems"[MeSH] AND "therapeutic"[Title/Abstract]' \
104 --date-start 2020-01-01 \
105 --date-end 2024-12-31 \
106 --publication-types "Clinical Trial,Review" \
107 --limit 200 \
108 --output crispr_therapeutic.json
110# Export to BibTeX
111python scripts/search_pubmed.py "Alzheimer's disease" \
112 --limit 100 \
113 --format bibtex \
114 --output alzheimers.bib
115```

search_pubmed.py

Search PubMed using E-utilities API.

Features:

  • Complex query support (MeSH, field tags, Boolean)
  • Date range filtering
  • Publication type filtering
  • Batch retrieval with metadata
  • Export to JSON or BibTeX

Usage:

# Simple keyword search
python scripts/search_pubmed.py "CRISPR gene editing"

# Complex query with filters
python scripts/search_pubmed.py \
  --query '"CRISPR-Cas Systems"[MeSH] AND "therapeutic"[Title/Abstract]' \
  --date-start 2020-01-01 \
  --date-end 2024-12-31 \
  --publication-types "Clinical Trial,Review" \
  --limit 200 \
  --output crispr_therapeutic.json

# Export to BibTeX
python scripts/search_pubmed.py "Alzheimer's disease" \
  --limit 100 \
  --format bibtex \
  --output alzheimers.bib
Raw lines 85 to 116
Runs code python scripts/search_pubmed.py :99
117### extract_metadata.py
119Extract available metadata from paper identifiers. Search JSON records need a
120DOI, PMID, PMCID, arXiv ID, or article URL; raw OpenAlex IDs are not supported.
122**Features**:
123- Supports DOI, PMID, PMCID, arXiv ID, URL; identifier flags are repeatable
124- Queries CrossRef, PubMed, arXiv APIs
125- Handles multiple identifier types
126- Batch processing from newline identifiers or bundled search JSON (`results`/`entries`)
127- Outputs BibTeX or JSON; partial extraction exits 2 after explicitly reporting failures
129**Usage**:
130```bash
131# Single DOI
132python scripts/extract_metadata.py --doi 10.1038/s41586-021-03819-2
134# Single PMID
135python scripts/extract_metadata.py --pmid 34265844
137# Single arXiv ID
138python scripts/extract_metadata.py --arxiv 2103.14030
140# From URL
141python scripts/extract_metadata.py \
142 --url "https://www.nature.com/articles/s41586-021-03819-2"
144# Batch processing (file with one identifier per line)
145python scripts/extract_metadata.py \
146 --input paper_ids.txt \
147 --output references.bib
149# Different output formats
150python scripts/extract_metadata.py \
151 --doi 10.1038/nature12345 \
152 --format json # or bibtex
153```

extract_metadata.py

Extract available metadata from paper identifiers. Search JSON records need a DOI, PMID, PMCID, arXiv ID, or article URL; raw OpenAlex IDs are not supported.

Features:

  • Supports DOI, PMID, PMCID, arXiv ID, URL; identifier flags are repeatable
  • Queries CrossRef, PubMed, arXiv APIs
  • Handles multiple identifier types
  • Batch processing from newline identifiers or bundled search JSON (results/entries)
  • Outputs BibTeX or JSON; partial extraction exits 2 after explicitly reporting failures

Usage:

# Single DOI
python scripts/extract_metadata.py --doi 10.1038/s41586-021-03819-2

# Single PMID
python scripts/extract_metadata.py --pmid 34265844

# Single arXiv ID
python scripts/extract_metadata.py --arxiv 2103.14030

# From URL
python scripts/extract_metadata.py \
  --url "https://www.nature.com/articles/s41586-021-03819-2"

# Batch processing (file with one identifier per line)
python scripts/extract_metadata.py \
  --input paper_ids.txt \
  --output references.bib

# Different output formats
python scripts/extract_metadata.py \
  --doi 10.1038/nature12345 \
  --format json  # or bibtex
Raw lines 117 to 154
Runs code python scripts/extract_metadata.py :132
155### validate_citations.py
157Validate BibTeX entries for accuracy, completeness, citation count standard compliance, and manuscript integration.
159**Features**:
160- DOI registration checks via Crossref, DataCite, and resolver fallback; inconclusive lookups are warnings
161- Required field checking
162- Duplicate detection
163- Format validation
164- **Heuristic citation-count warnings** for named venues; only an explicit `--min-count` is enforced.
165- **Mandatory post-writing checks** matching manuscript citations (Markdown or LaTeX) with defined BibTeX entries to detect unresolved/missing or unused references.
166- Detailed reporting
168**Usage**:
169```bash
170# Basic validation
171python scripts/validate_citations.py references.bib
173# Validate against a venue standard (e.g., Nature, NeurIPS, Literature Review)
174python scripts/validate_citations.py references.bib --venue nature
175python scripts/validate_citations.py references.bib --venue neurips
176python scripts/validate_citations.py references.bib --venue review
178# Validate with custom minimum citation count
179python scripts/validate_citations.py references.bib --min-count 40
181# Check references against a written manuscript file (detect missing or unused citations)
182python scripts/validate_citations.py references.bib --manuscript paper.md
184# Combined full validation
185python scripts/validate_citations.py references.bib \
186 --venue nature \
187 --manuscript paper.md \
188 --report validation_report.json \
189 --verbose
190```

validate_citations.py

Validate BibTeX entries for accuracy, completeness, citation count standard compliance, and manuscript integration.

Features:

  • DOI registration checks via Crossref, DataCite, and resolver fallback; inconclusive lookups are warnings
  • Required field checking
  • Duplicate detection
  • Format validation
  • Heuristic citation-count warnings for named venues; only an explicit --min-count is enforced.
  • Mandatory post-writing checks matching manuscript citations (Markdown or LaTeX) with defined BibTeX entries to detect unresolved/missing or unused references.
  • Detailed reporting

Usage:

# Basic validation
python scripts/validate_citations.py references.bib

# Validate against a venue standard (e.g., Nature, NeurIPS, Literature Review)
python scripts/validate_citations.py references.bib --venue nature
python scripts/validate_citations.py references.bib --venue neurips
python scripts/validate_citations.py references.bib --venue review

# Validate with custom minimum citation count
python scripts/validate_citations.py references.bib --min-count 40

# Check references against a written manuscript file (detect missing or unused citations)
python scripts/validate_citations.py references.bib --manuscript paper.md

# Combined full validation
python scripts/validate_citations.py references.bib \
  --venue nature \
  --manuscript paper.md \
  --report validation_report.json \
  --verbose
Raw lines 155 to 191
Runs code python scripts/validate_citations.py :171
192### format_bibtex.py
194Format and clean BibTeX files.
196**Features**:
197- Standardize formatting
198- Sort entries (by key, year, author)
199- Remove duplicates
200- Validate syntax
201- Fix common errors
202- Enforce citation key conventions
204**Usage**:
205```bash
206# Basic formatting
207python scripts/format_bibtex.py references.bib
209# Sort by year (newest first)
210python scripts/format_bibtex.py references.bib \
211 --sort year \
212 --descending \
213 --output sorted_refs.bib
215# Remove duplicates
216python scripts/format_bibtex.py references.bib \
217 --deduplicate \
218 --output clean_refs.bib
220# Complete cleanup
221python scripts/format_bibtex.py references.bib \
222 --rekey \
223 --deduplicate \
224 --sort year \
225 --output final_refs.bib
226```

format_bibtex.py

Format and clean BibTeX files.

Features:

  • Standardize formatting
  • Sort entries (by key, year, author)
  • Remove duplicates
  • Validate syntax
  • Fix common errors
  • Enforce citation key conventions

Usage:

# Basic formatting
python scripts/format_bibtex.py references.bib

# Sort by year (newest first)
python scripts/format_bibtex.py references.bib \
  --sort year \
  --descending \
  --output sorted_refs.bib

# Remove duplicates
python scripts/format_bibtex.py references.bib \
  --deduplicate \
  --output clean_refs.bib

# Complete cleanup
python scripts/format_bibtex.py references.bib \
  --rekey \
  --deduplicate \
  --sort year \
  --output final_refs.bib
Raw lines 192 to 227
Runs code python scripts/format_bibtex.py :207
228### doi_to_bibtex.py
230Quick DOI to BibTeX conversion.
232**Features**:
233- Fast single DOI conversion
234- Batch processing from newline identifiers or bundled search JSON (`results`/`entries`)
235- Outputs BibTeX or JSON; partial extraction exits 2 after explicitly reporting failures
236- Clipboard piping using a separate OS utility (for example `pbcopy`)
238**Usage**:
239```bash
240# Single DOI
241python scripts/doi_to_bibtex.py 10.1038/s41586-021-03819-2
243# Multiple DOIs
244python scripts/doi_to_bibtex.py \
245 10.1038/nature12345 \
246 10.1126/science.abc1234 \
247 10.1016/j.cell.2023.01.001
249# From file (one DOI per line)
250python scripts/doi_to_bibtex.py --input dois.txt --output references.bib
252# Copy to clipboard (macOS; use xclip on Linux)
253python scripts/doi_to_bibtex.py 10.1038/nature12345 | pbcopy
254```

doi_to_bibtex.py

Quick DOI to BibTeX conversion.

Features:

  • Fast single DOI conversion
  • Batch processing from newline identifiers or bundled search JSON (results/entries)
  • Outputs BibTeX or JSON; partial extraction exits 2 after explicitly reporting failures
  • Clipboard piping using a separate OS utility (for example pbcopy)

Usage:

# Single DOI
python scripts/doi_to_bibtex.py 10.1038/s41586-021-03819-2

# Multiple DOIs
python scripts/doi_to_bibtex.py \
  10.1038/nature12345 \
  10.1126/science.abc1234 \
  10.1016/j.cell.2023.01.001

# From file (one DOI per line)
python scripts/doi_to_bibtex.py --input dois.txt --output references.bib

# Copy to clipboard (macOS; use xclip on Linux)
python scripts/doi_to_bibtex.py 10.1038/nature12345 | pbcopy
Raw lines 228 to 254
Runs code python scripts/doi_to_bibtex.py :241