book-to-skill README

The project's README from github.com/virgiliojr94/book-to-skill. As one markdown file: README.md.

Booklin, the book-to-skill wizard, holding an open book whose pages scatter into sparkles that settle into an ordered grid

book-to-skill

English · Русский · 简体中文

Turn any technical book, document folder, or collection of sources into a unified agent skill — ready to study, reference, and use while you work in GitHub Copilot CLI, Amp, Claude Code, Codex, Hermes Agent, OpenCode, or OpenClaw.

Latest release Agent Skills standard Formats supported MIT License Sponsor

virgiliojr94%2Fbook-to-skill | Trendshift virgiliojr94%2Fbook-to-skill | Trendshift (daily, Python) Star History Rank

Why · What it generates · Beyond books · How it works · Usage · Install · FAQ · Performance · Architecture · Changelog

24×–51× fewer tokens than dumping the book into context to answer one question, measured on real books (how it's measured).

How it works, in 3 steps:

  1. Point it at a file, folder, or glob — /book-to-skill ./my-book.pdf
  2. It distills the book into a skill — frameworks, decision rules, anti-patterns, and per-chapter files. Structure, not a summary.
  3. Your agent loads it on demand — ask /my-book replication and it reads the right chapter and answers from the real content, no hallucination.

🤔 Why

Booklin — the book-to-skill mascot, a purple wizard holding a book

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:

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:

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


🔧 Requirements

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 --check prints 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 —

📁 Repository structure
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|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


book-to-skill ships no book content — not a single page. It's a converter you point at files you already own.

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

Booklin celebrating

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.

book-to-skill (virgiliojr94/book-to-skill)

Searching Database…

这是什么?book-to-skill 可以把技术书籍 PDF(或一个文件夹、glob 通配路径中的多份文档)转换成结构化的“技能”(skill)。Claude Code、GitHub Copilot CLI、Amp 或 Hermes Agent 等编程智能体可以按需加载这种技能,基于书中的真实内容回答问题,而不是凭空编造答案。
它是转换工具还是成品应用?它由两部分组成:一个确定性的 Python 提取器,用来从源文件中提取干净的文本;还有一个由规范驱动的生成器,智能体运行它后会把文本转换成基于 SKILL.md 的技能。没有单独的图形界面,也没有服务器。
怎样把一本书变成技能?在支持的智能体中,对某个文件、文件夹或 glob 通配路径使用 /book-to-skill 斜杠命令,例如 /book-to-skill ./my-book.pdf。输出结果(SKILL.md 加上每章的单独文件)会保存到该智能体的 skills 目录中,之后即可用 /your-book-slug 进行查询。
提取 PDF 需要先安装什么?需要 Python 3。处理 PDF 时,根据书籍是以文字为主还是以技术内容为主,会使用 pdftotext(poppler)、pypdf、pdfminer.six 或 docling 中的一种;处理 EPUB、DOCX、HTML 和 RTF 等格式时,也有对应的工具。运行 python3 scripts/extract.py --check,可以查看缺少哪些依赖,并给出具体的安装命令。
扫描版 PDF 也能处理吗?不能。扫描版 PDF 只有页面图像,没有文字层,因此没有可提取的内容。工具会直接停止并说明原因,而不会生成一个空的技能。你需要先自行进行 OCR(光学字符识别)。
我的书籍内容会被上传到别处吗?不会。提取和分析都在你的本地机器上运行,工具从不上传你的文件。如果你所用智能体的底层模型是云端模型,那么你提供给它的文本只会按照该服务商的常规条款处理,与任何提示词一样。
我可以分享用自己买的书生成的技能吗?MIT 许可证只适用于转换工具的代码,不包括你处理的任何书籍。分享由受版权保护的第三方书籍生成的技能,可能会侵犯权利人的权益,因此请将这类技能保留为私人使用。
除了书籍,还能把哪些内容转换成技能?除了书籍,它还可以处理内部文档,如运维手册(runbook)和架构决策记录(ADR)、品牌或设计规范 PDF、一组研究论文,以及规格说明或 RFC。总的来说,任何你经常翻阅、希望早就记住的资料都可以。
和直接把 PDF 放进上下文相比,技能能节省多少 token?在真实书籍上的测试显示,回答一个问题时,查询生成的技能所用的 token 比把整本书放进上下文少 24 到 51 倍,因为各章文件只会在需要时才加载。
添加新章节或新资料后,能更新技能吗?可以。它提供更新模式和合并模式,可以把新内容并入已有的技能,而无需从头重新生成。
哪些智能体可以运行生成的技能?任何实现了开放 Agent Skills 标准的宿主都可以,目前包括 GitHub Copilot CLI、Amp、Claude Code 和 Hermes Agent,因为它们都读取同一种 SKILL.md 格式。
Size
2.7 MB
Stars
35.1K
Age
5mo
Commits · 90 Days