/calibre-mcp:calibre-distill-topicfrom calibre-mcp
Synthesizes a single topic across multiple Calibre books into a concept-keyed agent skill with decision frameworks, cross-source config tables, and an agree/disagree section. Requires 3+ sources and drives the calibre-mcp server for chapter maps and semantic search.
Ships in calibre-mcp. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Synthesize a single topic across several books in your Calibre library into one
concept-keyed agent skill. Where calibre-distill mirrors one book, this skill mirrors
nobody's structure: it takes a thin topic slice from each of ≥3 sources and re-authors
them into original, multi-source knowledge — a decision framework, per-concept sections, a
cross-source config table, and an explicit "where the sources disagree or complement"
section (the whole point of the aggregate class).
If you have exactly one book, or the user wants a faithful per-book distill, use
calibre-distill instead — route single-book requests there.
A skill directory with:
SKILL.md (~2.5–4K tokens) — concept-keyed synthesis (layered overview → decision
framework → per-concept sections → cross-source config table → disagree/complement →
L4 bibliography). No chapter files by default: the topic skill IS the pre-synthesized
bundle.distill.manifest.yaml — a kind: topic-aggregate provenance sidecar (D2.8 shape),
never loaded into L1 context.Pick a destination the user's host agent can discover (same roots as calibre-distill). Probe in order:
~/.claude/skills/~/.copilot/skills/ → ~/.agents/skills/~/.config/agents/skills/.claude/skills/ → .github/skills/ → .agents/skills/When more than one valid root exists, ask once and remember for the session — do not silently default. L1-budget note (E5): every installed skill adds its description to the always-loaded metadata level; when the target is a global root, warn the user and offer a per-project install or symlink for selective activation.
This skill itself lives in the calibre-mcp repo (skills/calibre-distill-topic/).
Install it by copying or symlinking to ~/.claude/skills/calibre-distill-topic/. The
calibre-mcp MCPB bundle cannot ship skills — install separately from the MCP server.
Parse the input into a topic phrase, optional book references (ids / titles /
query), and an optional SKILL_NAME slug.
If no topic phrase is provided, stop:
"calibre-distill-topic needs a topic — give me a topic phrase, optionally with book refs and a skill slug. Example:
calibre-distill-topic "kafka reliability" 187 182 571 186 kafka-reliabilityorcalibre-distill-topic "database indexing"."
Requires the calibre-mcp server connected. If its tools aren't available, say so and stop.
Find candidate books for the topic:
calibre_get_book for numeric ids;
calibre_search for titles/queries) and confirm title/authors.calibre_search the library on the topic (search title, tags, and
comments; e.g. calibre_search(query="kafka") then narrow) and present candidates.Present the candidate set with id / title / authors and ask the user to confirm or edit the source set.
Enforce the D1.7 minimum: 3 sources. With fewer than 3 confirmed sources, do not build a topic skill — offer either:
calibre-distill), orA ~90%-one-book "topic" skill re-enters the per-book legal analysis, which is why the floor is load-bearing (D1.7 validity condition 1).
Record SOURCES = [{ id, title, authors, formats }].
For each source, find where the topic lives — do NOT read whole books.
calibre_get_content(id=<id>, structure=true) → chapters: [{ n, heading, startChar, endChar, approxTokens, cursor }], plus hasToc, detector,
totalChars, format, backend.calibre_search(scope=book, id=<id>, query="<topic terms>") (FTS) → hit offsets; map
each hit to a chapter by finding the chapter whose [startChar, endChar) contains it.
Chapters with the most hits rank highest.calibre_semantic_search(scope=book, bookId=<id>, query="<topic>") → ranked
passages with offsets → same offset→chapter mapping. (Needs the book indexed via
calibre_build_index bookId=<id>; if not indexed, use FTS and say so.)topic_chapters as { n, heading } pairs (both together — bare "ГЛАВА N" headings
don't discriminate).If a source has no relevant chapters after vocabulary adaptation, drop it (and re-check the ≥3 floor).
Before reading anything, present the plan and get confirmation:
📚 Topic: <topic phrase>
🗂 Sources (<N>):
[<SRC>] <Title> — <Authors> (id <id>) → chapters <n(heading), …> ~<K> tokens
…
📄 Topic slice total: ~<K> tokens (vs ~<K> tokens whole-book — reading only the slices)
📁 To generate: SKILL.md (~3K tokens) + distill.manifest.yaml
➡ Proceed?
Assign each source a short citation tag (SRC) up front — e.g. DG2, KiA, KTiP,
KS — from author/title initials; these tags carry through every extract and the final
skill. Wait for confirmation.
For each source, read only its selected chapters via their cursor
(calibre_get_content(id=<id>, cursor=<chapter.cursor>, maxChars=<budget>); follow
nextCursor within a chapter, stop at the next chapter's startChar). Nothing else from
the book enters context.
If the host supports subagents, run the per-source extractions in parallel (one subagent per source, each returning its structured extract); otherwise do them sequentially.
Produce a structured extract per source — not prose:
Each item cited (SRC chN).
HARD RULES per extract (D1.3, applied per source):
Merge the per-source extracts into one SKILL.md (~2.5–4K tokens), organized by concept. Required sections (from the validated prototype):
(SRC chN).Balance: no single source may dominate. Track a rough contribution_frac per source;
no source > 0.50 (D1.7 validity condition 1). If one book is carrying the skill,
either broaden the other sources' slices or reconsider whether this is really a topic skill.
The bibliography is mandatory (attribution is an EU/UA precondition, not a courtesy) and it doubles as the live-source binding: a recipient who owns a source gets depth on demand.
For each source, list:
calibre_extract_isbn(id, apply=true) — an offline front-matter
scan — else fall back to the fallback_key below — E2).{ n, heading } pairs (n + heading TOGETHER — bare "ГЛАВА N"
doesn't discriminate across chapters).calibre_search(identifiers:isbn:<isbn>) → local id →
calibre_get_content(id, structure=true) → match the chapter headings/ordinals → mint
fresh cursors on their own extraction.No-ISBN source → provide a fallback_key (title:"…" AND authors:"…" query) and mark
it unverified. NEVER put char-offset cursors in the artifact (D1.3 #5 / D2.4 — cursors
are non-portable across machines/editions and are inducement-optics risk).
Close the bibliography with: all prose is original synthesis; if a book isn't in the reader's library the skill stands alone; consider buying each book (each covers far more than this one topic).
Write distill.manifest.yaml next to SKILL.md, following the prototype's D2.8 shape
exactly:
manifest_schema: 1
kind: topic-aggregate
skill:
name: <skill_name>
digest: "sha256:TBD" # sha256 of the distillate tree at publish time
revision: 1
identity:
topic: <topic-slug> # the topic IS the identity
language: en
sources: # each ≤ the contribution cap
- isbn13: "<isbn or null>"
title: "<Full Title>"
work: "<author:work-slug>" # discovery grouping only (optional)
authors: ["<Author>", …]
edition_note: "<e.g. RU translation of …>" # optional
topic_chapters: [{ n: <N>, heading: "<heading>" }, …]
contribution_frac: <0..1>
source_content_hash: "sha256:TBD" # hash of the extracted text read
# no-ISBN source additionally carries:
# fallback_key: 'title:"…" AND authors:"…"'
# identity_confidence: unverified
distillate:
license: "CC-BY-4.0"
transform: "multi-source-topic-synthesis"
files: [SKILL.md]
quote_budget: { max_words_per_quote: 25, max_total_words: 200, used: <N> }
provenance:
generator: "calibre-mcp"
generator_version: "<x.y.z>"
recipe: "calibre-distill-topic"
recipe_version: "1.0.0"
distiller_model: "<model id>"
generated_at: "<YYYY-MM-DD>"
method: "per-source topic-slice extraction -> concept-keyed cross-source synthesis"
quality:
structural: pass # bibliography + per-source citations present
legal_gate: # D1.4 checks — NOT YET AUTOMATED (manual until prompt 04)
shingle: not-run
compression_floor: pass
heading_match: pass # concept-keyed; no source ToC mirrored
cursors: pass # no char-offset cursors in the artifact
grounding: not-run
comparison:
identity_key: "topic:<topic-slug>"
sources_fingerprint: "sha256(sorted ISBN list + work slugs)"
schema: 1
distiller_family: "<model family>"
recipe_version: "1.0.0"
revision: 1
Leave sha256:TBD placeholders where a digest isn't computed at generation time; fill
quote_budget.used with the actual quoted-word count. The legal_gate checks stay
not-run (shingle/grounding) or manually-assessed (pass) until prompt 04's verifier ships.
Manual until the automated verifier lands. Scan your own output:
{ n, heading } bindings.Any failure → fix before reporting.
Report:
✅ Topic skill created: $SKILLS_HOME/<skill_name>/
📚 Topic: <topic phrase> (<N> sources)
[<SRC>] <Title> — contribution ~<frac> chapters <n(heading), …>
…
Files generated:
SKILL.md — concept-keyed synthesis (~X tokens)
distill.manifest.yaml — provenance sidecar (topic-aggregate)
Self-check: contribution balance <ok/flag> · quote budget <used>/200 · cursors none
Optional Step-9.5-style write-back (opt-in; requires the write gate
CALIBRE_MCP_ENABLE_WRITE=1): offer to tag each source book with the topic tag (+ marker
distilled-topic) and append a short distill note to comments, so
calibre_search "tags:<topic>" later finds the whole source set. Preview-first — show
the proposed tag/comment diff and ask before applying. Read → union → write (
set_metadata replaces the whole field, so merge existing tags first — never clobber). If
the write tools are absent, report "skipping library stamping (writes disabled)" and finish.
calibre-distill).{ n, heading } together; never char-offset cursors.calibre_search scope=book to confirm a config value
or framework is really in that source before attributing it.What SKILL.md sets; muted values are Claude Code's defaults
5 skills in this plugin
/calibre-distillTurn ONE Calibre book into a reusable agent skill — frameworks, mental models, principles, techniques, anti-patterns, glossary, cheatsheet — by driving the calibre-mcp server (chapter map, keyword + semantic in-book search; no temp files, no Python). Use when the user wants to study a Calibre book through Claude Code / Copilot / Amp, apply an author's frameworks while working, fold a new source or a targeted topic slice into an existing skill, or stamp what they learned back into the library (tags + distill note via the gated write tools). Works on EN + RU/UK books. Single-book distiller — for one topic synthesized across several books, use the sibling calibre-distill-topic./calibre-mcpSearch, read, and curate your Calibre ebook library. The operating manual for the calibre-mcp server (20 tools) with the calibre CLI as escape hatch. Covers picking the right search (metadata query vs full-text vs semantic), reading book content, chapter maps and book figures, gated preview-first writes (metadata, tags, bulk edits), deduplication, quality audits, ISBN extraction + metadata recovery, add/remove/merge books, semantic-index builds, and safe CLI routing through the Content Server while the Calibre GUI is running (convert, export, catalog). Use for any ebook/library task: finding books, searching inside them, curating metadata, or maintenance. Triggers on 'book', 'ebook', 'calibre', 'library', 'книга', 'бібліотека', 'знайди в книзі'.npx claudepluginhub caelum29/calibre-mcp --plugin calibre-mcpOther plugins' skills for the same job