Agent skill · Content & Marketing

content-hash-cache-pattern

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

mturacgithub.com/mturacGitHub ↗
codexcopilotcursorMIT
Install
npx skills add mturac/everything-openai-codex --skill content-hash-cache-pattern --agent codex

Same command for any agent — swap --agent for claude-code, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 5 KB
Bundled scripts: none
Path: skills/content-hash-cache-pattern/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 84
Language: JavaScript

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# 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-cache` CLI 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: ```python 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() ``` **Why content hash?** File rename/move = cache hit. Content change = automatic invalidation. No index file ne

What's inside
Steps it walks through
  1. When to Activate
  2. Core Pattern
  3. 1. Content-Hash Based Cache Key
  4. 2. Frozen Dataclass for Cache Entry
  5. 3. File-Based Cache Storage
  6. 4. Service Layer Wrapper (SRP)
  7. Key Design Decisions
  8. Best Practices
  9. Anti-Patterns to Avoid
  10. When to Use
  11. When NOT to Use
More from everything-openai-codex
All skills →
About this skill
What does the content-hash-cache-pattern skill do?

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

How do I install it?

Run `npx skills add mturac/everything-openai-codex --skill content-hash-cache-pattern --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From mturac/everything-openai-codex, a repository with 84 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going