In short.
Content-Hash File Cache Pattern is an assistant skill for developers building file-processing pipelines, but its content-only keys are unsuitable when settings or other inputs affect the result. It describes a disk cache that reuses results for identical file bytes and creates a different key when those bytes change. Caching sits around the processing function, keeping the two responsibilities separate. Application-specific extraction, serialization and CLI integration remain necessary. Execution results, compatibility guarantees and measured savings are not provided.
Researched and written by an AI model and checked by a second AI model. How it works
The covered scope is .kiro/skills/content-hash-cache-pattern in affaan-m/ECC at revision 8abdf329ecbc9315dc4e3334a5702782f70b8b02. The supplied manifest identifies SKILL.md as the complete selected-folder material and includes the repository-root LICENSE as a related notice outside that folder. Other ECC resources and downstream application implementations are outside this scope. No code was executed; runtime correctness, performance, assistant compatibility and concurrent behavior remain unassessed.
The overview
Identity
The resource is the content-hash-cache-pattern skill from affaan-m/ECC, located at .kiro/skills/content-hash-cache-pattern/SKILL.md. Its front matter identifies ECC as its origin.
It provides instructions and Python fragments for adding persistent caching to file processing, including PDF parsing, OCR, text extraction and image analysis. Implementations of those processors are left to the application.
Assessment
The design fits repeated processing of identical files when extraction is expensive compared with reading and hashing the input. Its main benefit is that reuse follows the bytes rather than the file's location.
The examples provide a concrete integration pattern, but adoption requires completing application-specific functions and addressing operational requirements. No complete application, execution results or benchmarks are supplied.
Users
The intended users are developers building batch processors, document pipelines or CLI tools that encounter the same files across runs. It also suits teams adding caching around an existing processing function.
Beginners will need familiarity with Python functions, dataclasses, paths and JSON. Experienced developers can use the wrapper as a starting point, while deciding how configuration, processor changes and concurrent access should affect cache behavior.
Capabilities
The examples compute SHA-256 incrementally, represent cache entries with a frozen dataclass, store one JSON file per hash and retrieve entries without maintaining a separate index.
The wrapper supports enabling or bypassing caching and logs hits and misses with shortened hashes. The document discusses --cache/--no-cache CLI options, but does not implement argument parsing.
Using it
Requirements
The illustrated implementation needs a Python application, readable input files and a writable cache directory. Its hashing, path handling, dataclass and JSON operations use Python standard-library modules.
The application must provide ExtractedDocument, extract_text, serialize_entry, deserialize_entry and logger. The examples use dataclass slots and union type annotations, but no supported Python version or assistant-host version is declared.
Mechanism
With caching enabled, the wrapper reads the input in 65,536-byte chunks to calculate its SHA-256 hash. It uses that hash to look for {hash}.json in the cache directory. A hit returns the saved document; a miss processes the file and stores the hash, source path and document.
Changing the bytes produces a different key on the next request. Moving or renaming identical bytes preserves the key when the same cache directory is used. Disabling caching calls the processor directly, bypassing hashing and cache access.
Setup
To adapt the examples, define the document type and processor, implement serialization and deserialization, provide a logger and choose a cache directory. Keep the caching wrapper separate from the processing function.
If a CLI needs cache controls, connect its options to cache_enabled. The shown default directory is .cache, created on the first write. Assistant installation commands and automatic skill-discovery behavior are not documented.
Example
As an illustrative walkthrough, a first request for a PDF with no matching entry would calculate its hash, extract its text and save the result. A later request after renaming that PDF would find the same entry if its bytes and cache directory were unchanged.
Editing the PDF's bytes would lead to a different key and another extraction. Changing only an extraction setting would leave the file hash unchanged, so this key design would need extending before it could distinguish those results. These are deductions from the snippets; no execution results are supplied.
Assessment & evidence
Limitations
File bytes are the only cache-key input. Configuration changes or processor upgrades that alter output would therefore need additional key information or explicit invalidation. Previous entries are not deleted when content changes, and no eviction or schema-versioning mechanism is shown.
The reader treats JSON decoding errors, ValueError and KeyError as misses, but does not catch filesystem errors. Writes go directly to the destination file; atomic replacement and locking are not shown. Concurrent access and interrupted writes remain unassessed.
Hashing is chunked, but cached JSON is read as a complete text value. The document advises against using the pattern for extremely large entries or results requiring freshness beyond file-content changes.
Reasoning
The design follows from treating identical bytes as interchangeable processing inputs. That makes file moves irrelevant to cache identity and lets content changes produce new keys without maintaining a path index.
Correct reuse also requires interchangeable outputs. If a result depends on settings, processor versions or the current filename, the file hash alone is insufficient. Keeping source_path in the saved entry does not make it part of the key. The performance benefit depends on avoided processing outweighing hashing, JSON handling and storage overhead.
Alternatives
The supplied wrapper includes an uncached route for processing without reuse. The document also contrasts its approach with path-based caching, which ties reuse to a file's location, and suggests considering streaming for very large results.
For settings-dependent output, a possible adaptation is a composite key containing the content hash plus relevant configuration and processor-version information. That extension is not implemented in the supplied examples, and no comparative benchmarks are provided.
Evidence
The resource text is available at its pinned original-source address: [https://raw.githubusercontent.com/affaan-m/ECC/8abdf329ecbc9315dc4e3334a5702782f70b8b02/.kiro/skills/content-hash-cache-pattern/SKILL.md]. It contains the instructions and Python fragments supporting the behavior described here.
The accompanying rights notice is available at [https://raw.githubusercontent.com/affaan-m/ECC/8abdf329ecbc9315dc4e3334a5702782f70b8b02/LICENSE]. The supplied material contains no execution logs, benchmark data or complete downstream processor implementation.
Access & freshness
Costs
Operational cost and savings are unknown. The resource provides no timing measurements, storage estimates or processing-cost figures.
The shown cache performs local hashing and file operations without calling a paid service. Actual costs depend on input sizes, repeat frequency, saved-result sizes and the processor supplied by the application. A cache hit still requires reading and hashing the entire input.
Rights
The captured repository-root LICENSE is the MIT License, with copyright attributed to Affaan Mustafa in 2026. It permits use, copying, modification, distribution, sublicensing and sale.
Copies or substantial portions must retain the copyright and permission notices. The licence also disclaims warranties and liability.
Freshness
The supplied snapshot was captured on 2026-11-17 at 04:27:29.728 UTC and is pinned to Git revision 8abdf329ecbc9315dc4e3334a5702782f70b8b02. These findings describe that revision.
Whether later revisions change the skill is unknown. The document does not establish current assistant compatibility or provide a supported runtime matrix.
Actions
Before adopting the pattern, identify every input that can change the processing result and decide whether the key must include more than file bytes. Complete the missing processor and serialization functions.
Validate serialization round trips, reuse after renaming, misses after content changes, disabled-cache behavior and malformed-entry recovery. If the application needs concurrent processing or long-term caching, add appropriate write coordination and retention handling. Measure the actual workload before relying on savings.
