$npx -y skills add tuan3w/obsidian-vault-agent --skill book-analyzerAnalyze a book (EPUB/PDF) and generate detailed chapter-by-chapter notes with extracted key concepts. Use when given a book file path to process.
| 1 | <Purpose> |
| 2 | Full autonomous analysis of book files (EPUB/PDF) into structured notes. |
| 3 | Extracts text, detects chapters, analyzes each chapter via parallel agents, |
| 4 | synthesizes across chapters, and optionally integrates into an Obsidian vault |
| 5 | with wikilinks and extracted Term notes. |
| 6 | </Purpose> |
| 7 | |
| 8 | <Use_When> |
| 9 | - User provides a path to an EPUB or PDF book file |
| 10 | - User says "analyze this book", "process this book", "read this book" |
| 11 | - User wants structured notes from a book-length document (20+ pages) |
| 12 | </Use_When> |
| 13 | |
| 14 | <Do_Not_Use_When> |
| 15 | - Short documents under 20 pages — use /paper or /process instead |
| 16 | - User wants to read or search specific sections — just use Read tool directly |
| 17 | - User wants EPUB output from markdown — wrong direction |
| 18 | - URL-only input with no file on disk — use /research instead |
| 19 | </Do_Not_Use_When> |
| 20 | |
| 21 | <Why_This_Exists> |
| 22 | Book notes that merely transcribe content are useless — the value is in synthesis. |
| 23 | Most book notes in a vault end up sparse because processing a full book manually is |
| 24 | exhausting. This skill automates the mechanical work (extraction, splitting, formatting) |
| 25 | while delegating the intellectual work (synthesis, assessment, connections) to specialized |
| 26 | agents with strict quality constraints. |
| 27 | </Why_This_Exists> |
| 28 | |
| 29 | <Execution_Policy> |
| 30 | - Run extraction scripts first, verify output before proceeding to analysis |
| 31 | - Delegate chapter analysis to parallel agents (one per chapter, all simultaneous) |
| 32 | - Use Sonnet for chapter analysis, Opus for cross-book synthesis |
| 33 | - Vault integration is conditional — detect .obsidian/ or CLAUDE.md in working directory |
| 34 | - Report progress via TodoWrite at each stage transition |
| 35 | - If extraction fails, stop and report — don't guess at content |
| 36 | - Total chapters capped at 50 — if more, group adjacent chapters into batches |
| 37 | </Execution_Policy> |
| 38 | |
| 39 | <Steps> |
| 40 | |
| 41 | ## Stage 1: PARSE ARGUMENTS AND EXTRACT |
| 42 | |
| 43 | Parse `$ARGUMENTS` to get the book file path and optional flags. |
| 44 | |
| 45 | **Argument format:** |
| 46 | ``` |
| 47 | $ARGUMENTS = "path/to/book.epub" # basic |
| 48 | $ARGUMENTS = "path/to/book.pdf --no-terms" # skip term extraction |
| 49 | $ARGUMENTS = "path/to/book.epub --output ~/Desktop/" # custom output location |
| 50 | ``` |
| 51 | |
| 52 | **Parse logic:** |
| 53 | 1. Split $ARGUMENTS by spaces, treating quoted paths as single tokens |
| 54 | 2. First non-flag token = file path (REQUIRED — stop if missing) |
| 55 | 3. Optional flags: `--no-terms` (skip concept extraction), `--output <dir>` (custom output) |
| 56 | 4. Detect format from file extension: `.epub`, `.pdf`, `.mobi` |
| 57 | |
| 58 | **Run extraction based on format:** |
| 59 | |
| 60 | For EPUB: |
| 61 | ```bash |
| 62 | SKILL_DIR="$(dirname "$(readlink -f "$0" 2>/dev/null || echo "$0")")" |
| 63 | # Find skill directory — check common locations |
| 64 | for dir in .claude/skills/book-analyzer ~/.claude/skills/book-analyzer; do |
| 65 | if [ -f "$dir/scripts/extract_epub.py" ]; then SKILL_DIR="$dir"; break; fi |
| 66 | done |
| 67 | WORK_DIR=".book-work-$(date +%s)" |
| 68 | python3 "$SKILL_DIR/scripts/extract_epub.py" "INPUT_PATH" "$WORK_DIR" |
| 69 | ``` |
| 70 | |
| 71 | For PDF: |
| 72 | ```bash |
| 73 | WORK_DIR=".book-work-$(date +%s)" |
| 74 | "$SKILL_DIR/scripts/extract_pdf.sh" "INPUT_PATH" "$WORK_DIR" |
| 75 | ``` |
| 76 | |
| 77 | For MOBI: Convert to EPUB first with `ebook-convert` (calibre), then run EPUB extraction. |
| 78 | |
| 79 | The work directory is created inside the vault root (e.g., `.book-work-1709398200/`). |
| 80 | Clean it up after the pipeline completes. |
| 81 | |
| 82 | **After extraction:** Read `$WORK_DIR/metadata.json` to verify success. |
| 83 | |
| 84 | **PDF fallback:** If metadata shows `"needs_fallback": true`, use the Claude Read tool instead: |
| 85 | - Read the PDF 20 pages at a time: `Read(file_path="INPUT_PATH", pages="1-20")`, then `pages="21-40"`, etc. |
| 86 | - Write each batch to `$WORK_DIR/pages/page_batch_NNN.txt` |
| 87 | - Update metadata with actual content |
| 88 | |
| 89 | ## Stage 2: STRUCTURE |
| 90 | |
| 91 | Read `metadata.json` from the extraction output. |
| 92 | |
| 93 | **For EPUBs:** Chapter structure comes directly from extraction (H1/H2 splitting). Proceed to Stage 3. |
| 94 | |
| 95 | **For PDFs:** Chapter detection depends on extraction quality. |
| 96 | - If pages have clear chapter headings, group pages into chapters |
| 97 | - If no clear structure: Launch a single agent to read the first 5 pages and detect chapter boundaries: |
| 98 | |
| 99 | ``` |
| 100 | Agent( |
| 101 | subagent_type="general-purpose", |
| 102 | model="haiku", |
| 103 | prompt="Read the following text from the first 5 pages of a book. Identify chapter |
| 104 | boundaries and return a JSON array of {title, start_page, end_page} objects. |
| 105 | If no chapters are detectable, return [{title: 'Full Text', start_page: 1, end_page: LAST}]. |
| 106 | |
| 107 | TEXT: |
| 108 | [first 5 pages content]" |
| 109 | ) |
| 110 | ``` |
| 111 | |
| 112 | - Update metadata with detected chapter list |
| 113 | - Group page files into chapter files by concatenation |
| 114 | |
| 115 | **Result:** A `chapters/` directory with one file per chapter, and updated `metadata.json`. |
| 116 | |
| 117 | ## Stage 3: ANALYZE (parallel, file-based) |
| 118 | |
| 119 | Read the agent definition from `agents/ |