content-hash-cache-pattern

Cache file processing results using SHA-256 content hashes as keys.

2|Updated Mar 3, 2026
One-click install
npx skills add https://github.com/MomoDaviluke/star-citizen-promotion --skill content-hash-cache-pattern-momodaviluke
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: content-hash-cache-pattern
Source: https://github.com/MomoDaviluke/star-citizen-promotion/tree/main/.agents/skills/ecc/content-hash-cache-pattern
Command: npx skills add https://github.com/MomoDaviluke/star-citizen-promotion --skill content-hash-cache-pattern-momodaviluke

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Cache expensive file processing results using SHA-256 content hashes as cache keys, achieving path-independence and automatic invalidation when content changes.

Core Features & Use Cases

  • Content-hash based cache keys that survive file moves/renames.
  • Service-layer separation: the cache is a separate concern from the processing function.
  • Safe, lazy storage with graceful handling of misses and corruption.

Quick Start

Run the content-hash cache wrapper on input files to obtain cached results.

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 using a content hash?

You can cache file processing results using a SHA-256 content hash as the cache key, storing outputs as disk-based JSON. This provides path-independence and automatically invalidates the cache when file content changes.

Why does my file processing cache break when files are moved or renamed?

Path-based cache keys break on file moves because they rely on file location. Using a SHA-256 content hash as the cache key instead ensures your cache survives file renames and directory changes while automatically invalidating on content modifications.

What is the best way to cache OCR and text extraction results across batch runs?

The best way to cache OCR and text extraction results across recurring batch runs is wrapping your processing pipeline in a service layer that uses SHA-256 content hashes as cache keys with disk-based JSON storage for persistent retrieval.

Does content-hash caching work with PDF parsing pipelines?

Yes, content-hash caching works with PDF parsing pipelines by applying a SHA-256 hash cache key wrapper to input files. This safely caches expensive parsing results and gracefully handles cache misses or storage corruption.

How do I keep file processing logic pure when adding a caching layer?

You keep file processing logic pure by using a service-layer wrapper that separates the cache as a distinct concern. This wrapper manages disk-based JSON storage and hash generation while leaving your core processing function untouched.

What happens when a content-hash cache miss or file corruption occurs?

During a content-hash cache miss or file corruption, the service-layer wrapper provides safe, lazy storage with graceful handling. It falls back to re-running the expensive file processing operation and regenerating the cached result.