content-hash-cache-pattern

Cache file processing results using SHA-256 content hashes.

1|Updated Mar 10, 2026
One-click install
npx skills add https://github.com/aleonsa/claude-config --skill content-hash-cache-pattern-aleonsa
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: content-hash-cache-pattern
Source: https://github.com/aleonsa/claude-config/tree/main/claude/skills/content-hash-cache-pattern
Command: npx skills add https://github.com/aleonsa/claude-config --skill content-hash-cache-pattern-aleonsa

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill solves the problem of inefficient file processing by caching results based on file content, ensuring that expensive operations are only performed once per unique file content, regardless of its location or name.

Core Features & Use Cases

  • Content-Based Caching: Uses SHA-256 hashes of file content as cache keys, making the cache resilient to file renames or moves.
  • Automatic Invalidation: Cache entries are automatically invalidated when the file content changes.
  • Service Layer Separation: Keeps expensive processing functions pure by encapsulating caching logic in a separate service layer.
  • Use Case: When processing a large batch of documents (e.g., PDFs, images) where the same documents might appear multiple times under different names or in different directories, this pattern ensures each document's processing result is computed only once.

Quick Start

Use the content-hash-cache-pattern skill to extract text from the file located at '/path/to/document.pdf' and enable caching.

Frequently Asked Questions about content-hash-cache-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I cache file processing results based on content instead of file path?

Use a content-hash caching pattern to generate SHA-256 hashes of file contents as cache keys. This ensures expensive processing results are reused regardless of file renames or directory moves, automatically invalidating when content changes.

What is the best way to avoid reprocessing duplicate files in a large batch of documents?

Content-hash caching computes a SHA-256 hash for each file to create path-independent cache keys. Duplicate documents appearing multiple times under different names or paths are processed only once, optimizing batch performance.

How does automatic cache invalidation work when file contents change?

Automatic cache invalidation works by hashing file contents with SHA-256 to generate the cache key. When a file's content is modified, its hash changes, bypassing the cache and triggering the expensive processing task to run again.

Does content-hash caching require separating the caching logic from the core processing function?

Yes, content-hash caching encapsulates the caching logic in a separate service layer. This separation keeps your expensive core processing functions pure and free of caching dependencies, maintaining clean code architecture.

When should I use a content-based cache instead of a path-based cache for file processing?

Use content-based caching when processing large batches of documents where identical files might appear under different names or in different directories. Path-based caches fail on renames, whereas SHA-256 content hashing ensures idempotency.