B

book-to-skill

by @virgiliojr94v
4.5(120)

技術書(ぎじゅつしょ)(PDFまたはEPUB)を構造化(こうぞうか)されたClaude Codeスキルに変換(へんかん)し、著者(ちょしゃ)が結晶化(けっしょうか)したフレームワーク、メンタルモデル、原則(げんそく)、テクニック、アンチパターンを抽出(ちゅうしゅつ)します。Claudeを通じて書籍(しょせき)を学習(がくしゅう)したり、作業中(さぎょうちゅう)に著者(ちょしゃ)のフレームワークを適用(てきよう)したり、PDFやEPUBから再利用可能(さいりようかのう)な知識(ちしき)ベースを構築(こうちく)したい場合(ばあい)に利用(りよう)します。

bookknowledge-extractionai-skillautomationframeworksGitHub
インストール方法
npx skills add https://github.com/virgiliojr94/book-to-skill --skill book-to-skill
compare_arrows

Before / After 効果比較

1 组
使用前

技術書からフレームワーク、原則、テクニックを手動で探し出し、実用的な形に構造化する作業。このプロセスは時間がかかり、一貫性に欠け、必要な時に特定の概念を素早く思い出したり適用したりするのが難しい。

使用後

書籍を構造化されたClaudeスキルに自動変換することで、フレームワークやアンチパターンなどの結晶化された知識に即座にアクセス。これにより、迅速な学習、著者洞察の一貫した適用、再利用可能な知識ベースの構築が可能になる。

SKILL.md

Book-to-Skill Converter

Transform written knowledge into actionable agent skills by extracting structure — not producing summaries.

Philosophy

Books contain crystallized expertise: frameworks, principles, and techniques that took years to develop. This skill extracts that knowledge into a format GitHub Copilot CLI, Amp, Claude Code, Hermes Agent, OpenCode, OpenClaw, or another compatible agent can leverage repeatedly. Extract structure, not summaries. A skill isn't a book report. It's a toolkit of:

  • Named frameworks (mental models with clear application)
  • Actionable principles (rules that guide decisions)
  • Techniques (step-by-step methods)
  • Anti-patterns (what to avoid and why)
  • Voice calibration (how the author thinks and communicates)

Preserve the author's precision. Frameworks often have specific names for reasons. "The 5 Whys" isn't interchangeable with "ask why multiple times." Capture the exact formulation.

Layer depth appropriately. Simple books → simple skills. Complex books with 10+ frameworks → skills with reference files and on-demand chapters.


Modes of Operation

Four paths available. Route based on what the user asks:

1. Full Conversion (Default)

Trigger: User provides one or more document/directory/glob paths without special instructions Action: Run all steps below (Steps 0–9) Output: Complete skill with SKILL.md, chapters/, glossary, patterns, cheatsheet

2. Analyze Only

Trigger: User says "analyze", "just extract", or "I want to review before generating" Action: Run Steps 0–3, then produce a structured extraction report (frameworks, principles, techniques found). Stop — do NOT generate skill files. Output: Analysis report for user review

3. Generate from Prior Analysis

Trigger: User has existing analysis notes or previously ran analyze-only Action: Skip Steps 0–3, use the provided analysis as input, run Steps 4–9 Output: Skill files from the provided analysis

4. Update / Fold-in (Existing Skill)

Trigger: User provides one or more new source paths and indicates they want to update an existing skill (either by pointing to the existing skill folder, providing a skill slug that already exists in SKILLS_HOME, or explicitly requesting an update). Action: Run Step 0 (out-of-scope check), Step 1 (validate inputs), Step 1.5 (identify book type), and Step 2 (extract new files). Then skip to Step 5 (identify/detect existing skill path) and run the Update / Fold-in Workflow to merge the new content into the existing skill files. Output: Updated existing skill with new/revised chapter summaries and merged indexes/glossaries.


Skill Locations

This converter can run from multiple skill systems. When looking for this converter's helper script or writing the generated book skill, prefer these locations in order:

  1. GitHub Copilot CLI personal skills: ~/.copilot/skills/
  2. Cross-agent personal skills (Copilot, Amp, Codex; OpenClaw with its default state): ~/.agents/skills/
  3. Claude Code personal skills: ~/.claude/skills/
  4. Project-local Copilot skills: .github/skills/
  5. Project-local Claude skills: .claude/skills/
  6. Project-local Amp / Copilot / OpenClaw skills: .agents/skills/
  7. Amp global skills: ~/.config/agents/skills/
  8. Amp legacy global skills: ~/.config/amp/skills/
  9. Hermes Agent personal skills: $HERMES_HOME/skills/ (defaults to ~/.hermes/skills/)
  10. Hermes Agent project skills: .hermes/skills/ or .agents/skills/
  11. OpenClaw personal skills: ${OPENCLAW_STATE_DIR:-~/.openclaw}/skills/ (active state; ~/.agents/skills/ is shared only with the default state)
  12. OpenClaw project skills: .agents/skills/ or skills/
  13. OpenCode personal skills: ~/.config/opencode/skills/ or ~/.agents/skills/
  14. OpenCode project skills: .opencode/skills/ or .agents/skills/

For generated book skills, prefer the user-level cross-agent root ~/.agents/skills/ — one physical copy serves the cross-agent hosts and OpenClaw when it uses its default state. Copilot CLI and Amp discover it natively; Claude Code needs a symlink from ~/.claude/skills/<skill_name> (created in Step 10, see Step 5 for the rules). Pick a host-private or project-local root only when the user explicitly asks for one. BOOK_TO_SKILL_SCOPE=project or personal can make that choice explicit for automation; do not ask a mandatory scope question merely because both scopes are available.


Step 0 — Out-of-scope check

If no arguments are provided, stop and respond:

"book-to-skill requires a supported document path, folder, or glob pattern. Usage: book-to-skill <path-to-document-folder-or-glob>... [skill-name-slug]"

Throughout the workflow:

  • Resolve the destination root first. Before any existing-skill lookup, determine where this run would write: the personal or project-local root for the user's host, per the Step 5 table and selection rules — a project-local request uses its project-local root, never the personal root. Below, "the resolved root" means that destination.
  • Identify the input paths and the optional skill slug.
  • If the last argument is not a file, folder, or glob that exists or matches any files, and it looks like a skill slug (e.g. lowercase hyphens, alphanumeric), treat it as SKILL_NAME.
  • Treat all other arguments as the list of INPUT_PATHS.
  • If any input path is an existing skill directory (contains SKILL.md and a chapters/ sub-folder), or if SKILL_NAME matches an existing skill slug in the resolved root, flag this run as an Update/Fold-in operation (Mode 4).
  • Re-run guard. Before starting extraction for a Full Conversion, derive the prospective skill slug under Step 5's naming options — the author-concept form, the by-title form, and any SKILL_NAME given — and check the resolved root for an existing match. On a match, STOP and ask the user: "<skill-name> already exists. Choose: (1) Update/Fold-in (Mode 4), (2) verify the existing skill is complete and stop, or (3) force full regeneration." Do not re-extract until the user chooses. On context recovery after an interrupted run (network cut-off, replayed or continued conversation), reuse the extraction work directory that run reported (Workdir -> in its output, or the path you set in BOOK_SKILL_WORKDIR) only if it is still intact and still matches the current inputs and options — the directory exists, its metadata.json is readable, the sources it lists match the files being converted now one-to-one on filename and content fingerprint (the extractor records a per-source sha256 in metadata.json; recompute the fingerprint from each file as it exists now and require an exact match — reuse_is_safe() in book_to_skill/utils.py is the executable form of this check), and its recorded extraction_mode is the mode this run is using (Step 2's "confirm the extraction is the document you asked for" rule). If it is missing (temp cleanup), its metadata.json is gone, the sources no longer match (a different filename, or a changed content fingerprint), the recorded metadata has no sha256 for a source (recorded before fingerprints existed, so freshness cannot be established), or the mode differs, say so and start a fresh extraction instead of resuming. When in doubt, ask the user before discarding or resuming.

Step 1 — Validate input

Verify that there is at least one supported file, directory, or glob pattern among the INPUT_PATHS. For directories and globs, expand them to find matching supported files (.pdf, .epub, .docx, .txt, .md, .markdown, .rst, .adoc, .html, .htm, .rtf, .mobi, .azw, .azw3).

If no supported files are found, stop with a clear error message.


Step 1.5 — Identify content type

Before extracting, ask the user:

"What kind of content do these sources have? This helps me choose the best extraction method.

  1. Technical — has code blocks, tables, formulas, diagrams (e.g. programming books, academic papers, architecture guides)
  2. Text-heavy — mostly prose, few or no tables/code (e.g. management, productivity, narrative non-fiction)
  3. Not sure — I'll use the fast method and warn you if quality seems limited"

Store the answer as BOOK_TYPE:

  • Option 1 → BOOK_TYPE=technical
  • Option 2 → BOOK_TYPE=text
  • Option 3 → BOOK_TYPE=text

If BOOK_TYPE=technical, inform the user before proceeding:

"📐 Technical mode selected — PDFs attempt Docling for layout-aware extraction. EPUBs and other formats use their existing text extractors; code, tables, and formulas may lose structure. Check each source's extraction_method and fallback_reason in metadata.json for the actual extraction path."

If BOOK_TYPE=text, inform:

"📄 Text mode selected — using the fastest suitable extractor for each file type. Plain text/Markdown/HTML are usually ready in seconds; PDFs use pdftotext when available."


Step 2 — Extract text from the source documents

Run the extraction script, passing the input paths:

SCRIPT_PATH=""
HERMES_HOME_RESOLVED="${HERMES_HOME:-$HOME/.hermes}"
OPENCLAW_STATE_DIR_RESOLVED="${OPENCLAW_STATE_DIR:-$HOME/.openclaw}"
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)"
HERMES_PROJECT_TRUSTED=false
if [ -n "$PROJECT_ROOT" ] && [ "${HERMES_AGENT:-}" = true ] && \
  command -v hermes >/dev/null 2>&1 && \
  command -v python3 >/dev/null 2>&1 && \
  hermes config get skills.trusted_project_dirs --json 2>/dev/null | PROJECT_ROOT="$PROJECT_ROOT" python3 -c 'import json, os, pathlib, sys; root=pathlib.Path(os.environ["PROJECT_ROOT"]).resolve(); sys.exit(not any(pathlib.Path(p).expanduser().resolve() == root for p in json.load(sys.stdin)))' 2>/dev/null
then
  HERMES_PROJECT_TRUSTED=true
fi

CANDIDATES=(
  "$HOME/.copilot/skills/book-to-skill/scripts/extract.py"
  "$HOME/.agents/skills/book-to-skill/scripts/extract.py"
  "$HOME/.claude/skills/book-to-skill/scripts/extract.py"
  "${OPENCLAW_STATE_DIR_RESOLVED}/skills/book-to-skill/scripts/extract.py"
  "${OPENCLAW_STATE_DIR_RESOLVED}/skills"/*/book-to-skill/scripts/extract.py
  "${OPENCLAW_STATE_DIR_RESOLVED}/skills"/*/*/book-to-skill/scripts/extract.py
  "${OPENCLAW_STATE_DIR_RESOLVED}/skills"/*/*/*/book-to-skill/scripts/extract.py
  "${OPENCLAW_STATE_DIR_RESOLVED}/skills"/*/*/*/*/book-to-skill/scripts/extract.py
  "${OPENCLAW_STATE_DIR_RESOLVED}/skills"/*/*/*/*/*/book-to-skill/scripts/extract.py
  "${OPENCLAW_STATE_DIR_RESOLVED}/skills"/*/*/*/*/*/*/book-to-skill/scripts/extract.py
  "$HOME/.config/opencode/skills/book-to-skill/scripts/extract.py"
  "$HERMES_HOME_RESOLVED/skills/book-to-skill/scripts/extract.py"
  "$HERMES_HOME_RESOLVED"/skills/*/book-to-skill/scripts/extract.py
)
if [ "${HERMES_AGENT:-}" != true ]; then
  # Project-local roots are resolved against the git worktree, not the current
  # directory: an agent can be invoked from anywhere inside the project (e.g.
  # `src/nested`) and these roots still have to be found — that is how OpenCode
  # and the other hosts discover project skills. The CWD-relative forms are kept
  # so the probe also works outside a git repository.
  if [ -n "$PROJECT_ROOT" ]; then
    CANDIDATES+=(
      "$PROJECT_ROOT/.github/skills/book-to-skill/scripts/extract.py"
      "$PROJECT_ROOT/.claude/skills/book-to-skill/scripts/extract.py"
      "$PROJECT_ROOT/.agents/skills/book-to-skill/scripts/extract.py"
      "$PROJECT_ROOT/.opencode/skills/book-to-skill/scripts/extract.py"
    )
  fi
  CANDIDATES+=(
    ".github/skills/book-to-skill/scripts/extract.py"
    ".claude/skills/book-to-skill/scripts/extract.py"
    ".agents/skills/book-to-skill/scripts/extract.py"
    "skills/book-to-skill/scripts/extract.py"
    "skills"/*/book-to-skill/scripts/extract.py
    "skills"/*/*/book-to-skill/scripts/extract.py
    "skills"/*/*/*/book-to-skill/scripts/extract.py
    "skills"/*/*/*/*/book-to-skill/scripts/extract.py
    "skills"/*/*/*/*/*/book-to-skill/scripts/extract.py
    "skills"/*/*/*/*/*/*/book-to-skill/scripts/extract.py
    ".opencode/skills/book-to-skill/scripts/extract.py"
  )
  if [ -n "$PROJECT_ROOT" ]; then
    CANDIDATES+=(
      "$PROJECT_ROOT/skills/book-to-skill/scripts/extract.py"
      "$PROJECT_ROOT/skills"/*/book-to-skill/scripts/extract.py
      "$PROJECT_ROOT/skills"/*/*/book-to-skill/scripts/extract.py
      "$PROJECT_ROOT/skills"/*/*/*/book-to-skill/scripts/extract.py
      "$PROJECT_ROOT/skills"/*/*/*/*/book-to-skill/scripts/extract.py
      "$PROJECT_ROOT/skills"/*/*/*/*/*/book-to-skill/scripts/extract.py
      "$PROJECT_ROOT/skills"/*/*/*/*/*/*/book-to-skill/scripts/extract.py
    )
  fi
fi
CANDIDATES+=(
  "$HOME/.config/agents/skills/book-to-skill/scripts/extract.py"
  "$HOME/.config/amp/skills/book-to-skill/scripts/extract.py"
)
if [ "$HERMES_PROJECT_TRUSTED" = true ]; then
  CANDIDATES=(
    "$PROJECT_ROOT/.hermes/skills/book-to-skill/scripts/extract.py"
    "$PROJECT_ROOT/.hermes/skills"/*/book-to-skill/scripts/extract.py
    "$PROJECT_ROOT/.agents/skills/book-to-skill/scripts/extract.py"
    "$PROJECT_ROOT/.agents/skills"/*/book-to-skill/scripts/extract.py
    "${CANDIDATES[@]}"
  )
fi
for candidate in "${CANDIDATES[@]}"
do
  if [ -f "$candidate" ]; then
    SCRIPT_PATH="$candidate"
    break
  fi
done

if [ -z "$SCRIPT_PATH" ]; then
  echo "Could not find scripts/extract.py for book-to-skill" >&2
  exit 1
fi

PYTHON_BIN="${PYTHON_BIN:-python3}"
if ! command -v "$PYTHON_BIN" >/dev/null 2>&1; then
  PYTHON_BIN="python"
fi

"$PYTHON_BIN" "$SCRIPT_PATH" $INPUT_PATHS --mode <BOOK_TYPE> --install-missing ask

Before extraction, the script checks optional Python packages needed for the detected format. If a better extractor is missing, it prompts the user with the available fallback. Non-interactive sessions default to fallback unless install mode is explicitly yes.

Tip — preflight the environment: run "$PYTHON_BIN" "$SCRIPT_PATH" --check to p

...

ユーザーレビュー (0)

レビューを書く

効果
使いやすさ
ドキュメント
互換性

レビューなし

統計データ

インストール数9.8K
評価4.5 / 5.0
バージョン
更新日2026年11月20日
比較事例1 件

ユーザー評価

4.5(120)
5
37%
4
43%
3
13%
2
5%
1
2%

この Skill を評価

0.0

対応プラットフォーム

🤖claude-code

タイムライン

作成2026年5月5日
最終更新2026年11月20日
🎁 Agent 知識カード
アンケート