pubmed-cli is a command-line interface for NCBI PubMed E-utilities.
It focuses on deterministic, scriptable literature workflows on the main branch:
searchfetchcited-byreferencesrelatedmeshrefcheck
brew tap henrybloomingdale/tools
brew install pubmed-cligo install github.com/henrybloomingdale/pubmed-cli/cmd/pubmed@latestgit clone https://github.com/drpedapati/pubmed-cli.git
cd pubmed-cli
go build -o pubmed ./cmd/pubmedSet your NCBI API key (recommended):
export NCBI_API_KEY="your-key"NCBI rate limits:
- Without key: 3 requests/second
- With key: 10 requests/second
# Basic search
pubmed search "fragile x syndrome" --limit 5 --human
# Fetch one PMID
pubmed fetch 38000001 --human --full
# Fetch multiple PMIDs (space or comma-separated)
pubmed fetch 38000001 38000002 --json
pubmed fetch "38000001,38000002" --json
# Export RIS for EndNote/Zotero import
pubmed fetch 38000001 38000002 --ris refs.ris
# Citation graph
pubmed cited-by 38000001 --limit 5 --json
pubmed references 38000001 --limit 5 --json
pubmed related 38000001 --limit 5 --human
pubmed related 38000001 --limit 10 --ris related.ris
# MeSH lookup
pubmed mesh "depression" --json
# Verify document references against PubMed
pubmed refcheck manuscript.docx --human
pubmed refcheck manuscript.docx --json
pubmed refcheck manuscript.docx --audit-text --csv-out report.csv --ris-out verified.ris| Flag | Description |
|---|---|
--json |
Structured JSON output |
--human, -H |
Rich terminal rendering |
--csv FILE |
Export current result to CSV |
--ris FILE |
Export citations in RIS format (fetch/link commands) |
--full |
Show full abstract text (human article output) |
--limit N |
Maximum results (must be > 0) |
--sort |
relevance, date, or cited |
--year |
YYYY or YYYY-YYYY |
--type |
Publication-type filter (review, trial, meta-analysis, randomized, case-report, or custom) |
--api-key |
NCBI API key override |
The CLI now fails fast for common mistakes:
- Invalid
--limitvalues (<= 0) are rejected. - Invalid
--sortvalues are rejected. - Invalid year formats and descending ranges are rejected.
- Invalid PMIDs (non-digits) are rejected in
fetch,cited-by,references, andrelated. --risis supported onfetch,cited-by,references, andrelated(rejected forsearchandmesh).refcheckvalidates that the input file exists and thatdocx-reviewis installed.
- Shared NCBI client with rate limiting and response-size guards.
- Automatic retry with backoff for transient NCBI
HTTP 429responses. - UTF-8 safe text truncation in human output.
- Tiered PubMed query strategy for reference verification (PMID β DOI β title β author+year β relaxed).
- Hallucination detection for potentially fabricated references.
# Build
go build ./...
# Test
go test ./...
# Vet
go vet ./...Additional development docs:
docs/development/TDD.mddocs/development/CODE_REVIEW.mddocs/development/UX_TESTING.mddocs/homebrew.mdRELEASING.md
Repository metadata:
CONTRIBUTING.mdSECURITY.md.github/workflows/ci.yml.github/workflows/release-assets.yml
main: non-AI command set listed above, includingrefcheckfor document reference verification.ai-features: historical branch for AI/LLM workflows.
MIT