Content-Hash Cache Pattern

•
323
•

Optimizes file processing performance by using SHA-256 content hashing for robust, path-independent caching.

This skill implements a high-performance caching pattern for Claude Code that identifies files by their SHA-256 content hash rather than their file path. This approach ensures that moving or renaming a file does not invalidate the cache, while any modification to the file content triggers an automatic refresh. It is particularly useful for expensive operations like PDF parsing, OCR, and image analysis, providing a clean service-layer architecture that keeps your core processing functions pure and decoupled from caching logic.

Key Features

01SRP-compliant service layer wrapper for clean code architecture
02SHA-256 content-based hashing for path-independent cache hits
03Memory-efficient chunked reading for processing large files
04323 GitHub stars
05Automatic cache invalidation triggered by file content changes
06O(1) lookup performance using hash-named JSON storage files

Use Cases

01Implementing --cache/--no-cache flags in command-line utilities
02Caching results from expensive PDF text extraction or OCR tasks
03Speeding up data processing pipelines for recurring datasets