Build an EPUB from your fiction project. Compiles chapters, metadata, and optionally a cover image.
View on GitHubhowells/fiction
fiction
skills/build/SKILL.md
January 25, 2026
Select agents to install to:
npx add-skill https://github.com/howells/fiction/blob/main/skills/build/SKILL.md -a claude-code --skill buildInstallation paths:
.claude/skills/build/Build an EPUB file from the current fiction project. ## Build Context - Chapter count: !`ls chapters/*.md 2>/dev/null | wc -l | tr -d ' '` - Has cover: !`ls covers/cover.* 2>/dev/null | head -1 || echo "no cover found"` ## What This Does 1. Reads project metadata from README.md 2. Compiles all chapters from `chapters/` in order 3. Applies styling from `epub.css` (if present) 4. Includes cover image from `covers/` (if specified) 5. Sets a stable EPUB identifier (preserves highlights across builds) 6. Outputs to `builds/` directory ## Usage ``` /fiction:build # Build dated epub (archive mode) /fiction:build --sync # Build for Apple Books sync (preserves highlights) /fiction:build --cover cover.png # Include specific cover image /fiction:build /path/to/project # Build specific project ``` If arguments provided: $ARGUMENTS ## Build Modes ### Archive Mode (default) Outputs: `builds/YYYY-MM-DD/project-name-YYYY-MM-DD.epub` - Each build is date-stamped - Preserves history of versions - Good for milestones and backups ### Sync Mode (`--sync`) Outputs: `builds/project-name.epub` - Same filename every time - Uses stable EPUB identifier - **Preserves highlights and reading position in Apple Books** - Ideal for reading on devices while writing ## What to Do ### 1. Find Project Root Look for README.md, chapters/ directory. Support both flat and part-based structures: **Flat structure:** ``` chapters/01-chapter.md chapters/02-chapter.md ``` **Part-based structure:** ``` part-1-name/chapters/01-chapter.md part-2-name/chapters/10-chapter.md ``` ### 2. Gather Metadata Extract from README.md: - **Title** — Project name (H1 heading) - **Author** — From frontmatter or infer from git config - **Description** — From "The Story" section or premise ### 3. Generate Identifier Create a stable identifier for the EPUB: ``` com.author-name.project-name ``` This identifier is what Apple Books uses to recognize "same book, updated" — prese