Turn any technical book PDF into a Claude Code skill — ready to study, reference, and use while you work.
Python agent-skillsai-agentsbook-to-skillcontext-engineeringdocument-processingedtechknowledge-baseknowledge-managementllmpdf-to-markdownragself-studystudy-tools
docs: add release infrastructure for v1.0.0 (#29)
Virgilio Junior40d249f9c06b
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.mdnew file mode 100644index 0000000..5368d9c--- /dev/null+++ b/.github/ISSUE_TEMPLATE/bug_report.md@@ -0,0 +1,24 @@+---+name: Bug report+about: Something went wrong during extraction or skill generation+title: "[bug] "+labels: bug+---++## What happened++## What you expected++## Source document+- Format: <!-- PDF / EPUB / DOCX / … -->+- Pages / size:+- Language:+- Does `python3 scripts/extract.py --check` show the relevant extractor installed? <!-- yes/no -->++## Repro+<!-- The exact command and (if shareable) a small sample file or input -->++## Environment+- OS:+- Python version:+- book-to-skill version / commit:diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.mdnew file mode 100644index 0000000..b626457--- /dev/null+++ b/.github/ISSUE_TEMPLATE/feature_request.md@@ -0,0 +1,17 @@+---+name: Feature request+about: Suggest an improvement to extraction, generation, or the skill format+title: "[feat] "+labels: enhancement+---++## Problem+<!-- What are you trying to do that's hard or impossible today? -->++## Proposed change++## How would we know it's better?+<!-- A measurable acceptance criterion: a token delta, a test, a before/after.+ Changes that add weight without a demonstrated gain are unlikely to land. -->++## Alternatives considereddiff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.mdnew file mode 100644index 0000000..9420c86--- /dev/null+++ b/.github/PULL_REQUEST_TEMPLATE.md@@ -0,0 +1,17 @@+<!-- Conventional Commit title, e.g. fix(extractor): scan full text -->++## What & why+<!-- What does this change and what problem does it solve? -->++## Evidence+<!-- Required for any claimed gain. A test, a discovery_tax.py number, or a+ before/after. "No behavior change" is a valid answer for pure docs/refactor. -->++## Checklist+- [ ] One focused change+- [ ] Tests added/updated for behavior changes+- [ ] `ruff check .` clean+- [ ] `pytest -q` green+- [ ] `python3 tools/validate_skill.py SKILL.md` passes (if SKILL.md changed)+- [ ] `CHANGELOG.md` updated under `## [Unreleased]`+- [ ] No raw book text shipped; no net SKILL.md bloat without justificationdiff --git a/CHANGELOG.md b/CHANGELOG.mdnew file mode 100644index 0000000..8b0b2c8--- /dev/null+++ b/CHANGELOG.md@@ -0,0 +1,56 @@+# Changelog++All notable changes to **book-to-skill** are documented here.++The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).++## [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 `extractor`+ package 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 N` headings, rejecting numbered list+ items, inline cross-references, and years; adds Portuguese support (#26).+- **Roman-numeral headings** — `I: Loomings`, `II. The Carpet-Bag` are 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 N` or 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.++[1.0.0]: https://github.com/virgiliojr94/book-to-skill/releases/tag/v1.0.0diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdnew file mode 100644index 0000000..df0f203--- /dev/null+++ b/CONTRIBUTING.md@@ -0,0 +1,55 @@+# Contributing to book-to-skill++Thanks for helping improve book-to-skill. This project turns books and documents+into structured agent skills; contributions that make extraction more robust,+generation higher-signal, or the docs clearer are all welcome.++## Ground rules++- **Measure, don't assert.** A change that claims a gain should show it — a test,+ a benchmark number from `tools/discovery_tax.py`, or a before/after. PRs that add+ weight (e.g. to `SKILL.md`, which is loaded on every run) without a demonstrated+ benefit will be asked for evidence first.+- **Keep `SKILL.md` lean.** It is the always-loaded converter spec. Prefer editing+ existing steps over adding new ones; justify net additions.+- **Never ship raw book text.** Generated skills synthesize; they never reproduce+ long passages. Respect source licenses (see the README's Copyright section).++## Development++```bash+git clone https://github.com/virgiliojr94/book-to-skill.git+cd book-to-skill+python3 -m venv .venv && . .venv/bin/activate+pip install pytest ruff+python3 scripts/extract.py --check # see which optional extractors you have+```++Run the checks the CI runs before opening a PR:++```bash+ruff check .+pytest -q+python3 tools/validate_skill.py SKILL.md+```++## Pull requests++- One focused change per PR; small and reviewable.+- **Conventional Commits** for titles and commits: `feat:`, `fix:`, `docs:`,+ `chore:`, `test:`, `ci:` … (e.g. `fix(extractor): scan full text`).+- Add or update tests for any behavior change.+- Update `CHANGELOG.md` under an `## [Unreleased]` section.+- CI must be green (lint, test matrix py3.10–3.13, smoke, SKILL.md validation).++## Releases++Maintainers cut releases with semantic versioning: tag `vX.Y.Z`, move the+`Unreleased` changelog section under the new version with the date, and publish a+GitHub Release using those notes.++## Reporting bugs / requesting features++Open an issue using the templates in `.github/ISSUE_TEMPLATE/`. For extraction+bugs, please include the format, page count, and whether `--check` shows the+relevant extractor installed.diff --git a/README.md b/README.mdindex 2ccc850..3c88e23 100644--- a/README.md+++ b/README.md@@ -5,9 +5,9 @@</p><p align="center">+ <a href="https://github.com/virgiliojr94/book-to-skill/releases"><img src="https://img.shields.io/github/v/release/virgiliojr94/book-to-skill?style=for-the-badge&color=blueviolet" alt="Latest release"></a><img src="https://img.shields.io/badge/Claude_Code-Skill-blueviolet?style=for-the-badge" alt="Claude Code Skill"><img src="https://img.shields.io/badge/PDF%20%E2%80%A2%20EPUB%20%E2%80%A2%20DOCX%20%E2%80%A2%20MD%20%E2%80%A2%20HTML%20%E2%80%A2%20RTF%20%E2%80%A2%20MOBI-supported-green?style=for-the-badge" alt="Formats supported">- <img src="https://img.shields.io/badge/effort-high-orange?style=for-the-badge" alt="Effort: high"><img src="https://img.shields.io/badge/License-MIT-blue?style=for-the-badge" alt="MIT License"></p>@@ -22,7 +22,10 @@<a href="#-how-it-works">How it works</a> ·<a href="#-the-discovery-loop-tax">Discovery Loop Tax</a> ·<a href="#-faq">FAQ</a> ·- <a href="#-install">Install</a>+ <a href="#-install">Install</a> ·+ <a href="CHANGELOG.md">Changelog</a> ·+ <a href="docs/PERFORMANCE.md">Performance</a> ·+ <a href="docs/ARCHITECTURE.md">Architecture</a></p>---@@ -344,18 +347,25 @@ Then in any Claude Code session:```book-to-skill/-├── SKILL.md # Skill definition + step-by-step instructions+├── SKILL.md # Skill definition + step-by-step instructions (the generator spec)├── scripts/│ ├── extract.py # Thin entrypoint wrapper│ └── extractor/ # Modular extraction package-│ ├── __init__.py│ ├── config.py # Extensions, paths, dependency constants-│ ├── dependencies.py+│ ├── dependencies.py # optional-dep probing + --check│ ├── exceptions.py # ExtractionError (per-source failures, batch-safe)-│ ├── utils.py # CLI parsing, multi-source resolution, runner+│ ├── utils.py # CLI parsing, multi-source resolution, chapter detection, runner│ └── parsers/ # Format-specific parsers (pdf, epub, docx, html, rtf, calibre, text)-├── tests/-│ └── test_extractor.py # Test suite (multi-source, batch resilience, EPUB, parsers)+├── tools/+│ ├── discovery_tax.py # measures token cost vs context-dump / discovery loop+│ └── validate_skill.py # checks a generated SKILL.md against Claude Code rules+├── 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```diff --git a/SECURITY.md b/SECURITY.mdnew file mode 100644index 0000000..3489896--- /dev/null+++ b/SECURITY.md@@ -0,0 +1,33 @@+# Security Policy++## Scope++book-to-skill is a local conversion tool. It reads document files you point it at+and writes skill files to your skills directory. It does **not** upload your files,+phone home, or run a network service. The main security surface is:++- the Python extraction code (parsing untrusted document files), and+- the optional dependencies it can install on request (`pip install …` when you+ choose `--install-missing yes`).++## Supported versions++The latest released `1.x` version receives fixes. Please reproduce issues against+the most recent tag before reporting.++## Reporting a vulnerability++Please **do not** open a public issue for a security problem. Instead use GitHub's+private vulnerability reporting:++- Go to the repository's **Security** tab → **Report a vulnerability**.++Include: affected version, a minimal reproduction (ideally a small sample file or+crafted input), and the impact you observed. We aim to acknowledge within a few days.++## Good practices for users++- Run `python3 scripts/extract.py --check` to see exactly which extractors are in+ use; install dependencies yourself if you prefer to control what is added.+- Only convert documents you trust and have the right to process (see the README's+ Copyright & fair-use section).diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdnew file mode 100644index 0000000..eb526ed--- /dev/null+++ b/docs/ARCHITECTURE.md@@ -0,0 +1,72 @@+# Architecture++book-to-skill has two halves: a **deterministic extractor** (Python) and a+**spec-driven generator** (the agent following `SKILL.md`). The extractor turns any+document into clean text + metadata; the agent turns that into a structured skill.++```+ ┌─────────────────────────── EXTRACTOR (Python, deterministic) ──┐+ documents │ scripts/extract.py → extractor/ │+ (pdf/epub/ │ ├─ utils.py CLI parse · multi-source resolve · runner │+ docx/...) │ ├─ config.py supported extensions · paths · deps map │+ │ │ ├─ dependencies.py optional-dep probing · --check report │+ ▼ │ └─ parsers/ pdf · epub · docx · html · rtf · calibre · │+ ───────────│ text (best tool first, stdlib fallback) │+ │ output → <tempdir>/book_skill_work/ │+ │ full_text.txt (all sources merged, source-marked) │+ │ metadata.json (pages, words, tokens, chapters, ToC) │+ └────────────────────────────────────────────────────────────────┘+ │+ ▼+ ┌─────────────────────────── GENERATOR (agent, follows SKILL.md) ┐+ │ Step 1.5 ask content type → BOOK_TYPE (technical | text) │+ │ Step 2/2.5 extract · cost estimate · confirm │+ │ Step 2.6 REPL-style probing for large books (grep/sed, no │+ │ full re-reads) │+ │ Step 3 analyze structure (title, author, chapters, ToC) │+ │ Step 4 purpose → DEPTH (reference | study) │+ │ Step 7 per-chapter summaries (budget = BOOK_TYPE × DEPTH) │+ │ Step 8 glossary · patterns · cheatsheet (decision layer) │+ │ Step 9/9.5 SKILL.md core + indexes │+ └────────────────────────────────────────────────────────────────┘+ │+ ▼+ ~/.claude/skills/<slug>/+ SKILL.md core frameworks + chapter & topic index (~4K)+ chapters/*.md on-demand, loaded only when asked+ glossary.md terms+ patterns.md techniques+ cheatsheet.md decision rules / trees / trade-offs / tells+```++## Design principles++1. **Extract structure, not summaries** — named frameworks, decision rules,+ anti-patterns; never raw passages.+2. **Compile-time over runtime** — pay navigation/structuring once; at query time+ load only the relevant chapter. See [PERFORMANCE.md](PERFORMANCE.md).+3. **On-demand chapters** — `SKILL.md` stays small; chapter files cost tokens only+ when read.+4. **Front-loaded `SKILL.md`** — most important content first (compaction truncates+ from the end).+5. **Graceful degradation** — every format has a stdlib fallback; one bad source is+ skipped, not fatal.++## Key components++| Path | Responsibility |+|------|----------------|+| `scripts/extract.py` | thin entrypoint wrapper |+| `scripts/extractor/utils.py` | CLI parsing, multi-source resolution, chapter/ToC detection, runner |+| `scripts/extractor/parsers/` | one module per format |+| `scripts/extractor/dependencies.py` | optional-dependency probing + `--check` |+| `tools/discovery_tax.py` | measures token cost vs context-dump / discovery loop |+| `tools/validate_skill.py` | checks a generated SKILL.md against Claude Code rules |+| `SKILL.md` | the generator spec (Steps 0–10 + fold-in workflow) |++## Extending++- **New format** → add `parsers/<fmt>.py`, register its extension in `config.py`,+ wire dependency probing in `dependencies.py`, branch in `utils.extract_single_file`.+- **New generation behavior** → edit the relevant Step in `SKILL.md`; keep it lean+ and back the change with evidence (see CONTRIBUTING.md).diff --git a/docs/PERFORMANCE.md b/docs/PERFORMANCE.mdnew file mode 100644index 0000000..16b190f--- /dev/null+++ b/docs/PERFORMANCE.md@@ -0,0 +1,79 @@+# Performance & Cost++All numbers below are **measured**, not estimated, using `tiktoken` (cl100k_base)+for token counts and `tools/discovery_tax.py` for the discovery model. Reproduce+any of them with the commands shown.++## Extraction (real conversions)++Measured with `pdftotext` (PDF) and `ebooklib` (EPUB):++| Book | Format | Pages | Tokens | Chapters auto-detected |+|------|--------|------:|-------:|-----------------------:|+| Think Python 2 | PDF | 244 | 119K | 19 |+| Working Backwards | PDF | 371 | 175K | 10 |+| Pro Git | PDF | 501 | 229K | — † |+| Moby-Dick | EPUB | — | 301K | 133 |++† Pro Git heads chapters with section titles (no `Chapter N`), so it does not+auto-segment. Moby-Dick's bodies use bare titles, but its Roman-numeral table of+contents is detected (133) — see *Known limitations* in the README.++**Extraction method matters for technical books.** On a 103-page technical PDF:++| Method | Time | Tables | Code blocks |+|--------|-----:|-------:|------------:|+| pdftotext | 0.1s | 0 | 0 |+| Docling (technical mode) | 164s | 48 | 36 |++pdftotext is instant but flattens structure; Docling is ~1.5s/page but preserves+tables and code as markdown. Pick text mode for prose, technical mode for code/tables.++## The Discovery Loop Tax++Tokens entering context to answer **one** targeted question. book-to-skill loads a+resident core (~4K) plus one compiled chapter (~1K) ≈ **5,000 tokens**.++| Book (chapter size) | Context-dump | Discovery loop | book-to-skill | vs dump / loop |+|---------------------|-------------:|---------------:|--------------:|:--------------:|+| Think Python 2 (small) | 119,264 | 12,152 | ~5,000 | 24× / 2.4× |+| Working Backwards (medium) | 175,253 | 33,444 | ~5,000 | 35× / 6.7× |+| AI Engineering (large) | 256,287 | 77,866 | ~5,000 | 51× / 15.6× |++```bash+python3 tools/discovery_tax.py --full-text /tmp/book_skill_work/full_text.txt --target-chapter 5+```++- The **context-dump** advantage (24–51×) is the strongest claim: that cost recurs on+ *every conversation turn*.+- The **discovery-loop** advantage (2.4–15.6×) is a one-time cost and a model using+ the book's real ToC/chapter sizes; it scales with chapter size.++## Generation cost++One-pass full conversion, estimated from measured tokens (Claude Sonnet 4.5,+\$3 / \$15 per MTok input/output):++| Book | Input | Output | ~Cost |+|------|------:|-------:|------:|+| Think Python 2 | 155K | 28K | \$0.88 |+| Working Backwards | 228K | 19K | \$0.96 |+| Pro Git | 298K | 23K | \$1.23 |+| Moby-Dick | 391K | 17K | \$1.42 |++Roughly **\$1 per book** for a full skill — paid once. Re-reading the same PDF into+context every session costs far more over time (see the Discovery Loop Tax above).++## Generated-skill output quality++A before/after of the adaptive-depth change (`v1.0.0`, #20) on one chapter:++| Artifact | Old spec | New spec |+|----------|---------:|---------:|+| Chapter file (tokens) | 473 | 1,219 |+| Worked example present | no | yes |+| Cheatsheet decision rules | 0 | 32 |+| Cheatsheet keyword/definition lines | 9 | 0 |++The new spec turns the cheatsheet from a glossary into a decision layer and gives+study-depth chapters a reproduced worked example.