jpskill.com
🛠️ 開発・MCP コミュニティ

ai-chapter-consolidate

AIを活用して、複数のHTMLファイルを結合し、章単位でまとまった読みやすいドキュメントを生成することで、内容理解を深め、一貫性のある情報提供を実現するSkill。

📜 元の英語説明(参考)

Use AI to merge individual page HTML files into a unified chapter document. Creates continuous document format for improved reading experience and semantic consistency.

🇯🇵 日本人クリエイター向け解説

一言でいうと

AIを活用して、複数のHTMLファイルを結合し、章単位でまとまった読みやすいドキュメントを生成することで、内容理解を深め、一貫性のある情報提供を実現するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o ai-chapter-consolidate.zip https://jpskill.com/download/16953.zip && unzip -o ai-chapter-consolidate.zip && rm ai-chapter-consolidate.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/16953.zip -OutFile "$d\ai-chapter-consolidate.zip"; Expand-Archive "$d\ai-chapter-consolidate.zip" -DestinationPath $d -Force; ri "$d\ai-chapter-consolidate.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して ai-chapter-consolidate.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → ai-chapter-consolidate フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

AI Chapter Consolidate Skill

目的

このスキルは、AI を使用して個々のページの HTML ファイルをインテリジェントにマージし、連続した 1 つの章のドキュメントにします。単純な連結ではなく、AI は以下を行います。

  • 継続ページから重複するヘッダー/フッターを削除します
  • ページ全体で一貫した見出し階層を確保します
  • 全体を通してセマンティック構造を維持します
  • 損失や繰り返しなしにすべてのコンテンツを保持します
  • スムーズなコンテンツフローを作成します (改ページなし)

その結果、連続した形式 (単一の page-container、単一の page-content) の統合された章のドキュメントが得られます。

実行内容

  1. 章のすべてのページの HTML ファイルを収集します

    • 章のすべてのページの 04_page_XX.html ファイルを収集します
    • すべてのファイルが存在し、有効であることを確認します
    • ページ番号でソートします (昇順)
  2. 各ページからコンテンツを抽出します

    • 各 HTML ファイルをロードします
    • <main class="page-content"> からメインコンテンツを抽出します
    • セマンティッククラスと構造を保持します
  3. AI のための統合入力を準備します

    • 1 ページ目: 章のヘッダーを含むすべてのコンテンツ
    • 2 ページ目以降: コンテンツセクションを抽出し、章のヘッダー/ナビゲーションを削除します
    • すべてのテキストと構造を保持します
    • 特別なセクション (展示、表など) をメモします
  4. AI 統合を呼び出します

    • すべてのページコンテンツを Claude に送信します
    • 単一の連続したドキュメントへのマージをリクエストします
    • 構造要件を指定します
    • 見出し階層の正規化をリクエストします
  5. AI 出力を処理します

    • レスポンスから統合された HTML を抽出します
    • 構造の整合性を検証します
    • すべてのページが表現されていることを確認します
    • 見出し階層を確認します
  6. 統合されたドキュメントを保存します

    • 以下に保存します: output/chapter_XX/chapter_artifacts/chapter_XX.html
    • メタデータ/ログファイルを作成します
    • 統計を計算します

入力ファイル

ページごとの HTML ファイル (以前のゲートで検証済み):

  • output/chapter_XX/page_artifacts/page_16/04_page_16.html (章の開始)
  • output/chapter_XX/page_artifacts/page_17/04_page_17.html (継続)
  • output/chapter_XX/page_artifacts/page_18/04_page_18.html (継続)
  • ... (章のすべてのページ)

章のメタデータ (分析から):

  • ページ範囲 (章の最初と最後のページ)
  • 章番号
  • 章のタイトル
  • 予想されるページ数

AI 統合プロンプト

Claude に送信されるプロンプト:

あなたは、個々のページの HTML ドキュメントを、単一の連続した章にマージしています。

入力ページ:

1 ページ目 (開始 - 章のヘッダーを含める):
[1 ページ目の HTML コンテンツ]

2 ページ目 (継続):
[2 ページ目の HTML コンテンツ]

3 ページ目 (継続):
[3 ページ目の HTML コンテンツ]

... (すべてのページ)

タスク:
これらのページを、1 つの連続した章として読める単一の HTML ドキュメントにマージします。

要件:

1. 構造:
   - すべてをラップする単一の <div class="page-container"> を作成します
   - すべてのコンテンツに対して単一の <main class="page-content"> を作成します
   - 改ページインジケーターまたはコメントを削除します
   - 真に連続したドキュメントを作成します (ページ分割された要素はありません)

2. 章のヘッダー:
   - 1 ページ目の章のヘッダーを保持します (章番号、タイトル)
   - 継続ページから章のヘッダー/タイトルを削除します
   - 1 ページ目にセクションナビゲーションがある場合は保持します
   - 他のページから重複するナビゲーションを削除します

3. コンテンツの保持:
   - すべてのページのすべてのテキストコンテンツを含めます
   - 正確な言い回しを保持します (言い換えはしません)
   - すべてのリスト、段落、表を維持します
   - すべてのセマンティッククラスを含めます
   - すべての HTML 構造を保持します

4. 見出し階層:
   - マージされたページ全体で見出しレベルを正規化します
   - 1 ページ目の h1 = 章のタイトル (h1 のまま)
   - 各ページの最初のセクション = h2 (メインセクション)
   - サブセクション = 必要に応じて h3 または h4
   - 階層ジャンプがないことを確認します (h2 なしで h1 → h3)
   - 連続する見出しに論理的に番号を付けます

5. コンテンツフロー:
   - ページ固有のヘッダー/フッターを削除します
   - コンテンツが自然に流れるようにシームレスにマージします
   - 人工的な区切りやトランジションはありません
   - 段落は論理的に継続します
   - リストは一貫性を維持します

6. 展示と画像:
   - すべての表と図を保持します
   - 展示のタイトルとキャプションを保持します
   - 適切なパスですべての画像を含めます
   - 目次がある場合は維持します

7. CSS クラス:
   - すべてのセマンティッククラスを保持します (section-heading、paragraph など)
   - 全体を通して一貫したクラスの使用を維持します
   - クラスが章の開始ページのスタイルと一致することを確認します
   - クラスを追加または削除しないでください

8. メタデータ:
   - タイトルタグを含めます: "Chapter N: Title - Pages X-Y"
   - meta charset と viewport を保持します
   - スタイルシートをリンクします: <link rel="stylesheet" href="../../styles/main.css">

出力:

単一の有効な HTML5 ドキュメントのみを返します:

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Chapter [N]: [Title] - Pages [X-Y]</title>
    <link rel="stylesheet" href="../../styles/main.css">
</head>
<body>
    <div class="page-container">
        <main class="page-content">
            <!-- すべてのページのすべてのコンテンツをシームレスにマージ -->
        </main>
    </div>
</body>
</html>

検証:

  • 単一の HTML5 ドキュメント
  • すべてのページが表現されている
  • 改ページやトランジションがない
  • 適切な見出し階層
  • すべてのテキストが保持されている

ページコンテンツ抽出ロジック

AI に送信する前に、戦略的にコンテンツを抽出します。

1 ページ目 (開始):

  • 含める: ページ全体の HTML コンテンツ
  • 理由: 章のヘッダー、ナビゲーション、最初のセクションが含まれています
  • 保持: すべての要素 (ヘッダー、ナビゲーション、区切り線、コンテンツ)

2 ページ目から N ページ目 (継続):

  • 抽出: 章のヘッダー後のコンテンツのみ
  • スキップ: 章番号、章のタイトル、セクションナビゲーション
  • 保持: セクションの見出し、段落、リスト、展示
  • 含める: すべてのセマンティックコンテンツセクション

抽出の例:


<!-- 1 ページ目: すべてを保持 -->
<div class="chapter-header">
    <span class="chapter-number">2</span>
    <h1 class="chapter-title">Rights in Real Estate</h1>
</div>
<nav class="section-navigation">...</nav>
<h2 class="section-heading">REAL PROPERTY RIGHTS</h2>
<p class="paragraph">...</p>

<!-- Pa

(原文がここで切り詰められています)
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

AI Chapter Consolidate Skill

Purpose

This skill uses AI to intelligently merge individual page HTML files into a single, continuous chapter document. Rather than simple concatenation, the AI:

  • Removes duplicate headers/footers from continuation pages
  • Ensures consistent heading hierarchy across pages
  • Maintains semantic structure throughout
  • Preserves all content without loss or repetition
  • Creates smooth content flow (no page breaks)

The result is a unified chapter document in the continuous format (single page-container, single page-content).

What to Do

  1. Collect all page HTML files for chapter

    • Gather 04_page_XX.html files for all pages in chapter
    • Verify all files exist and are valid
    • Sort by page number (ascending)
  2. Extract content from each page

    • Load each HTML file
    • Extract main content from <main class="page-content">
    • Preserve semantic classes and structure
  3. Prepare consolidation inputs for AI

    • Page 1: Full content including chapter header
    • Pages 2+: Extract content sections, remove chapter header/nav
    • Preserve all text and structure
    • Note any special sections (exhibits, tables, etc.)
  4. Invoke AI consolidation

    • Send all page contents to Claude
    • Request merging into single continuous document
    • Specify structural requirements
    • Request heading hierarchy normalization
  5. Process AI output

    • Extract consolidated HTML from response
    • Verify structure integrity
    • Ensure all pages represented
    • Check heading hierarchy
  6. Save consolidated document

    • Save to: output/chapter_XX/chapter_artifacts/chapter_XX.html
    • Create metadata/log file
    • Calculate statistics

Input Files

Per-page HTML files (validated by previous gate):

  • output/chapter_XX/page_artifacts/page_16/04_page_16.html (Chapter opening)
  • output/chapter_XX/page_artifacts/page_17/04_page_17.html (Continuation)
  • output/chapter_XX/page_artifacts/page_18/04_page_18.html (Continuation)
  • ... (all pages in chapter)

Chapter metadata (from analysis):

  • Page range (first and last page of chapter)
  • Chapter number
  • Chapter title
  • Expected page count

AI Consolidation Prompt

The prompt sent to Claude:

You are merging individual page HTML documents into a single, continuous chapter.

INPUT PAGES:

Page 1 (Opening - include chapter header):
[HTML content from page 1]

Page 2 (Continuation):
[HTML content from page 2]

Page 3 (Continuation):
[HTML content from page 3]

... (all pages)

TASK:
Merge these pages into a single HTML document that reads as one continuous chapter.

REQUIREMENTS:

1. Structure:
   - Create single <div class="page-container"> wrapping everything
   - Create single <main class="page-content"> for all content
   - Remove page-break indicators or comments
   - Create truly continuous document (no paginated elements)

2. Chapter Header:
   - Keep chapter header from Page 1 (chapter number, title)
   - Remove chapter headers/titles from continuation pages
   - Keep section navigation if present on Page 1
   - Remove duplicate navigation from other pages

3. Content Preservation:
   - Include ALL text content from all pages
   - Preserve exact wording (no paraphrasing)
   - Maintain all lists, paragraphs, tables
   - Include all semantic classes
   - Keep all HTML structure

4. Heading Hierarchy:
   - Normalize heading levels across merged pages
   - Page 1 h1 = Chapter title (stays as h1)
   - First section in each page = h2 (main sections)
   - Sub-sections = h3 or h4 as needed
   - Ensure no hierarchy jumps (h1 → h3 without h2)
   - Number consecutive headings logically

5. Content Flow:
   - Remove page-specific headers/footers
   - Merge seamlessly so content flows naturally
   - No artificial breaks or transitions
   - Paragraphs continue logically
   - Lists maintain coherence

6. Exhibits and Images:
   - Preserve all tables and figures
   - Keep exhibit titles and captions
   - Include all images with proper paths
   - Maintain table of contents if present

7. CSS Classes:
   - Preserve all semantic classes (section-heading, paragraph, etc.)
   - Keep consistent class usage throughout
   - Ensure classes match chapter opening page style
   - Do not add or remove classes

8. Metadata:
   - Include title tag: "Chapter N: Title - Pages X-Y"
   - Keep meta charset and viewport
   - Link stylesheet: <link rel="stylesheet" href="../../styles/main.css">

OUTPUT:

Return ONLY a single, valid HTML5 document:

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Chapter [N]: [Title] - Pages [X-Y]</title>
    <link rel="stylesheet" href="../../styles/main.css">
</head>
<body>
    <div class="page-container">
        <main class="page-content">
            <!-- All content from all pages, merged seamlessly -->
        </main>
    </div>
</body>
</html>

VALIDATION:

  • Single HTML5 document
  • All pages represented
  • No page breaks or transitions
  • Proper heading hierarchy
  • All text preserved

Page Content Extraction Logic

Before sending to AI, extract content strategically:

Page 1 (Opening):

  • Include: Entire page HTML content
  • Reason: Contains chapter header, navigation, first section
  • Preserve: All elements (header, nav, dividers, content)

Pages 2-N (Continuation):

  • Extract: Only content after chapter header
  • Skip: Chapter number, chapter title, section navigation
  • Preserve: Section headings, paragraphs, lists, exhibits
  • Include: All semantic content sections

Example extraction:

<!-- Page 1: Keep everything -->
<div class="chapter-header">
    <span class="chapter-number">2</span>
    <h1 class="chapter-title">Rights in Real Estate</h1>
</div>
<nav class="section-navigation">...</nav>
<h2 class="section-heading">REAL PROPERTY RIGHTS</h2>
<p class="paragraph">...</p>

<!-- Page 2: Skip header, keep content -->
<!-- <div class="chapter-header">...</div> SKIPPED -->
<!-- <nav class="section-navigation">...</nav> SKIPPED -->
<h4 class="subsection-heading">Physical characteristics.</h4>
<p class="paragraph">...</p>
<ul class="bullet-list">...</ul>

<!-- Page 3: Continue same pattern -->
<h4 class="subsection-heading">Interdependence.</h4>
<p class="paragraph">...</p>

Output File

Consolidated Chapter HTML

Path: output/chapter_XX/chapter_artifacts/chapter_XX.html

Structure:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Chapter 2: Rights in Real Estate - Pages 16-29</title>
    <link rel="stylesheet" href="../../styles/main.css">
</head>
<body>
    <div class="page-container">
        <main class="page-content">
            <!-- Chapter header (from page 1) -->
            <div class="chapter-header">...</div>
            <nav class="section-navigation">...</nav>
            <hr class="section-divider">

            <!-- Page 1 content -->
            <h2 class="section-heading">REAL PROPERTY RIGHTS</h2>
            <p class="paragraph">...</p>

            <!-- Page 2 content (seamlessly merged) -->
            <h4 class="subsection-heading">Physical characteristics.</h4>
            <p class="paragraph">...</p>
            <ul class="bullet-list">...</ul>

            <!-- Page 3 content (continuing flow) -->
            <h4 class="subsection-heading">Interdependence.</h4>
            <p class="paragraph">...</p>

            <!-- ... more content from remaining pages ... -->

            <!-- Final page content -->
            <h2 class="section-heading">REGULATIONS AND LICENSING</h2>
            <p class="paragraph">...</p>
        </main>
    </div>
</body>
</html>

Consolidation Log

Path: output/chapter_XX/chapter_artifacts/consolidation_log.json

{
  "chapter": 2,
  "title": "Rights in Real Estate",
  "book_pages": "16-29",
  "pdf_indices": "15-28",
  "consolidated_at": "2025-11-08T14:35:00Z",
  "pages_merged": 14,
  "pages_included": [
    {
      "page": 16,
      "book_page": 17,
      "status": "opening_chapter",
      "content_type": "header_navigation_content"
    },
    {
      "page": 17,
      "book_page": 18,
      "status": "continuation",
      "content_type": "subsections_paragraphs"
    },
    {
      "page": 18,
      "book_page": 19,
      "status": "continuation",
      "content_type": "subsections_paragraphs_list"
    }
    // ... all pages
  ],
  "content_statistics": {
    "total_headings": {
      "h1": 1,
      "h2": 4,
      "h3": 0,
      "h4": 12
    },
    "total_paragraphs": 156,
    "total_lists": 12,
    "total_list_items": 42,
    "total_tables": 3,
    "total_images": 5,
    "total_words": 12547
  },
  "ai_model": "claude-3-5-sonnet-20241022",
  "consolidation_notes": "Successfully merged 14 pages into continuous format"
}

Implementation

Execute consolidation via Python wrapper:

cd Calypso/tools

# Run consolidation
python3 consolidate_chapter.py \
  --chapter 2 \
  --pages 15-28 \
  --output "../output" \
  --mapping "../analysis/page_mapping.json"

# Or invoke directly via Claude API:
# The orchestrator sends the AI prompt with all page contents

Quality Checks

Before passing to next gate:

  1. File created

    • [ ] chapter_XX.html exists
    • [ ] File is valid HTML (parseable)
    • [ ] File size reasonable (> 50KB typical)
  2. Structure validated

    • [ ] Single <div class="page-container">
    • [ ] Single <main class="page-content">
    • [ ] All tags properly closed
    • [ ] No duplicate content
  3. Content completeness

    • [ ] All pages represented
    • [ ] No missing sections
    • [ ] Paragraph/heading counts reasonable
    • [ ] All text content present
  4. Heading hierarchy

    • [ ] Starts with h1 (chapter title)
    • [ ] h1 count = 1
    • [ ] h2 = major sections
    • [ ] h3/h4 = subsections
    • [ ] No hierarchy jumps
  5. Metadata logged

    • [ ] Consolidation timestamp recorded
    • [ ] Pages merged count documented
    • [ ] Content statistics calculated
    • [ ] Log file saved

Success Criteria

✓ All pages merged into single document ✓ Chapter header preserved from page 1 ✓ Duplicate headers removed from continuation pages ✓ Content flows naturally (continuous format) ✓ Heading hierarchy is correct ✓ All text content preserved ✓ Semantic classes maintained ✓ Ready for semantic validation

Error Handling

If page HTML is incomplete:

  • Note in consolidation log
  • Include whatever content is available
  • Proceed to validation (validation will catch issues)

If heading hierarchy is ambiguous:

  • AI makes best judgment
  • Semantic validation gate will refine if needed
  • Document decision in log

If content appears duplicated:

  • AI deduplicates automatically
  • Verify word count is reasonable
  • Log any unusual content patterns

Next Steps

Once consolidation completes:

  1. Quality Gate 2 (semantic-validate) checks semantic structure
  2. Skill 5 (quality-report-generate) generates final report
  3. Quality Gate 3 (visual-accuracy-check) validates appearance

Design Notes

  • This skill is AI-powered (uses probabilistic consolidation)
  • Relies on AI's understanding of document structure
  • Produces continuous format (no page breaks)
  • Merges intelligently (not just concatenation)
  • Output will be refined by validation gates

Testing

To test consolidation on Chapter 2:

# Input: 14 individual page HTML files (pages 16-29)
# Process: AI merges into single continuous chapter
# Output: chapter_02.html (single, unified document)

# Verify:
# - File size is sum of all pages
# - Content flows logically
# - Heading hierarchy makes sense
# - No duplicate sections