From bmad-skills
Converts EPUB books to formatted Markdown via pandoc extraction and AI fixes for paragraphs, code blocks, headers, TOC. Use when user provides EPUB file path.
npx claudepluginhub bmad-labs/skills --plugin bmad-skillsThis skill uses the workspace's default tool permissions.
Convert EPUB books into professionally formatted Markdown books with AI-assisted quality improvements.
Suggests manual /compact at logical task boundaries in long Claude Code sessions and multi-phase tasks to avoid arbitrary auto-compaction losses.
Share bugs, ideas, or general feedback.
Convert EPUB books into professionally formatted Markdown books with AI-assisted quality improvements.
This skill converts EPUB files into high-quality Markdown documents by:
User provides an EPUB file path:
/Users/username/Downloads/Book.Name.2024.epub
Execute the conversion workflow:
python3 scripts/convert_book.py "/path/to/book.epub"
This initiates the complete conversion process.
CRITICAL: Use subagents for all formatting work to avoid polluting main context.
Run the conversion script:
python3 scripts/convert_book.py "/path/to/book.epub"
This script:
books/book-name/ - Main directorybooks/book-name/raw/ - Pandoc outputbooks/book-name/chapters/ - Formatted chaptersbooks/book-name/images/ - Extracted imagesOutput: Raw Markdown in books/book-name/raw/book-parsed.md
Step 1: Run the structure analysis script (Main Agent):
python3 books/book-name/analyze_structure.py books/book-name
This script:
STRUCTURE_ANALYSIS.md report (~5-10 KB instead of 35k+ lines)Step 2: Launch a general subagent to create mapping files:
Task(
subagent_type="general",
description="Create chapter map and formatting plan",
prompt="""Create CHAPTER_MAP.md and FORMATTING_PLAN.md:
1. Read books/book-name/STRUCTURE_ANALYSIS.md (concise report with headers and issues)
2. Read books/book-name/references/chapter-map-template.md for format
3. Read books/book-name/references/formatting-plan-template.md for format
4. Create books/book-name/CHAPTER_MAP.md:
- Use suggested chapter boundaries from analysis
- Verify line ranges make sense
- Create proper slugged filenames
5. Create books/book-name/FORMATTING_PLAN.md:
- Document issues found in analysis
- Add severity and priority
- Note book-specific patterns
6. Update books/book-name/progress.md to mark Phase 2 complete
Return: Summary of chapters found and major issues identified."""
)
Output: CHAPTER_MAP.md, FORMATTING_PLAN.md, and updated progress.md
For EACH chapter, launch a separate general subagent:
# Example for Chapter 1
Task(
subagent_type="general",
description="Format Chapter 1",
prompt="""Format Chapter 1 following the chapter formatting workflow.
**Critical Instructions:**
1. Read and follow ALL steps in books/book-name/references/chapter-workflow.md
2. Apply formatting rules from books/book-name/references/formatting-standards.md
3. Use books/book-name/CHAPTER_MAP.md to find line ranges for Chapter 1
4. Read books/book-name/FORMATTING_PLAN.md for known issues to watch for
**Workflow Summary (see chapter-workflow.md for complete details):**
Step 1: Read Standards and Chapter Map
- Read references/formatting-standards.md
- Read CHAPTER_MAP.md for your chapter's line ranges
- Read FORMATTING_PLAN.md for known issues
Step 2: Extract Chapter Content
- Extract Chapter 1 from raw/book-parsed.md using line ranges
Step 3: Identify Issues follow the standards
- Headers using bold instead of #
- Shattered code blocks
- Split paragraphs
- Missing code language identifiers
- Emphasis artifacts [word]
- Corrupted footnotes
- Missing image alt text
- Broken links
Step 4: Apply Formatting Fixes
- Follow the three-pass approach in chapter-workflow.md:
* First pass: Structure (headers, code blocks)
* Second pass: Content (paragraphs, emphasis)
* Third pass: Details (footnotes, images, links)
Step 5: Create Output File
- Write to books/book-name/chapters/chapter-01-title.md
- Use structure from chapter-workflow.md
Step 6: Update Progress
- Update books/book-name/progress.md with completion status
- Document fixes applied
**Quality Checklist (from chapter-workflow.md):**
- [ ] All headers use proper # syntax
- [ ] All code blocks have language identifiers
- [ ] No shattered code blocks remain
- [ ] Text flows naturally without mid-sentence breaks
- [ ] All footnotes have [^N] format with definitions
- [ ] Images have descriptive alt text
Return: Confirmation with summary of fixes applied."""
)
Important:
Output: Formatted chapters in books/book-name/chapters/
The merge_book.py script is already copied to your project directory. Simply run it:
python3 books/book-name/merge_book.py books/book-name
The script will:
CHAPTER_MAP.md for chapter orderchapters/books/book-name-book.mdOutput: books/book-name-book.md with complete formatted book
Note: The merge script is reusable - no need to create it per book!
Every subagent in Phase 3 MUST:
Why this matters:
The workflow documents are your complete instructions - trust them!
Never process book content in main context. Always use subagents to:
Subagent Selection: Always use subagent_type="general" for all book processing tasks.
Create and maintain books/book-name/progress.md:
# Book Name - Conversion Progress
## Phase 1: Setup ✓
- [x] EPUB extracted
- [x] Project structure created
## Phase 2: Planning ✓
- [x] Chapter map created (15 chapters identified)
- [x] Formatting plan documented
## Phase 3: Chapter Formatting (5/15 complete)
- [x] Front Matter
- [x] Chapter 1: Introduction
- [x] Chapter 2: Getting Started
- [x] Chapter 3: Advanced Topics
- [x] Chapter 4: Best Practices
- [ ] Chapter 5: Performance
- [ ] ...
## Phase 4: Assembly
- [ ] Merge script created
- [ ] Final book generated
Update after each subagent completes.
All formatted output must meet these criteria:
# syntax, not bold text*italic* and **bold**, not [brackets][^1] format with definitionsComplete standards reference: references/formatting-standards.md
User Request:
"Convert this EPUB to Markdown: /Users/john/Downloads/Effective.Java.3rd.Edition.epub"
Skill Execution:
books/effective-java-final.md