A macOS agent that reads a PDF or a .webloc bookmark and writes a
BibLaTeX-Chicago entry (notes and bibliography), optionally filing it straight into
BibDesk.
NOTE: Early-stage software, developed against one ~5,500-item library. The prompt rules,
entry-type quotas, and normalization conventions follow one scholar's
biblatex-chicago practice. On held-out sources never used in development, the entry type
was correct for 38 of 48 (79%), measured against hand-verified ground truth with
claude-sonnet-4-6, the default type search (Claude web search) and the maintainer's library
for matching and examples. Without a library, expect less. The full configuration and
field-level tables are in
dev/eval/baselines/2026-11-06-holdout.md;
dev/eval/README.md says what the evaluation suite cannot measure. Assume entries need
checking before you cite from them. macOS only; BibDesk is optional.
Design notes, measurements and cost analysis live in NOTES.md.
- Rationale
- How it works
- Installation
- Configuration
- Usage
- Cost
- BibDesk integration
- Normalizing an existing library
- Evaluating extraction accuracy
- Troubleshooting
- Repository layout
- License
- Why “Ostracon”?
Chicago is the bibliography style typically used in the humanities, cherished for its attention to source and transmission history, to various types of authorship, and to detail in general. Its “notes and bibliography” variant relies on footnotes or endnotes rather than inline “author-date” references, and is the more common one in music theory and musicology. This Claude agent adds Zotero-like auto-fill capabilities to such BibLaTeX-Chicago writing workflows, generating .bib entries for new sources supplied as PDF files or .webloc bookmarks. Thanks to its reliance on AI models, multiple metadata sources, and elaborate prompting, the agent aims at outperforming Zotero, not merely matching it.
The immense number of types and fields in the BibLaTeX-Chicago package makes Zotero unsustainable as a bibliography manager, with the otherwise excellent Better BibTeX extension only alleviating a painful experience. For many writers, BibDesk is the only macOS manager that elegantly navigates the style’s ontological complexity. They will be relieved to know that the agent optionally imports the new references into BibDesk.
The agent assumes the Chicago Manual of Style throughout. Adapting it to another style, such as APA, is left as a trivial exercise for the reader.
For each source, the agent works in five stages (chart):
- Extract text: from the PDF, with OCR for scanned pages, or from the bookmarked page.
- Identify type [
gemini_type_check,type_search]; when off, or when nothing is found, Claude chooses the type in 3a.- a. Identifies the item: Claude reads the first pages for its title, author and, for a part, the item containing it.
- b. Searches the web: Claude Haiku 5.5, at most two searches per item (
claude, the default); Google's AI Mode in a Chrome tab, which writes a whole BibLaTeX-Chicago entry (ai-mode); or Gemini with Google Search (gemini). - c. Estimates the type: from the search results, or read from AI Mode's entry.
- Create record
- a. Estimates the entry fields: with Claude, from the extracted text and the source's metadata, given the type from 2c, per the extraction rules and your house style. Optionally, Claude is also shown up to three library entries as models of form: the container's other items first, then the same type's most fully populated entries, one per author; only fields that biblatex or biblatex-chicago defines are shown [
library_exemplars]. - b. Retrieves missing publication details: volume, number, pages, the journal or (for a chapter, from a DOI match) the book title and, for books, the publisher, from the work's CrossRef record, with Google Scholar as a fallback. Only empty fields are filled [
enrich_missing_fields]. - c. Verifies recollected field values: fields that Claude wrote from memory rather than the PDF or web page are looked up in CrossRef, with Google Scholar as a fallback. Fields that neither engine confirms are reported as inferred [
enrich_missing_fields].
- a. Estimates the entry fields: with Claude, from the extracted text and the source's metadata, given the type from 2c, per the extraction rules and your house style. Optionally, Claude is also shown up to three library entries as models of form: the container's other items first, then the same type's most fully populated entries, one per author; only fields that biblatex or biblatex-chicago defines are shown [
- Refine record
- a. Reconciles the new item with related library items: duplicate items are reported; an item (e.g., chapter) and its container (e.g., book) inherit each other's fields from the library for consistency, whichever was entered first; supplements (e.g., an introduction) and their books likewise [
library_match]. - b. Retrieves the remaining fields: any other field the type takes (editor, series, edition, translator, and so on), answered by Claude or Gemini from the 2b search results without searching again (for a review, only the curated questions: the results describe the reviewed work) (
gemini_question_searchlets Gemini search again), or taken from AI Mode's entry, cleaned, if 3a kept its type [gemini_type_check]. - c. Applies them by precedence: these values fill gaps and replace values that came only from Google Scholar; values from the source, CrossRef and the library stand.
- a. Reconciles the new item with related library items: duplicate items are reported; an item (e.g., chapter) and its container (e.g., book) inherit each other's fields from the library for consistency, whichever was entered first; supplements (e.g., an introduction) and their books likewise [
- Cleanup
- a. Enforces house style compliance: i.e., with the library's normalization rules and spellings, and without the fields you never record [
house_cleanup,drop_fields]. - b. Validates the new entry: using biber against biblatex-chicago's data model, with one repair by Claude [
validate_entries,repair_entries]; a test compile shows that every field prints [render_check]. - c. Saves the output: in the staging file, or in BibDesk [
autofile_bibdesk].
- a. Enforces house style compliance: i.e., with the library's normalization rules and spellings, and without the fields you never record [
Precedence. Where two sources offer different values for the same field, a
value read from the PDF or web page prevails, as does one from a CrossRef record
confirmed to describe the same work. Below these come, in order, the library's
value, the type search's (4b), and last a value from Google Scholar or one that Claude recalled
without confirmation. The comments written above each entry name the origin of
every value not read from the source (% Sources) and list the recalled values
that nothing confirmed (% INFERRED).
Review colour. An entry is coloured amber in BibDesk only when something has
failed: biber still rejects it after the repair attempt, one of its fields does
not appear in the printed citation, the source is too thin to trust or is not the
work at all (a login page, for instance), or, with require_langid, it has no
Langid. Doubts that could not be settled are logged, not coloured.
Blocked pages. When a bookmarked page cannot be fetched directly, because a
bot challenge or a login wall stands in the way, it is read from a Safari or
Chrome tab already showing it, which carries your session. Failing that, with
open_blocked_in_browser, it is read from a Chrome tab opened and closed for the
purpose; and failing that, if the URL contains a DOI, the entry is built from the
CrossRef record.
brew install ocrmypdf # optional; for scanned PDFs
conda create -n biblio-ai python=3.11 # or venv
conda activate biblio-ai
pip install -r requirements.txt # anthropic, pypdf, pyyaml,
# requests, beautifulsoup4,
# pyobjc-framework-Cocoa
cp config.yaml.example config.yaml # then set anthropic_api_key_command
cp automator/script.sh.example automator/script.sh # then set PYTHON and WORKDIR
./install # bib-audit link; the Finder quick action
python3 dev/test_setup.py # verifyconfig.yaml and automator/script.sh are not under version control. Re-run
./install after changing script.sh: it rebuilds the quick action when it is
stale.
dev/test_setup.py checks dependencies, configuration, the context files, OCR,
and that the documentation names every configuration key, command-line flag and
tracked file. The quick action runs dev/test_setup.py --preflight before each
batch. The self-tests (dev/test_*.py, dev/eval/test_eval.py) are listed in
NOTES.md.
Three keys need a value; the rest have defaults.
anthropic_api_key_command: "~/.local/bin/secret biblio-ai"
main_bib_file: "~/Desktop/biblio-staging.bib" # where entries are appended
failed_bib_file: "~/Desktop/biblio-failed.bib" # where invalid entries goanthropic_api_key_command is a command whose first line of output is the key,
such as security find-generic-password -s NAME -w or pass show NAME; give its
full path if it lies outside /usr/bin. A plaintext anthropic_api_key, then
ANTHROPIC_API_KEY, take precedence. Relative paths resolve against the
repository.
The web search of stages 2 and 4b is optional: set gemini_type_check: true. By
default Claude runs it (type_search: "claude") on the Anthropic key, at most
two searches per item. To use Gemini instead, set type_search: "gemini" and give
a key from a billed Google AI Studio project (aistudio.google.com/apikey), the
same way as the Anthropic key: gemini_api_key_command, or a plaintext
gemini_api_key, which takes precedence. No environment variable is read. Claude
calls are billed to the Anthropic API account, Gemini calls to the Google project;
a Claude subscription covers neither (see Cost).
gemini_type_check: true
type_search: "gemini"
gemini_api_key_command: "security find-generic-password -s ostracon-gemini-api-key -w"| Key | Default | Effect |
|---|---|---|
autofile_bibdesk |
false |
Import each entry into BibDesk rather than the staging file. |
batch_workers |
3 |
Sources processed at once. |
cache_ttl |
"1h" |
Prompt-cache lifetime. See Cost. |
careful_model |
claude-opus-5 |
Model for sources in pdf-in/careful/. See Usage. |
crossref_email |
— | CrossRef's faster polite pool. Free. |
drop_fields |
— | Fields removed from every new entry in 5a, e.g. [pagetotal, month]: those you never record. |
enrich_missing_fields |
true |
Completion from CrossRef and Google Scholar, and the check of unconfirmed fields. |
gemini_api_key |
— | For gemini_type_check; a billed Google AI project. Or gemini_api_key_command. |
gemini_question_search |
false |
With type_search: "gemini": let Gemini search Google again to answer its questions in 4b; each search past 5,000 a month is billed. |
gemini_type_check |
false |
A web search decides the type and fills missing fields (2 and 4b). |
house_cleanup |
true |
The library's normalization rules and spellings. |
interactive_ocr |
true |
Ask for the OCR language; false uses default_ocr_language (eng). |
library_bib_file |
— | Your library, for library_match, house_cleanup and library_exemplars. |
library_exemplars |
false |
Show Claude up to three library entries as models of form. |
library_match |
true |
Report duplicates; an item and its container inherit each other's fields from the library. |
max_tokens |
4000 |
Ceiling per response. |
model |
claude-sonnet-4-6 |
Claude model. |
ocr_engine |
auto |
Who OCRs a scanned PDF: auto (Google Document AI through ocrdoc when ocrdoc_path and ocrdoc_python are set and its setup check passes, else Tesseract), google (an error when ocrdoc is unusable), or tesseract. A failed or thin Google reading is logged and handed to Tesseract. See Cost. |
ocrdoc_path |
— | The ocrdoc checkout. Unset: Tesseract only. |
ocrdoc_python |
— | The Python interpreter of ocrdoc's environment, whatever manages it (micromamba, poetry, uv, venv). ocrdoc runs under it directly. |
ocr_threshold |
100 |
Words below which a page is OCR'd. |
ocr_timeout |
180 |
Seconds allowed to ocrmypdf, or to ocrdoc. |
open_blocked_in_browser |
false |
Open a blocked page in Chrome. Needs Chrome's "Allow JavaScript from Apple Events". |
render_check |
false |
Test-compile each entry. About 3 s a source. |
repair_entries |
true |
One Claude call repairs an entry biber rejects. |
require_langid |
false |
Colour an entry without Langid. |
scrapingdog_api_key |
— | Enables Google Scholar. Or scrapingdog_api_key_command. |
thin_yield_threshold |
400 |
Words a PDF must yield; fewer colours the entry. 0 disables. |
type_search |
"claude" |
Who runs 2b and 4b: claude (Claude Haiku 5.5, at most two web searches per item, $0.01 each) gemini (Google Search; Gemini decides how many searches), or ai-mode (Google Search's AI Mode in Chrome: no API cost; Chrome open and signed in, with View > Developer > Allow JavaScript from Apple Events). |
validate_entries |
true |
biber's data-model check. |
verbose |
true |
Progress on stderr. |
Presentation settings live under interface:; none affects extraction.
interface:
show_window: false # The floating progress window; --window/--no-window override.
window_models: [...] # Models offered in the window's dropdown. Unset hides it.
window_start_delay: 5 # Seconds the window waits before the first file; Start skips it.
notifications: false # macOS notifications for batch progress and failures.At the top level they are still read, with a warning, until the next release.
pdf_in_folder, pdf_out_folder, template_file, rules_file, ref_file and
example_files name the cached prefix and may be left as they are;
NOTES.md says what each contributes. Put your own conventions (your
preamble, your languages, fields to require or omit) in a private house-style
file, not in rules_file: ~/.config/ostracon-ai/house-style.md (or
house_style_file) is read when present and overrides the rules.
Right-click a PDF or .webloc file in Finder, or a mixed selection, and choose
Extract BibLaTeX-Chicago Bibliography (via Claude).
The progress window's Model dropdown lists window_models; its Search
dropdown chooses the type search for 2b and 4b: Off, Claude web search, Google AI
Mode (Chrome), or Gemini when a Gemini key is configured. It starts from
gemini_type_check and type_search. The window waits window_start_delay
seconds (default 5), counting down, before the first file, so both can be set
first; Start (or Return) begins at once. Later changes apply from the next
file. A choice lasts for that batch only; config.yaml is not changed. Reference works (Grove, the Stanford Encyclopedia, Wikipedia)
repay the stronger model: put them in pdf-in/careful/ before an --all run and
they process with careful_model. See the operator note in CLAUDE.md.
python3 src/biblio_agent.py paper.pdf bookmark.webloc # one or more sources
python3 src/biblio_agent.py --all # everything in pdf-in/
python3 src/biblio_agent.py paper.pdf --no-save # print, write nothing
python3 src/biblio_agent.py paper.pdf --output out.bib
python3 src/biblio_agent.py entry.webloc --model claude-opus-5| Flag | Effect |
|---|---|
--all |
Process pdf_in_folder rather than named files. |
--config FILE |
Use an alternate configuration file. |
--model ID |
Override model for this run. |
--no-move |
Leave processed files in place. The quick action uses this. |
--no-save |
Print to stdout; no staging file, no BibDesk import. |
--output FILE |
Write to FILE instead of main_bib_file. |
-q, --quiet |
Suppress status messages. |
--window / --no-window |
Force the progress window on or off. |
Measured on 168 sources on 2026-11-04 (claude-sonnet-4-6, gemini_type_check
on); the pipeline has changed since. python3 dev/estimate_cost.py prices the
current prompt per model.
| Service | First source in a run | Each later source |
|---|---|---|
| Claude | $0.162 | $0.057 |
| CrossRef | free | free |
Claude web search (gemini_type_check, type_search: claude) |
at most $0.02 in searches, plus Haiku 5.5 tokens (not yet measured) | the same |
Google AI Mode (type_search: ai-mode) |
none; about a minute per item in Chrome | the same |
Gemini (type_search: gemini) |
about $0.03 in tokens, plus searches past the free 5,000 a month (about 40 per source in the 2026-11-06 billing export) | the same |
| Google Scholar (ScrapingDog) | about $0.001 a lookup | the same |
Google Document AI, through ocrdoc (ocr_engine) |
scanned PDFs only: about $1.50 per 1,000 pages, so about $0.0075 for the 5 key pages | the same |
| Google Search, through Gemini | 5,000 a month free, then $14 per 1,000 | the same |
The first source pays to write the cached prompt; later ones read it back. At the
default cache_ttl: "1h" the cache survives between runs within the hour.
Entries accumulate in main_bib_file for you to import. Each carries a
bdsk-file-1 link to its source, which survives the import.
With autofile_bibdesk: true, entries are imported through AppleScript as they are
written, and BibDesk files the source itself. BibDesk builds the attachment's
filename from Title and the authors and flattens any LaTeX in them:
\bibstring{reviewof} becomes reviewof, \foreignlanguage{russian}{X} becomes
russianX, and ~, \,, --- survive verbatim. No BibDesk setting prevents
this; a Did Auto File script hook can rename the file afterwards.
NOTES.md records what was measured.
Separate tools bring an existing .bib into the same shape. None runs during
extraction.
python3 dev/bib_audit.py library.bib # count, change nothing
python3 dev/bib_normalize.py library.bib # dry run, grouped by rule
python3 dev/bib_normalize.py library.bib --apply --label a # snapshot, then write
python3 dev/bib_apply.py library.bib edits.json # named edits
python3 dev/bib_bisect.py library.bib # find the entry that breaks a buildEvery change is a byte-span rewrite, and ten gates must pass before anything is
written. See dev/normalization-plan.md.
python3 dev/eval/run.py # score dev/eval/sample/ against dev/eval/expected.bib
python3 dev/eval/test_eval.py # the harness itself; no sample, no API callrun.py runs the pipeline over real sources and compares each result, field by
field, with a hand-verified entry; entry type is scored separately. The sample and
its ground truth ship empty: build them from your library with
dev/eval/select_sample.py. See dev/eval/README.md.
Entry saved to failed_bib_file. The reply held no well-formed entry
(unbalanced braces, prose only). Repair it by hand and move it across.
Entry amber in BibDesk. See "What colours an entry" above; the log and the
entry's % AMBER comment say which failure.
bdsk-file-1 link inert after import. pyobjc-framework-Cocoa is missing from
the environment the quick action uses. Check PYTHON in automator/script.sh.
Quick action absent from Finder. On macOS 26 it sits under the contextual menu's
Services submenu, for PDF and .webloc files only. Re-run
python3 dev/install_service.py, which rebuilds it and relaunches Finder. Failing
that, tick it under System Settings ▸ Keyboard ▸ Keyboard Shortcuts ▸ Services ▸
Files and Folders.
“Context files configured in config.yaml are missing.” A file named in
rules_file, house_style_file, template_file, ref_file or example_files is
not where the configuration says. They form the cached prefix, so the agent will
not start without them.
A bot-challenged .webloc fails with the page open in a tab. Reading a tab
needs a one-time permission. Safari: Develop ▸ Allow JavaScript from Apple Events
(enable the Develop menu under Settings ▸ Advanced). Chrome: View ▸ Developer ▸
Allow JavaScript from Apple Events. Without it the log reports the refusal and the
agent falls back to CrossRef.
OCR not running. Install ocrmypdf; without it the agent extracts the text
layer only. dev/test_setup.py names the active engine.
Google OCR not used. With ocrdoc_path set, the log says why: “ocrdoc
unusable (…)” when its setup check (pdflayer.py --preflight ocr) fails, or
“Google OCR (ocrdoc) fell back to Tesseract: …” with the exit code, the timeout
or the word count. ocrdoc runs as <ocrdoc_python> <ocrdoc_path>/pdflayer.py, so
ocrdoc_python must be the interpreter of ocrdoc's own environment. ocrdoc reads one file at a time
across the Mac, so in a batch the wait for it counts against ocr_timeout.
A scanned PDF yields little but a date. Its text layer holds only whitespace,
which ocrmypdf --skip-text treats as done. Strip the layer, or OCR the file
externally, and re-run.
biber fails on entries with Volume or Number (“failed to find
unicore/version”), or rejects plain dates. macOS has pruned biber's unpacked copy
of itself. rm -rf "$TMPDIR"/par-* and re-run.
ostracon-ai/
├── CLAUDE.md # Instructions for agents developing this repository
├── NOTES.md # Design notes, measurements, developer tooling
├── config.yaml.example # Copy to config.yaml
├── install # Links bib-audit; rebuilds the quick action when stale
├── requirements.txt
├── src/
│ ├── biblio_agent.py # The pipeline; run this
│ ├── extraction_result.py # What extract_bibtex() hands save_entry()
│ ├── extract_pages.py # PDF text, OCR, the thin-yield check
│ ├── web_source.py # .webloc pages
│ ├── ai_mode.py # The type search through Google's AI Mode, in Chrome
│ ├── claude_search.py # The type search through Claude's web search, capped per item
│ ├── gemini_search.py # Gemini's type and answers
│ ├── type_fields.py # The fields each type takes, from the biblatex manual
│ ├── enrich.py # CrossRef/Scholar lookups and reconciliation
│ ├── library_match.py # Duplicates, a chapter's book fields, exemplars
│ ├── house_style.py # Normalizer rules and library spellings
│ ├── repairs.py # The cleanup spec's mechanical repairs
│ ├── bib_audit.py # Shared .bib scanner and rule predicates (dev/ links here)
│ ├── bib_normalize.py # The library's normalizer rules (dev/ links here)
│ ├── bib_validate.py # biber's data-model check; published by ./install
│ ├── bib_render.py # Fields that never reach the page
│ ├── tex/previewtemplate.tex # Neutral template for the test compile
│ ├── api_keys.py # API keys from config, environment or a command
│ └── progress_window.py # The floating window
├── prompt-context/ # The cached prefix
│ ├── extraction-rules.md # The extraction rules; first in the prefix
│ ├── gemini-questions.yaml # Gemini's question bank; not in the prefix
│ ├── biblio-template.bib # One worked example per entry type
│ ├── biblatex-chicago-notes-ref.md # Condensed field reference
│ ├── notes-test.bib # The package's annotated test suite
│ ├── cms-notes-intro-guide.md # Entry types by kind of source
│ └── biblatex-chicago-fields.md # Manual §4.2; consulted, not loaded
├── dev/ # Tooling and self-tests; see NOTES.md
│ └── eval/ # Accuracy harness; see dev/eval/README.md
├── automator/
│ └── script.sh.example # Copy to script.sh; set PYTHON and WORKDIR
├── pdf-in/ # Sources for --all
│ └── careful/ # Same, but processed with careful_model
└── pdf-out/ # Where they go afterwards
Copyright (c) 2026 yrammos. Licensed under CC BY-NC 4.0. Free for personal use; attribution requested for forks and modifications.
Three files in prompt-context/ derive from the
biblatex-chicago package (v2.3b, 2024-04-15),
© 2008–2024 David Fussner, under the
LPPL: notes-test.bib,
cms-notes-intro-guide.md and biblatex-chicago-fields.md. Each records its own
provenance and modifications in a header, as the licence requires; the derivations
are reproducible with dev/extract_intro.py and dev/extract_manual.py. See
NOTES.md for what was altered and why the .tex sources are not
vendored.
An ostracon (Greek: ὄστρακον /ós.tra.kon/, plural ὄστρακα /ós.tra.ka/) is a piece of pottery (or stone), usually broken off from a vase or other earthenware vessel. In archaeology and history, the term refers either to the fragment itself or to a potsherd used for writing or drawing.
