- 日常查手册式问答:把 800 页的框架文档转成技能,Agent 只加载相关章节,避免每次对话都带整本书的 token 成本
- 离线批量生成知识库:用 glob 把一整个 docs 目录合并成一个技能,比逐篇 RAG 切块少了向量库这一层依赖
- 给团队统一术语:生成的术语表和决策速查表可以直接进 repo,新人问 Agent 时答案来自同一份原文
- 在 Claude Code / Codex / Copilot CLI 之间复用同一份技能目录,换宿主不用重做知识整理
book-to-skill
virgiliojr94MIT活跃维护 有专家点评把技术书 PDF 转成 Claude Code 技能包,方便边工作边查阅和学习,省去手动整理笔记的麻烦。
Turn any technical book PDF into a Claude Code skill — ready to study, reference, and use while you work.
专家点评
上手难度:进阶更新于 2026-11-11把技术书 PDF 转成按需加载的 Agent Skill,替代把整本书塞进上下文的做法
适用场景
踩坑
- 技术类 PDF 不装 docling 就直接转,表格和代码块会静默丢失,生成的技能看起来正常但内容是残缺的,事后很难发现
- 扫描版 PDF 没有文本层,不先跑 ocrmypdf 会得到空或乱码的技能文件,转换阶段不会报错
- 技能目录按宿主区分,装错位置不会被识别,表现为「装好了但 Agent 完全不知道有这个东西」
- issue 里出现过同名项目的恶意重传仓库,clone 前要核对作者名
同类对比
如果只是想让 Agent 检索文档而不需要结构化技能,直接用向量库 RAG 更省事;如果书本身是纯文本或 Markdown,跳过 PDF 提取环节直接手写 SKILL.md 更可控
npx skills add virgiliojr94/book-to-skill
git clone https://github.com/virgiliojr94/book-to-skill.git ~/.claude/skills/book-to-skillREADME 未说明,纯 Python 文本提取,无 GPU 或显存要求
项目说明
由 README 自动翻译提炼把技术书或文档转成按需加载的 Agent Skill,让 AI 助手基于原文作答而不是瞎编
把技术书 PDF 转成 Claude Code 技能包,方便边工作边查阅和学习,省去手动整理笔记的麻烦。
核心能力
- 用 Python 提取器把 PDF/EPUB/DOCX 等转成干净文本
- 生成 SKILL.md 加每章独立文件,按需加载控制 token
- 自动产出术语表、模式库和速查决策表
- 支持文件夹、glob 和多文件合并成一个技能
- 兼容 Claude Code、Copilot CLI、Codex 等 Agent Skills 宿主
容易踩的坑
技术类 PDF 需先 pip3 install docling,否则表格和代码块会丢;扫描版 PDF 没有文本层,需先用 ocrmypdf 做 OCR 再转换;MOBI/AZW 依赖外部 Calibre 的 ebook-convert,不是 pip 包;不同宿主的技能目录不同,装错位置不会被识别
- v1.4.0最新正式版2026-08-10 · 2026-08-10 19:06 UTC
Extraction reliability release: six fixes for silent content loss or silent wrong answers, plus the first changelog generated from commit messages.
Highlights
- Scanned PDFs fail fast. An image-only PDF used to run the whole extraction chain — Docling across every page in technical mode — before failing with a message about Unicode sanitization. It now stops on the first pages in ~0.01s and tells you to run
ocrmypdf(#130), and the docs finally state the limit (#132). - Real words stopped being deleted. Page-edge cleanup treated any short word built from
ivxlcdmas a page number, so "MIX", "CIVIL" and "VIVID" vanished when they were alone on a page's first or last line (#119). - Table-of-contents detection no longer depends on input order. With multiple sources,
has_tocwas re-derived over the joined corpus and its 30k-char window only ever covered the first book — the same two books in the opposite order gave opposite answers (#114). - A single unreadable file no longer aborts the batch (#120), and
~in a quoted glob is expanded, so the README's own example works (#118). - CJK tables of contents with inserted whitespace (
目 录, including the ideographic space) are detected (#112). - The generated-skill scanner reads nested chapters and reports Markdown it left out of scope instead of printing an unqualified pass (#115).
Thanks to @Zhengzhongjie, @Hotragn, @aryansk and @dex0shubham for these fixes.
Added
- Warn on unknown CLI flags instead of silently ignoring (#89)
- Make the site indexable and shareable
- Add Booklin banner and hand-made share card
- Apply pdftotext cleanup to pypdf and pdfminer paths too (#101)
Documentation
- Sync architecture, skill spec, and README with v1.3.0
- Reserve README project listings for sponsors
- Add Booklin mascot to the README (#106)
- Split README into pages and add Booklin mascot set (#110)
- State that scanned PDFs need OCR first (#132)
Fixed
- Gate lowercase Roman behind heading context, add FP coverage (#88)
- CJK-aware token estimate (rescued from #70) (#103)
- Support documented help flags (#97)
- Emit block boundaries at end tags in the stdlib parser (#107)
- Skip control destination groups in the dependency-free fallback (#109)
- Scrub bidirectional controls and remaining invisible code points (#108)
- Write metadata.json as UTF-8 (#105)
- Detect Markdown-prefixed chapter headings (#91) (#92)
- Reserve the banner's space on the site build
- Abort early on scanned PDFs with an OCR hint (#130)
- Stop edge-of-page cleanup deleting real one-word lines (#119)
- Expand
~in input paths (#118) - Skip an unreadable source instead of aborting the batch (#120)
- Detect a table of contents in any source, not just the first (#114)
- Scan nested chapters and report markdown left out of scope (#115)
- Detect whitespace-separated CJK ToC headers (#112)
- Stop duplicating the PR number in generated entries (#131)
Miscellaneous
- Untrack stale compiled bytecode (#94)
- Generate CHANGELOG from commits with git-cliff (#104)
Notes on selected changes
Written by hand before this file became generated; kept for the detail the one-line entries above do not carry.
CJK-aware token estimate —
estimate_tokensnow counts CJK codepoints directly (againstCJK_CHARS_PER_TOKEN) instead of whitespace-delimited words, fixing a ~1000× undercount for space-less Chinese/Japanese books in the cost pre-flight. Latin behavior is unchanged and the estimate stays deterministic and dependency-free (rescued from #70).Stale tracked bytecode —
scripts/__pycache__/extract.cpython-313.pycwas committed alongside the EPUB-support change and has been tracked ever since, despite.gitignorelisting both*.pycand__pycache__/(ignore rules do not untrack already-committed files). The file was inert — its timestamp-based header records a 11,321-byte source whilescripts/extract.pyis now 871 bytes, so Python always invalidated it and re - Scanned PDFs fail fast. An image-only PDF used to run the whole extraction chain — Docling across every page in technical mode — before failing with a message about Unicode sanitization. It now stops on the first pages in ~0.01s and tells you to run
- v1.3.02026-07-30 · 2026-07-30 14:19 UTC
查看更新说明
book-to-skill v1.3.0
36 commits since v1.2.0. This release is security-heavy and adds multilingual chapter detection.
🔒 Security
- Generated-skill prompt-injection scan — a dependency-free advisory scanner flags instruction-override phrases, model-control tags, invisible Unicode, authority-widening frontmatter, and exfiltration-shaped content before a generated skill is accepted or published. Findings never echo attacker-controlled text (#73, #74).
- Invisible-Unicode extraction hardening — every parser result now strips zero-width
U+200B/200C/200D/2060/FEFFand the Unicode tag blockU+E0000–E007F, reports the removal count, and rejects sources with no visible content after the scrub (#73, #75, #85). - DOCX XXE / Billion Laughs and subprocess argument-injection hardening, plus dependency CVE review on PRs (#53, #54).
🌏 Multilingual chapter detection
- Korean
제N장/제N절/제N편and the statutory의Nform —제prefix required so the everyday counter장never false-matches. Corpus-validated (precision 0.999 / recall 1.000) (#82). - Thai
บทที่ N/ตอนที่ N/ภาคที่ Nwith Thai or Arabic numerals. - Roman
Chapter I.(chapter word + Roman numeral) — Project Gutenberg #132 goes from 2 phantom "chapters" to the 13 real headings.
🧹 Extraction quality & fixes
- pdftotext cleanup — dehyphenate line-wraps, strip repeated headers/footers and edge page numbers (conservative: edges only, ≥3 pages) (#77).
- SOURCE-banner fix — chapter detection now runs on source text before the generated
SOURCE:banners, so they no longer become phantom setext headings (#81, #83). - Encoding fixes —
pdftotextoutput decoded as UTF-8; UTF-16/UTF-32 text files decoded by BOM; RTF\uNescapes; HTML double-entity fix; DOCX table reconstruction; EPUB spine-order reading.
📦 Packaging
- The
pdfextra now installspypdfinstead of the end-of-lifePyPDF2.
Full changelog: https://github.com/virgiliojr94/book-to-skill/blob/master/CHANGELOG.md
- v1.2.0v1.2.0 — installable package + multilingual chapter detection2026-06-17 · 2026-06-17 22:15 UTC
查看更新说明
book-to-skill v1.2.0 turns the project into an installable Python package and makes chapter detection genuinely multilingual.
Highlights
📦 Installable package + CLI
book-to-skillis now a realbook_to_skillpackage:pip installit, run thebook-to-skillconsole script orpython -m book_to_skill, and pull only the extractors you need via extras (epub,pdf,docx,rtf,technical,all). The base install stays dependency-free with stdlib fallbacks, andpython3 scripts/extract.pystill works unchanged, so existing skill flows keep running.🌍 Multilingual chapter detection
- Markdown / AsciiDoc ATX headings (
#,==) detected when no numeric "Chapter N" is present. - setext / reStructuredText underline headings (
Titleover===/---), guarded against thematic breaks, table borders, and YAML front matter. - French, German, Italian, Dutch chapter words (
Chapitre,Kapitel,Capitolo,Hoofdstuk) and umlaut titles (Überblick). - Full-width Arabic digits in CJK headings (
第1章), common in Japanese typesetting. - Multilingual table-of-contents detection (CN, JP, FR, DE, IT, NL).
🔎 Diagnosable extraction
Unexpected parser errors are now logged to stderr (extractor name + exception type) instead of vanishing, while the fallback chain still continues. Corrupt files and encoding issues are finally visible.
🔒 Security & CI
CodeQL, Bandit (HIGH gate), Zizmor workflow audit, and grouped Dependabot. Test matrix now spans Python 3.9–3.13.
Thanks
Community contributions from @Marcelluxx, @dex0shubham, @RandMelville, @addy790, @yukaina, @wuji-labs, and everyone filing multilingual edge cases. 💖 Sponsor the project
Full changelog: https://github.com/virgiliojr94/book-to-skill/blob/master/CHANGELOG.md
- Markdown / AsciiDoc ATX headings (
- v1.1.02026-06-12 · 2026-06-12 14:46 UTC
查看更新说明
[1.1.0] — 2026-06-12
Added
- GitHub Copilot CLI as a first-class target — the same
SKILL.mdnow discovers, installs, and runs across GitHub Copilot CLI, Amp, and Claude Code via the open Agent Skills standard. Skill Locations cover 8 discovery paths and the script probe walks all of them (#30). validate_skill.py --lens claude|copilot|amp— audits a generated SKILL.md against each host's rules;claudestays the default for CI back-compat (#30).- Attribution banner —
scripts/banner.txtis printed at the start of each run (best-effort, never fails the run).
Changed
SKILL.mdfrontmatter trimmed toward the open-standard minimum and the description now names all three hosts so each agent's auto-loader picks it up (#30).- README headline + "Agent Skills" badge; install/usage sections cover all three
hosts.
docs/ARCHITECTURE.mdshows per-host destination paths (#30).
Notes
allowed-toolswas dropped from the frontmatter for host-neutrality; the skill is conformant on all three hosts (validated with all three lenses). If Claude users hit permission-prompt friction, the Bash grant from #18 will be restored with Claude-native tokens (Copilot ignores the key either way).
- GitHub Copilot CLI as a first-class target — the same
- v1.0.02026-06-08 · 2026-06-08 21:22 UTC
查看更新说明
[1.0.0] — 2026-06-08
First formally tagged release. The converter is stable, multi-format, and validated on real books.
Added
- Multi-format extraction — PDF, EPUB, DOCX, HTML, Markdown, reStructuredText,
AsciiDoc, RTF, and MOBI/AZW/AZW3 (via Calibre), through a modular
extractorpackage with per-format parsers and graceful stdlib fallbacks. extract.py --check— preflight that reports which extractors are installed for every format and the exact command to install whatever is missing (#21).- Adaptive per-chapter depth — token budget scales with
BOOK_TYPE × DEPTH; study-depth chapters require a worked example, and the cheatsheet is generated as a decision/reasoning layer (decision rules, trees, trade-offs, thresholds, tells) rather than a keyword list (#20). tools/discovery_tax.py— measures the "Discovery Loop Tax": tokens a context-dump vs a discovery loop vs book-to-skill put into context to answer one question, on a real book (#23).- Update / fold-in workflow — merge new sources into an existing skill, keeping chapter index, topic index, glossary, patterns, and cheatsheet in sync.
- GitHub Actions CI — lint (ruff), test matrix (py3.10–3.13), dependency-free smoke test, and SKILL.md Claude-conformance validation (#15, #18).
Changed
- README positioning — copyright & fair-use section, "Beyond books" use cases, context-dump / RAG / 1M-window FAQ, and a measured Discovery Loop Tax + real per-conversion cost table across four books (#19, #27).
- Default output target is
~/.claude/skills/for Claude Code, with Amp skill directories also supported (#13, #14).
Fixed
- Chapter detection — scans the full text (was capped at 50k chars) and counts
distinct explicit
Chapter N/Capítulo Nheadings, rejecting numbered list items, inline cross-references, and years; adds Portuguese support (#26). - Roman-numeral headings —
I: Loomings,II. The Carpet-Bagare now detected with canonical-numeral validation (#28). - EPUB extraction — resolve OPF-relative hrefs in the stdlib zipfile fallback (#11, #12).
- Batch resilience — one bad source is skipped with a warning instead of aborting the whole run; explicit input order is preserved (#7).
Known limitations
- Chapter auto-detection needs explicit
Chapter N/Capítulo Nor Roman-numeral headings. Books that head chapter bodies with bare titles (e.g. Moby-Dick, where numerals appear only in the table of contents) or use section titles (e.g. Pro Git) do not auto-segment. - Technical PDFs extracted in text mode may lose heading structure; use technical mode (Docling) to preserve tables, code, and headings.
- Multi-format extraction — PDF, EPUB, DOCX, HTML, Markdown, reStructuredText,
AsciiDoc, RTF, and MOBI/AZW/AZW3 (via Calibre), through a modular
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
How it works, in 3 steps:
- Point it at a file, folder, or glob —
/book-to-skill ./my-book.pdf - It distills the book into a skill — frameworks, decision rules, anti-patterns, and per-chapter files. Structure, not a summary.
- Your agent loads it on demand — ask
/my-book replicationand it reads the right chapter and answers from the real content, no hallucination.
🤔 Why
You buy a great technical book. You read it once. Three months later you can't remember chapter 7 existed.
The usual workarounds don't help:
- 📄 "Let me just search the PDF" → you get a list of pages, not answers
- 🧠 "I'll ask the agent about this book" → it either hallucinates or says it doesn't have the content
- 📝 "I'll take notes as I read" → you end up with a 200-line doc you never open again
book-to-skill solves this by turning the book into a structured skill your agent loads on demand.
Once installed, you just type /your-book-slug replication and the agent reads the right chapter and answers from the actual content. No hallucination. No digging through PDFs. The book becomes part of your workflow.
Works with any host that supports the open Agent Skills standard — GitHub Copilot CLI, Amp, Claude Code, Codex, Hermes Agent, OpenCode, and OpenClaw all read the same SKILL.md format.
📦 What it generates
Running /book-to-skill your-book.pdf (or a folder, glob, or list of files) creates a full skill in the user-level cross-agent skills directory ~/.agents/skills/<slug>/ — one copy that Copilot CLI, Amp, Codex, OpenCode, and OpenClaw discover natively (OpenCode also reads its own managed root ~/.config/opencode/skills/<slug>/; OpenClaw also discovers it when using its default state directory, with a non-default OPENCLAW_STATE_DIR use the active state's skills/ root instead). When run under Claude Code, the converter also attempts a verified symlink at ~/.claude/skills/<slug>/ — Claude Code sees the skill when the link read-back confirms it; otherwise the run report says so. Hermes Agent partitions its personal skills by category and does not scan the cross-agent root, so a Hermes install lands in /skills/<category>/<slug>/ instead. OpenClaw-managed, OpenCode-managed, and project-local destinations remain available when explicitly requested:
| File | Purpose | Size |
|---|---|---|
SKILL.md | Core mental models + chapter index | ~4,000 tokens |
chapters/ch01-*.md … | One file per chapter, loaded on-demand | ~1,000 tokens each |
glossary.md | Every key term, alphabetically sorted with chapter refs | ~1,500 tokens |
patterns.md | All techniques, algorithms, and design patterns | ~2,000 tokens |
cheatsheet.md | Decision tables and quick-reference rules | ~1,000 tokens |
Chapter files are loaded on-demand — they don't count against the skill budget until you ask about that topic.
🏢 Beyond books
The name says "book", but the input is any structured prose. The same extraction works on knowledge you own and re-read constantly:
- Internal documentation — architecture decision records, runbooks, onboarding guides. Fold a whole
docs/folder into one skill and ask it while you code. - Brand & design systems — voice guidelines, tone-of-voice docs, component principles. Turn a brand book into a skill your team queries instead of skimming a 60-page PDF.
- Research clusters — a stack of papers plus your own notes, merged into a single unified skill and updated as new material lands (see Update / fold-in).
- Specs & standards — RFCs, API contracts, compliance docs you reference but never memorize.
If you re-open a document often enough to wish you'd memorized it, it's a candidate.
🧾 The Discovery Loop Tax
A PDF-reading agent doesn't just read — it navigates: it re-fetches the ToC, backtracks, and re-processes all of it on every turn. book-to-skill pays that structuring cost once, at conversion, so queries stay proportional to the answer — 24×–51× fewer tokens than dumping the book into context, measured on real books.
📊 Full methodology, numbers, and per-book tables → docs/performance.md
⚙️ How it works
Two halves: a deterministic Python extractor (document → clean text + metadata) and a spec-driven generator (your agent follows SKILL.md to turn that into a structured skill). On-demand chapter files keep the loaded skill small.
🔧 Full walkthrough (Steps 0–10, extraction modes, token budgets) → docs/how-it-works.md
🚀 Usage
/book-to-skill <path|folder|glob> [skill-name] — plus analyze-only, generate-from-analysis, and update/fold-in modes. After a conversion, the converter can publish the skill to GitHub (private by default) so any host installs it with npx skills add.
▶️ All modes and examples → docs/usage.md
💬 In practice → use cases — a DevEx book became a survey of 300+ engineers; a scanned PDF that stalled became #130. Add yours: the account lives in your own Gist, the index takes a one-line PR.
📥 Install
# One command, any host — via the cross-agent skills CLI:
npx skills add virgiliojr94/book-to-skill
# Or manually — clone into your skills folder (registers /book-to-skill):
git clone https://github.com/virgiliojr94/book-to-skill.git ~/.claude/skills/book-to-skill
# (Copilot CLI: ~/.copilot/skills/ · Amp/cross-agent: ~/.agents/skills/)
# (Hermes Agent: ${HERMES_HOME:-$HOME/.hermes}/skills/<category>/)
# (OpenClaw: ${OPENCLAW_STATE_DIR:-$HOME/.openclaw}/skills/; ~/.agents/skills/ only with default state)
# (OpenCode: ~/.agents/skills/ — it also reads ~/.config/opencode/skills/)
📥 All hosts, optional extractors, and the standalone CLI → docs/install.md
❓ FAQ
Common questions — "why not just dump the PDF?", cost, privacy, non-book inputs, multi-file books.
❓ Answers → docs/faq.md
The extractor tries tools in order per format and uses the first available. If nothing is installed, it tells you which command to run. Plain text, Markdown, reStructuredText and AsciiDoc need no extra deps.
Check your setup in one command:
python3 scripts/extract.py --checkprints which extractors are installed for every format and the exact command to install anything missing — no file needed.
PDF — choose by book type:
| Book type | Tool | Install | Speed |
|---|---|---|---|
| Text-heavy (prose, few tables) | pdftotext (poppler) | sudo apt install poppler-utils | ⚡ instant |
| Text-heavy fallback | pypdf | pip3 install pypdf | ⚡ instant |
| Text-heavy fallback | pdfminer.six | pip3 install pdfminer.six | ⚡ instant |
| Technical (code, tables, formulas) | docling | pip3 install docling | ~1.5s/page |
Before extraction begins, the skill asks you whether the book is technical or text-heavy and picks the right tool automatically. Docling preserves markdown tables and code blocks; pdftotext is faster for prose-only books.
Scanned PDFs need OCR first. A PDF that is page images with no text layer — a photographed or scanned book — has nothing for these tools to extract. The extractor checks the first pages and stops immediately with an explanation, rather than working through the whole book to produce an empty skill. Run OCR yourself, then convert the result:
ocrmypdf input.pdf output.pdf
EPUB:
| Tool | Install | Quality |
|---|---|---|
ebooklib + beautifulsoup4 | pip3 install ebooklib beautifulsoup4 | ⭐⭐⭐ Best |
stdlib zipfile | built-in — no install needed | ⭐⭐ Always available |
Other formats:
| Format | Tool | Install |
|---|---|---|
| DOCX | python-docx (fallback: stdlib ZIP/XML) | pip3 install python-docx |
| HTML | beautifulsoup4 (fallback: stdlib html.parser) | pip3 install beautifulsoup4 |
| RTF | striprtf (fallback: regex) | pip3 install striprtf |
| MOBI / AZW / AZW3 | Calibre ebook-convert (external app, not pip) | https://calibre-ebook.com/download |
| TXT / Markdown / reStructuredText / AsciiDoc | built-in | — |
book-to-skill/
├── SKILL.md # Skill definition + step-by-step instructions (the generator spec)
├── scripts/
│ ├── extract.py # Thin entrypoint wrapper
│ └── extractor/ # Modular extraction package
│ ├── config.py # Extensions, paths, dependency constants
│ ├── dependencies.py # optional-dep probing + --check
│ ├── exceptions.py # ExtractionError (per-source failures, batch-safe)
│ ├── utils.py # CLI parsing, multi-source resolution, chapter detection, runner
│ └── parsers/ # Format-specific parsers (pdf, epub, docx, html, rtf, calibre, text)
├── tools/
│ ├── discovery_tax.py # measures token cost vs context-dump / discovery loop
│ └── validate_skill.py # checks a generated SKILL.md against host rules (--lens claude|copilot|amp|hermes|openclaw|opencode)
├── tests/ # pytest suite (extraction, detection, discovery tax)
├── docs/
│ ├── performance.md # measured benchmarks, discovery tax, cost
│ └── architecture.md # pipeline + component map
├── CHANGELOG.md # release history (semver)
├── CONTRIBUTING.md # dev setup, PR conventions, release process
├── SECURITY.md # vulnerability reporting
└── README.md # This file
⚖️ Copyright & fair use
book-to-skill ships no book content — not a single page. It's a converter you point at files you already own.
- Processing is local. Extraction and analysis run on your machine. Your files are never uploaded by this tool. (If your agent's model runs in the cloud, the text you feed it follows that provider's normal data terms — same as any prompt.)
- You use your own copy. Bring a book you bought, docs your company owns, or papers you have the right to read.
- The output is your notes. A generated skill is a structured, synthesized derivative — framework names, definitions, takeaways — not a reproduction of the text. The skill explicitly never copies raw passages (see Quality Rule #7). Treat it like handwritten study notes: yours, for personal use.
- Don't redistribute. Publishing or sharing a generated skill of a copyrighted work can infringe the rights holder. Keep skills of third-party books private. Internal docs, your own writing, and openly-licensed material are fine to share within the bounds of their license.
When in doubt, follow the license or terms of the source document. This project is a tool; how you use it is on you.
💖 Sponsors
book-to-skill is free and MIT-licensed, maintained on personal time. If it saves you tokens or study hours, consider sponsoring its upkeep: PR reviews, multilingual fixes, releases, and docs.
Become a sponsor → github.com/sponsors/virgiliojr94
Every sponsor is listed in BACKERS.md. Thank you for keeping open, privacy-first tooling alive. ✨
License
MIT — applies to the converter (code + skill definition) in this repository, not to any book or document you process with it.