Content Hash Cache Pattern
Caches expensive file-processing results keyed by SHA-256 content hash rather than file path.
- CCM score
- 77 of 100
- skills.sh installs
- 12.1K
- GitHub stars
- 312.6K
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers a service-layer pattern for caching PDF parsing, text extraction, and image analysis results
- Includes
compute_file_hash, a frozenCacheEntrydataclass, and{hash}.jsonstorage with corruption handled as a miss - Enforces separation of concerns so processing functions stay pure and know nothing about caching
- Designed for batch pipelines and CLI tools with
--cache/--no-cacheoptions, not real-time or parameter-dependent results
Install
$ npx -y skills add affaan-m/ecc --skill content-hash-cache-pattern -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Content-Hash File Cache Pattern
Cache expensive file processing results (PDF parsing, text extraction, image analysis) using SHA-256 content hashes as cache keys. Unlike path-based caching, this approach survives file moves/renames and auto-invalidates when content changes.
When to Activate
- Building file processing pipelines (PDF, images, text extraction)
- Processing cost is high and same files are processed repeatedly
- Need a
--cache/--no-cacheCLI option - Want to add caching to existing pure functions without modifying them
Core Pattern
1. Content-Hash Based Cache Key
Use file content (not path) as the cache key:
import hashlib
from pathlib import Path
_HASH_CHUNK_SIZE = 65536 # 64KB chunks for large files
def compute_file_hash(path: Path) -> str:
"""SHA-256 of file contents (chunked for large files)."""
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()
Details
- Repository
- github.com/affaan-m/ecc
- Category
- Python
- First seen
- Jul 14, 2026
Questions
What does the content-hash-cache-pattern skill do?
It caches expensive file processing results such as PDF parsing, text extraction and image analysis, using SHA-256 hashes of file contents as cache keys. Because the key is the content rather than the path, cached results survive file moves and renames and invalidate automatically when content changes.
How do I install the content-hash-cache-pattern skill?
Run npx -y skills add affaan-m/ecc --skill content-hash-cache-pattern -y in your project. This lets the agent apply the hash-based caching pattern when you build file processing pipelines.
Where does content-hash-cache-pattern rank among Python skills?
It ranks in the top 25 on the Python category page of Claude Marketplaces. Other skills in that category include python-performance-optimization, python-design-patterns, async-python-patterns, python-code-style and uv-package-manager.
When should I use this caching skill instead of path-based caching?
Use it when repeated file processing is slow and the same files reappear across runs, or when you want a --cache/--no-cache CLI option. It keeps the processing function pure by wrapping it in a service layer, and it is not suited to data that must always be fresh.
More from affaan-m/ecc
All 257- Kotlin Testing12.1K
- Ai Regression Testing12.1K
- Browser Qa12.1K
- Design System12.1K
- Jira Integration12K
- Investor Outreach12K
- Documentation Lookup12K
- Remotion Video Creation12K
- Swift Actor Persistence12K
- Swift Protocol Di Testing12K
- Blueprint12K
- Git Workflow11.9K
- Foundation Models On Device11.9K
- Exa Search11.9K
- Swift Concurrency 6 211.9K
- Nestjs Patterns11.9K
- Data Scraper Agent11.9K
- Hexagonal Architecture11.9K
- Mcp Server Patterns11.9K
- Plankton Code Quality11.9K
- Fal Ai Media11.8K
- Visa Doc Translate11.8K
- Inventory Demand Planning11.8K
- Customs Trade Compliance11.8K
Similar to Content Hash Cache Pattern
More PythonHex LineMCP serverlevnikolaevich598 starsHash-verified file editing for AI coding agents, with a token-efficiency hook included.
caching-strategy-optimizerSkillpatricio0312rev/skills274 installsGuide for speeding up CI pipelines with cache keys for dependencies, Docker layers, build outputs, and tests.
file-uploadsSkillsickn33/agentic-awesome-skills740 installsExpert file upload handling for S3, R2, presigned URLs, multipart uploads, and image optimization.
doc-pipelineSkillclaude-office-skills/skills4.8K installsChains document operations into reusable pipelines where each stage's output feeds the next.