Content Hash Cache Pattern

SHA-256コンテンツハッシュを使用して、高コストなファイル処理結果をキャッシュします — パス非依存、自動無効化、サービスレイヤーの分離。

293,665 stars 43,456 forksWriting & Content Plugin marketplace

Install

Claude Code plugin
/plugin marketplace add affaan-m/ECC

The repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add affaan-m/ECC --skill content-hash-cache-pattern
Manual install
git clone --depth 1 https://github.com/affaan-m/ECC.git /tmp/ECC
mkdir -p ~/.claude/skills
cp -r /tmp/ECC/docs/ja-JP/skills/content-hash-cache-pattern ~/.claude/skills/content-hash-cache-pattern

Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.

From the SKILL.md

# コンテンツハッシュファイルキャッシュパターン

SHA-256コンテンツハッシュをキャッシュキーとして使用して、高コストなファイル処理結果(PDF解析、テキスト抽出、画像分析)をキャッシュします。パスベースのキャッシュとは異なり、このアプローチはファイルの移動/名前変更に対して生き残り、コンテンツが変更されたときに自動的に無効化されます。

## 起動条件

- ファイル処理パイプラインの構築(PDF、画像、テキスト抽出)
- 処理コストが高く、同じファイルが繰り返し処理される場合
- `--cache/--no-cache`CLIオプションが必要な場合
- 既存の純粋な関数を変更せずにキャッシュを追加したい場合

## コアパターン

### 1. コンテンツハッシュベースのキャッシュキー

パスではなくファイルコンテンツをキャッシュキーとして使用します:

```python
import hashlib
from pathlib import Path

_HASH_CHUNK_SIZE = 65536  # 大きなファイルには64KBチャンク

def compute_file_hash(path: Path) -> str:
    """ファイルコンテンツのSHA-256(大きなファイルにはチャンク処理)。"""
    if not path.is_file():
        raise FileNotFoundError(f"File not found: {path}")
    sha256 = hashlib.sha256()
    with open(path, "rb") as f:
        while True:
            chunk = f.read(_HASH_CHUNK_SIZE)
            if not chunk:
                break
            sha256.update(chunk)
    return sha256.hexdigest()
```

**なぜコンテンツハッシュ?** ファイルの名前変更/移動 = キャッシュヒット。コンテンツ変更 = 自動無効化。インデックスファイル不要。

### 2. キャッシュエントリの凍結データクラス

```python
from dataclasses import dataclass

@dataclass(frozen=True, slots=True)
class CacheEntry:
    file_hash: str
    source_path: str
    document: ExtractedDocument  # キャッシュされた結果
```

### 3. ファイルベースのキャッシュストレージ

各キャッシュエントリは`{hash}.json`として保存されます — ハッシュによるO(1)検索、インデックスファイル不要。
Read the full skill on GitHub

Details

Skill name
content-hash-cache-pattern
Repository
affaan-m/ECC
Path
docs/ja-JP/skills/content-hash-cache-pattern/SKILL.md
License
MIT
Repo updated
30 October 2026

FAQ

What does the Content Hash Cache Pattern skill do?

SHA-256コンテンツハッシュを使用して、高コストなファイル処理結果をキャッシュします — パス非依存、自動無効化、サービスレイヤーの分離。

How do I install the Content Hash Cache Pattern skill?

Claude Code plugin: /plugin marketplace add affaan-m/ECC. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.

Is Content Hash Cache Pattern popular?

It lives in affaan-m/ECC, which has 293,665 GitHub stars and 43,456 forks, and is included in 1 curated skill list.

Related skills

Accessibility

294k

affaan-m/ECC

WCAG 2.2 レベル AA 標準を用いてインクルーシブなデジタルプロダクトを設計・実装・監査します。Web 用のセマンティック ARIA および Web・ネイティブプラットフォーム(iOS/Android)のアクセシビリティトレイトを生成するために使用します。

Frontend & DesignIn 1 list43k

Agent Architecture Audit

294k

affaan-m/ECC

エージェントおよび LLM アプリケーション向けのフルスタック診断。12 層のエージェントスタックにおけるラッパーリグレッション、メモリ汚染、ツール規律の失敗、隠れた修復ループ、レンダリング破損を監査します。重要度順の発見事項とコードファーストの修正を生成します。エージェントアプリケーション、自律ループ、または LLM を活用した機能を構築する開発者に必須です。

AI, LLMs & AgentsIn 1 list43k

Agent Eval

294k

affaan-m/ECC

カスタムタスクでコーディングエージェント(Claude Code、Aider、Codex など)をヘッドツーヘッドで比較し、合格率、コスト、時間、一貫性のメトリクスを測定します

AI, LLMs & AgentsIn 1 list43k

Crosspost

294k

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

Writing & ContentIn 1 list43k

Content Hash Cache Pattern

294k

affaan-m/ECC

Cache expensive file processing results using SHA-256 content hashes — path-independent, auto-invalidating, with service layer separation.

Writing & ContentIn 1 list43k

Crosspost

294k

affaan-m/ECC

X、LinkedIn、Threads、Bluesky間のマルチプラットフォームコンテンツ配布。content-engineパターンを使用してプラットフォームごとにコンテンツを適応します。同一コンテンツをクロスプラットフォームで投稿することはありません。コンテンツをソーシャルプラットフォーム間で配布したい場合に使用します。

Writing & ContentIn 1 list43k

Browse the most popular Claude skills, all writing & content skills, or write your own with the skills generator.