Calibre Library Curator
A workflow + opinionated policy set for auditing and cleaning a Calibre library
with the calibredb CLI. This is a review-then-act skill: Claude surfaces
candidates grouped for human judgment, only touches the library after explicit
per-group approval, and verifies afterward. Never do unattended bulk edits
that weren't approved for that specific group.
0. Locate the tool and library
Find calibredb first — it's commonly at
/Applications/calibre.app/Contents/MacOS/calibredb on macOS, or just
calibredb if it's on PATH. Confirm the library path (--library-path or
the tool's default) before doing anything else.
Always use --for-machine for any listing/export command. It returns
clean JSON instead of fragile human-formatted text, which matters a lot here
because author/publisher/tag strings routinely contain apostrophes, commas,
embedded quotes, and ampersands that break naive text parsing.
1. Duplicate/variant detection (authors, publishers, tags)
Pull full lists of authors, publishers, and tags with item counts
(calibredb list_categories or equivalent with --for-machine) and run
fuzzy matching to surface candidate duplicate clusters. Then apply these
filters before presenting anything to the user — a raw fuzzy match is very
noisy:
- Check co-occurrence before flagging a pair as a duplicate. If two
similar-looking tags appear together on the same book, they are almost
certainly a broad tag + a narrower/BISAC "sub" tag, not a typo pair (e.g.
African American & Black + African American & Black Studies on the same
book → leave both, don't merge).
- Hierarchical tags are not duplicates.
Fiction vs Historical Fiction,
Science Fiction vs Hard Science Fiction, Development vs
Developmental, Northwestern States vs Southwestern States — these are
genuinely distinct categories that fuzzy matching will false-positive on.
Exclude them.
- Punctuation/formatting variants are real duplicates: trailing commas,
curly vs straight quotes, missing hyphens,
Inc vs Inc. vs Incorporated,
credentials appended to a name (Faith G. Harper vs
Faith G. Harper, Phd, Lpc-S, Acs, Acn), a BISAC code prefixed vs not
(COM046070 - COMPUTERS / ... vs COMPUTERS / ... with the code just
missing), ; vs &/, as a separator artifact.
- Use item counts to suggest — never silently pick — the canonical
spelling. Present the most-used variant as the recommendation, but always
let the user confirm or override, especially for publisher names that might
actually be distinct imprints (e.g. don't assume "Mango Media Inc" and
"Mango Publishing Group" are the same company — ask).
- Present results grouped by category (Authors / Publishers / Tags) as a
table or list with counts and a recommended canonical name, and flag
open questions explicitly (which spelling to standardize on, whether two
similar names are actually the same entity). Wait for the user's per-group
decision before merging anything.
Executing merges
- Merge by
calibredb search to find affected books, then
calibredb set_metadata per book. Run everything through subprocess with
argument lists, not shell strings — these values routinely contain
apostrophes and embedded quotes that break shell quoting.
See scripts/batch_set_metadata.py for the pattern.
- Test on 1–2 books first before running a bulk batch, to confirm
behavior for tricky fields (multi-value tags, publisher strings with
commas) matches expectations.
- After renaming/merging an author, always check and fix
author_sort
separately — it does not auto-update via the CLI and will keep showing
the old name in brackets in Calibre's UI otherwise. Match whatever
Last, First (or other) convention the rest of the library already uses —
check existing entries rather than assuming a format.
- After the batch completes, re-pull categories and confirm before/after
counts and that no duplicate spellings remain.
Malformed multi-author fields
Watch for author fields where multiple people got smashed into one bogus
"author" string because Calibre's separator (&) wasn't used — e.g. someone
entered ; between names for a subset of authors on a book. This is a
data-entry bug, not a duplicate-spelling issue: flag it separately from
the merge review, and if approved, split it into proper individual author
entries joined with & on re-entry, then fix author_sort for each.
2. Tag hygiene beyond simple duplicates
Separately from duplicate detection, look for raw BISAC/taxonomy path
strings living as tags (e.g. COMPUTERS / Security / Viruses & Malware)
sitting alongside their already-split-out keyword tags. The default policy
(confirm with the user, but this is the right default):
- Remove the full
A / B / C path-string tag.
- Ensure every component of that path ends up as its own individual tag.
- Reuse existing tags where they already match rather than creating new
near-duplicates — including collapsing "and" vs "&" spelling so you don't
end up with both "Software Development and Engineering" and the
library's existing "Software Development & Engineering".
- Pull the complete list of path-string tags first (don't just fix the ones
that happened to surface during the earlier duplicate scan) so the pass is
exhaustive.
3. Format-driven tagging rules
Apply structural tagging rules across the whole library when asked, e.g.
"every .cbz should have Comics & Graphic Novels." Pull the full list of
matching books, note how many already have vs. need the tag, and append
to each book's existing tag list — never overwrite/replace it.
4. Fiction / Nonfiction coverage (or any universal-tag requirement)
When asked to ensure every book has exactly one of a pair of top-level tags:
- Before introducing a new spelling, check what the library already uses.
If the user says
Non-Fiction but the library already has Nonfiction
(no hyphen) on other tags, point this out and recommend matching the
existing convention rather than creating a second spelling — dedup effort
is wasted if new near-duplicates get introduced in the same session.
- Triage books into confidence tiers rather than guessing uniformly:
- Already compliant — skip.
- Parent-tag gaps — book has
Juvenile Fiction/Young Adult Nonfiction/etc. but not the plain parent tag. Trivial, high confidence.
- High-confidence from other tags — genre/subject tags that clearly
imply Fiction or Nonfiction (Computers/Security/Cooking/Business →
Nonfiction; Science Fiction/Media Tie-In/novel → Fiction). Spot-check
the list for anything that looks misclassified before batch-applying.
- No tag signal at all — classify from title/author/genre knowledge,
but split into "confident" vs. "genuinely unsure." For confident ones,
proceed with the classification but tell the user what you did. For
unsure ones, export a CSV for the user to mark up and return rather
than guessing — include your proposed classification as a column so
they can just confirm or correct it, and confirm explicitly whether
"apply high-confidence automatically" also covers this whole tier or
just the ones you're unsure about (this is an easy miscommunication —
spell out the scope of what you're about to auto-apply).
- If there's a secondary tagging rule bundled in (e.g. "also make sure all
cookbooks have
Cooking"), fold it into the same batch pass rather than
running two separate sets of set_metadata calls per book.
- One consolidated per-book update plan, then one batch execution, then
verify — not per-rule passes that touch the same book multiple times.
5. Whole-library pattern sweep ("what are we doing more than one way")
When asked for this kind of audit, split findings into two buckets and
present both, don't just fix things silently:
A. Inconsistent conventions (multiple ways of doing the same thing) —
things like: series metadata (series/series_index) set for some
multi-volume works but not others despite "Volume 1"/"Series 2" being right
in the title; a tag re-introduced as a near-duplicate during a later pass
(catch tag redundancy that sneaks back in after later tagging work — always
re-check the full tag list, not just the tags touched in the current pass);
inconsistent author attribution (some multi-author comics have real credits,
others are lazily set to Unknown when the info is knowable); mixed file
formats where one book has redundant copies in two formats; a metadata field
that's essentially unused library-wide (worth flagging even if not "wrong").
B. Likely mistakes (wrong regardless of style) — true duplicate book
entries (same author/file/everything, accidental double-import); wrong-edition
metadata (e.g. language/publisher/ISBN belonging to a different translation
than the actual file — search online to confirm and fix the correct
edition's metadata rather than just flagging it); malformed identifier
fields (e.g. an ISBN landing in the identifier-type slot instead of the
value slot); broken or duplicate series_index values across volumes of the
same series (verify the correct reading/publication order before fixing);
orphaned series_index with no series name set.
Note: Calibre sets series_index to 1.0 as its universal default for
every book without a series — this is not a real stored value and
doesn't need to be "removed" from a standalone book; it's indistinguishable
from any other non-series book and only becomes meaningful once a series
name is set. Don't waste an operation trying to strip it.
Offer the user two paths: work through findings one at a time, or knock out
the clearly-mistaken/clear-cut items immediately while leaving genuine
judgment calls (ambiguous language/edition calls, whether an "Unknown" author
is fixable, imprint-vs-company questions) for explicit sign-off.
6. New-book intake (e.g. a fresh batch from Project Gutenberg or similar)
When the user adds a batch of same-source books and asks for tidy-up:
- Pull full current metadata for just the new batch first.
- Research anything uncertain (translation edition, anthology contents,
which volume of a multi-volume work) before writing synopses/comments
for all of them, not after — verify first, write once.
- Apply consistent publisher/tag conventions, and retroactively apply the
same convention to any older books from the same source already in the
library, so the whole source-group stays consistent (don't leave the old
ones on a different convention just because they predate this pass).
- Link series membership the same way the rest of the library does it
(numbered by publication order unless there's a clear canonical order).
- Do a spot-check pass after applying comments/descriptions in bulk —
mismatched volume descriptions (e.g. swapping Volume 1 and Volume 2
synopses) are an easy mistake when writing several similar comments at
once.
- Flag genuine content overlaps (e.g. a story that's both a standalone entry
and included in an anthology already in the library) as a note, not an
automatic fix — that's a curation choice, not a metadata error.
General execution principles
- Never touch the library before presenting findings and getting a
per-group decision. Batches should be scoped to what was actually
approved.
- JSON in, argument-list subprocess out.
--for-machine for reads,
Python subprocess with arg lists (never shell strings) for
set_metadata writes.
- Test small, then batch, then verify. Run 1–2 books, confirm behavior,
run the full batch, then re-pull categories/counts to confirm the
before/after state matches what was approved.
- Match existing conventions over introducing new ones — naming
(
Last, First, tag spelling, hyphenation) should follow whatever the
majority of the library already does, surfaced to the user as a
recommendation rather than assumed.
- When confidence is low, export a CSV for markup rather than guessing
silently — include your proposed answer as a column so the user can
confirm-in-bulk instead of typing from scratch.
- Re-verify after every batch: category counts, spot-checks on a few
affected books, and confirmation that no new near-duplicates were
introduced by the fix itself.
See scripts/batch_set_metadata.py for a reusable, safe pattern for
batched set_metadata calls (arg-list subprocess, per-book error capture,
dry-run mode).
1---2name: calibre-library-curator3description: Use this skill whenever the user wants to review, clean up, deduplicate, or standardize metadata in a Calibre ebook library via the calibredb CLI — merging duplicate/variant authors, publishers, or tags, enforcing Fiction/Nonfiction tagging, tidying series numbering, fixing malformed metadata, or doing a general "audit my library for inconsistencies" pass. Trigger on mentions of calibredb, "my calibre library", "duplicate authors/publishers/tags", "clean up my ebooks", or requests to standardize metadata across a book collection. This skill is opinionated. It encodes specific judgment calls (naming conventions, what counts as a real duplicate vs. a legitimate distinct tag, how to handle ambiguous classifications) learned from actual library-cleanup sessions — follow its heuristics rather than re-deriving policy from scratch each time.4---56# Calibre Library Curator78A workflow + opinionated policy set for auditing and cleaning a Calibre library9with the `calibredb` CLI. This is a **review-then-act** skill: Claude surfaces10candidates grouped for human judgment, only touches the library after explicit11per-group approval, and verifies afterward. Never do unattended bulk edits12that weren't approved for that specific group.1314## 0. Locate the tool and library1516Find `calibredb` first — it's commonly at17`/Applications/calibre.app/Contents/MacOS/calibredb` on macOS, or just18`calibredb` if it's on PATH. Confirm the library path (`--library-path` or19the tool's default) before doing anything else.2021**Always use `--for-machine` for any listing/export command.** It returns22clean JSON instead of fragile human-formatted text, which matters a lot here23because author/publisher/tag strings routinely contain apostrophes, commas,24embedded quotes, and ampersands that break naive text parsing.2526## 1. Duplicate/variant detection (authors, publishers, tags)2728Pull full lists of authors, publishers, and tags with item counts29(`calibredb list_categories` or equivalent with `--for-machine`) and run30fuzzy matching to surface *candidate* duplicate clusters. Then apply these31filters before presenting anything to the user — a raw fuzzy match is very32noisy:3334- **Check co-occurrence before flagging a pair as a duplicate.** If two35 similar-looking tags appear together on the same book, they are almost36 certainly a broad tag + a narrower/BISAC "sub" tag, not a typo pair (e.g.37 `African American & Black` + `African American & Black Studies` on the same38 book → leave both, don't merge).39- **Hierarchical tags are not duplicates.** `Fiction` vs `Historical Fiction`,40 `Science Fiction` vs `Hard Science Fiction`, `Development` vs41 `Developmental`, `Northwestern States` vs `Southwestern States` — these are42 genuinely distinct categories that fuzzy matching will false-positive on.43 Exclude them.44- **Punctuation/formatting variants are real duplicates**: trailing commas,45 curly vs straight quotes, missing hyphens, `Inc` vs `Inc.` vs `Incorporated`,46 credentials appended to a name (`Faith G. Harper` vs47 `Faith G. Harper, Phd, Lpc-S, Acs, Acn`), a BISAC code prefixed vs not48 (`COM046070 - COMPUTERS / ...` vs `COMPUTERS / ...` with the code just49 missing), `;` vs `&`/`,` as a separator artifact.50- **Use item counts to suggest — never silently pick — the canonical51 spelling.** Present the most-used variant as the recommendation, but always52 let the user confirm or override, especially for publisher names that might53 actually be distinct imprints (e.g. don't assume "Mango Media Inc" and54 "Mango Publishing Group" are the same company — ask).55- Present results grouped by category (Authors / Publishers / Tags) as a56 table or list with counts and a recommended canonical name, and flag57 open questions explicitly (which spelling to standardize on, whether two58 similar names are actually the same entity). Wait for the user's per-group59 decision before merging anything.6061### Executing merges6263- Merge by `calibredb search` to find affected books, then64 `calibredb set_metadata` per book. Run everything through subprocess with65 **argument lists, not shell strings** — these values routinely contain66 apostrophes and embedded quotes that break shell quoting.67 See `scripts/batch_set_metadata.py` for the pattern.68- **Test on 1–2 books first** before running a bulk batch, to confirm69 behavior for tricky fields (multi-value tags, publisher strings with70 commas) matches expectations.71- **After renaming/merging an author, always check and fix `author_sort`72 separately** — it does not auto-update via the CLI and will keep showing73 the old name in brackets in Calibre's UI otherwise. Match whatever74 `Last, First` (or other) convention the rest of the library already uses —75 check existing entries rather than assuming a format.76- After the batch completes, re-pull categories and confirm before/after77 counts and that no duplicate spellings remain.7879### Malformed multi-author fields8081Watch for author fields where multiple people got smashed into one bogus82"author" string because Calibre's separator (`&`) wasn't used — e.g. someone83entered `;` between names for a subset of authors on a book. This is a84**data-entry bug, not a duplicate-spelling issue**: flag it separately from85the merge review, and if approved, split it into proper individual author86entries joined with `&` on re-entry, then fix `author_sort` for each.8788## 2. Tag hygiene beyond simple duplicates8990Separately from duplicate detection, look for **raw BISAC/taxonomy path91strings living as tags** (e.g. `COMPUTERS / Security / Viruses & Malware`)92sitting alongside their already-split-out keyword tags. The default policy93(confirm with the user, but this is the right default):9495- Remove the full `A / B / C` path-string tag.96- Ensure every component of that path ends up as its own individual tag.97- **Reuse existing tags where they already match** rather than creating new98 near-duplicates — including collapsing "and" vs "&" spelling so you don't99 end up with both "Software Development and Engineering" and the100 library's existing "Software Development & Engineering".101- Pull the *complete* list of path-string tags first (don't just fix the ones102 that happened to surface during the earlier duplicate scan) so the pass is103 exhaustive.104105## 3. Format-driven tagging rules106107Apply structural tagging rules across the whole library when asked, e.g.108"every `.cbz` should have `Comics & Graphic Novels`." Pull the full list of109matching books, note how many already have vs. need the tag, and **append**110to each book's existing tag list — never overwrite/replace it.111112## 4. Fiction / Nonfiction coverage (or any universal-tag requirement)113114When asked to ensure every book has exactly one of a pair of top-level tags:115116- **Before introducing a new spelling, check what the library already uses.**117 If the user says `Non-Fiction` but the library already has `Nonfiction`118 (no hyphen) on other tags, point this out and recommend matching the119 existing convention rather than creating a second spelling — dedup effort120 is wasted if new near-duplicates get introduced in the same session.121- Triage books into confidence tiers rather than guessing uniformly:122 1. **Already compliant** — skip.123 2. **Parent-tag gaps** — book has `Juvenile Fiction`/`Young Adult124 Nonfiction`/etc. but not the plain parent tag. Trivial, high confidence.125 3. **High-confidence from other tags** — genre/subject tags that clearly126 imply Fiction or Nonfiction (Computers/Security/Cooking/Business →127 Nonfiction; Science Fiction/Media Tie-In/novel → Fiction). Spot-check128 the list for anything that looks misclassified before batch-applying.129 4. **No tag signal at all** — classify from title/author/genre knowledge,130 but split into "confident" vs. "genuinely unsure." For confident ones,131 proceed with the classification but tell the user what you did. For132 unsure ones, **export a CSV for the user to mark up and return** rather133 than guessing — include your proposed classification as a column so134 they can just confirm or correct it, and confirm explicitly whether135 "apply high-confidence automatically" also covers this whole tier or136 just the ones you're unsure about (this is an easy miscommunication —137 spell out the scope of what you're about to auto-apply).138- If there's a secondary tagging rule bundled in (e.g. "also make sure all139 cookbooks have `Cooking`"), fold it into the same batch pass rather than140 running two separate sets of `set_metadata` calls per book.141- One consolidated per-book update plan, then one batch execution, then142 verify — not per-rule passes that touch the same book multiple times.143144## 5. Whole-library pattern sweep ("what are we doing more than one way")145146When asked for this kind of audit, split findings into two buckets and147present both, don't just fix things silently:148149**A. Inconsistent conventions** (multiple ways of doing the same thing) —150things like: series metadata (`series`/`series_index`) set for some151multi-volume works but not others despite "Volume 1"/"Series 2" being right152in the title; a tag re-introduced as a near-duplicate during a later pass153(catch tag redundancy that sneaks back in after later tagging work — always154re-check the full tag list, not just the tags touched in the current pass);155inconsistent author attribution (some multi-author comics have real credits,156others are lazily set to `Unknown` when the info is knowable); mixed file157formats where one book has redundant copies in two formats; a metadata field158that's essentially unused library-wide (worth flagging even if not "wrong").159160**B. Likely mistakes** (wrong regardless of style) — true duplicate book161entries (same author/file/everything, accidental double-import); wrong-edition162metadata (e.g. language/publisher/ISBN belonging to a different translation163than the actual file — **search online to confirm and fix the correct164edition's metadata** rather than just flagging it); malformed identifier165fields (e.g. an ISBN landing in the identifier-*type* slot instead of the166value slot); broken or duplicate `series_index` values across volumes of the167same series (verify the correct reading/publication order before fixing);168orphaned `series_index` with no `series` name set.169170Note: Calibre sets `series_index` to `1.0` as its universal default for171**every** book without a series — this is not a real stored value and172doesn't need to be "removed" from a standalone book; it's indistinguishable173from any other non-series book and only becomes meaningful once a `series`174name is set. Don't waste an operation trying to strip it.175176Offer the user two paths: work through findings one at a time, or knock out177the clearly-mistaken/clear-cut items immediately while leaving genuine178judgment calls (ambiguous language/edition calls, whether an "Unknown" author179is fixable, imprint-vs-company questions) for explicit sign-off.180181## 6. New-book intake (e.g. a fresh batch from Project Gutenberg or similar)182183When the user adds a batch of same-source books and asks for tidy-up:184185- Pull full current metadata for just the new batch first.186- Research anything uncertain (translation edition, anthology contents,187 which volume of a multi-volume work) **before** writing synopses/comments188 for all of them, not after — verify first, write once.189- Apply consistent publisher/tag conventions, and retroactively apply the190 same convention to any older books from the same source already in the191 library, so the whole source-group stays consistent (don't leave the old192 ones on a different convention just because they predate this pass).193- Link series membership the same way the rest of the library does it194 (numbered by publication order unless there's a clear canonical order).195- Do a spot-check pass after applying comments/descriptions in bulk —196 mismatched volume descriptions (e.g. swapping Volume 1 and Volume 2197 synopses) are an easy mistake when writing several similar comments at198 once.199- Flag genuine content overlaps (e.g. a story that's both a standalone entry200 and included in an anthology already in the library) as a note, not an201 automatic fix — that's a curation choice, not a metadata error.202203## General execution principles2042051. **Never touch the library before presenting findings and getting a206 per-group decision.** Batches should be scoped to what was actually207 approved.2082. **JSON in, argument-list subprocess out.** `--for-machine` for reads,209 Python subprocess with arg lists (never shell strings) for210 `set_metadata` writes.2113. **Test small, then batch, then verify.** Run 1–2 books, confirm behavior,212 run the full batch, then re-pull categories/counts to confirm the213 before/after state matches what was approved.2144. **Match existing conventions over introducing new ones** — naming215 (`Last, First`, tag spelling, hyphenation) should follow whatever the216 majority of the library already does, surfaced to the user as a217 recommendation rather than assumed.2185. **When confidence is low, export a CSV for markup** rather than guessing219 silently — include your proposed answer as a column so the user can220 confirm-in-bulk instead of typing from scratch.2216. **Re-verify after every batch**: category counts, spot-checks on a few222 affected books, and confirmation that no new near-duplicates were223 introduced by the fix itself.224225See `scripts/batch_set_metadata.py` for a reusable, safe pattern for226batched `set_metadata` calls (arg-list subprocess, per-book error capture,227dry-run mode).