Guide · Agent skill
How to use the Content-Hash File Cache agent skill
Updated · written with AI from the project's own documentation and checked against our catalogue data
The content-hash-cache-pattern skill teaches an agent to cache the results of slow file-processing work, such as PDF parsing, text extraction, or image analysis, using a SHA-256 hash of each file's contents as the cache key. It is aimed at developers building file ingestion pipelines or batch jobs where the same files come up again and again. After this guide you will know what the skill does, how to install it, how to ask the agent to use it, and when it is the wrong choice.
Quick start
- 1Download the ZIP. Download the skill ZIP from this page. It contains SKILL.md.
- 2Unzip into a skills folder. Unzip it into ~/.claude/skills/ for personal use or into a project's .claude/skills/ folder for one project.
- 3Or upload in the Claude apps. In the Claude apps, go to Settings → Capabilities → Skills and upload the skill.
- 4Describe your file pipeline. Ask for caching in plain language, naming the slow processing function and the file types involved.
- 5Review the generated wrapper. Confirm the original processing function is unchanged and the cache lives in a separate wrapper layer.
- 6Run and check the logs. Run your job twice on the same files and confirm the second run logs cache hits.
What the skill makes the agent do
Agent skills are instruction packages that an AI agent loads when a request matches them. This skill gives the agent a specific design pattern rather than a tool that runs on its own. When you ask for caching around file processing, the agent is guided to hash the file's contents, check a cache directory for a stored result under that hash, and only run the expensive processing when no result exists.
Because the key is the content hash rather than the file path, a renamed or moved file still gets a cache hit, and a file whose contents change gets a new hash and fresh results automatically. The skill also tells the agent to keep the original processing functions unchanged and put the cache in a separate wrapper layer.
- Computes a SHA-256 hash of file contents, reading in 64 KB chunks for large files
- Stores each result as {hash}.json in a cache directory, with no index file
- Wraps existing processing functions in a service-layer function instead of editing them
- Treats a corrupted cache entry as a cache miss so processing runs again
- Logs cache hits and misses with a shortened hash for debugging
Install the skill
Download the ZIP file from this page. The skill is distributed as a folder containing SKILL.md. Unzip it into one of the following locations, depending on how you want to use it.
For all your projects, unzip it into ~/.claude/skills/. To limit it to a single project, unzip it into that project's .claude/skills/ folder. In the Claude apps you can instead upload the skill under Settings → Capabilities → Skills.
- Personal: ~/.claude/skills/
- Project only: .claude/skills/ inside your project folder
- Claude apps: Settings → Capabilities → Skills, then upload
Trigger the skill with natural requests
You do not need to type a special command. Describe the work in plain language that mentions files being processed repeatedly, slow processing, or a cache option. The skill's own trigger conditions cover building file pipelines for PDFs, images and text extraction, adding a --cache/--no-cache CLI option, and adding caching without changing existing pure functions.
Be specific about the code you want changed. Naming the processing function and the file types makes it easier for the agent to apply the pattern correctly.
- "My PDF parser re-reads the same invoices every night. Add content-hash caching around it."
- "Add a --cache/--no-cache flag to this CLI that runs OCR on images."
- "Wrap extract_text with a cache keyed on file contents, and don't touch extract_text itself."
Example: adding a cache to a batch job
Suppose your batch job calls extract_text on every file in a folder each run. Ask the agent to add a content-hash cache to the call site. The skill guides it to build a service-layer function that checks the cache first, calls the unchanged extraction function on a miss, and writes the result to the cache.
The core wrapper looks like this. It is taken from the skill's own example, so the agent works from the same structure:
def extract_with_cache(file_path: Path, *, cache_enabled: bool = True, cache_dir: Path = Path(".cache")) -> ExtractedDocument:
if not cache_enabled:
return extract_text(file_path)
file_hash = compute_file_hash(file_path)
cached = read_cache(cache_dir, file_hash)
if cached is not None:
return cached.document
doc = extract_text(file_path)
write_cache(cache_dir, CacheEntry(file_hash=file_hash, source_path=str(file_path), document=doc))
return docWhat you need before you start
The skill needs Python. Its examples use the standard library modules hashlib, dataclasses, pathlib and json, so no extra packages are named in the source. You still need your own processing function, such as the PDF parser or OCR call you want to speed up, because the skill does not supply one.
The skill does not run scripts and does not use the network, according to its listing.
- Python environment for the project you are changing
- Your existing processing function (for example extract_text)
- A writable directory for the cache, such as .cache
Safety notes
The skill contains only a SKILL.md file with guidance and example code. Its listing states that it runs no scripts and uses no network access. The code it produces writes cache files to disk, so check the cache directory location before committing it to version control or running the job in a shared environment.
Review the code the agent writes as you would any change to your project, especially the cache directory path and any stored data that may be sensitive.
- Runs scripts: no
- Uses network: no
- Cache files are plain JSON on disk; choose a location you are comfortable with
Tips for getting good results
Keep the processing function pure. The skill's main design rule is that extraction should know nothing about caching, so ask the agent to leave the original function alone. Hash the file, not its path, so renames still hit the cache. If processing depends on settings such as extraction options, make sure those settings are part of what the cache key captures, because a content hash alone does not include them.
Plan for large outputs. The skill itself notes that very large cache entries may be better handled with streaming.
- Do not key the cache on file path alone
- Check that processing depends only on file contents before caching
- Ask the agent to log hits and misses so you can see the cache working
What people use it for
- Re-running a nightly PDF invoice parser that sees mostly the same files
- Adding a --cache/--no-cache option to a command-line OCR or text extraction tool
- Batch image analysis where the same images appear across several runs
- Ingestion pipelines that rename or move files but should not reprocess unchanged content
Frequently asked questions
Is the content-hash-cache-pattern skill free?
The skill is listed under the MIT licence. The source for this page does not mention pricing beyond that licence, so check the licence text in the repository for full terms.
What do I need to use this skill?
You need Python, since the examples use hashlib, dataclasses, pathlib and json. You also need an existing file-processing function to wrap, because the skill provides the caching pattern, not the processing itself.
Where do I install the content-hash-cache-pattern skill?
Unzip the downloaded ZIP into ~/.claude/skills/ for personal use or into a project's .claude/skills/ folder. In the Claude apps you can upload it under Settings → Capabilities → Skills.
Does the skill run scripts or access the internet?
According to its listing, it runs no scripts and uses no network. It consists of a SKILL.md file with guidance and example code.
When should I not use content-hash caching?
Avoid it for data that must always be current, such as real-time feeds, where cached results could be stale. Also avoid it when results depend on settings other than file contents, since the hash key would not capture them and could return wrong output.
How does this compare to caching by file path?
A path-based cache breaks when a file is moved or renamed. This skill hashes the file contents instead, so renames still hit the cache and changed content triggers fresh processing automatically.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
This skill is a good fit for developers building PDF, OCR, text extraction or image analysis pipelines, or adding a --cache option to a CLI, where the same files recur across batch runs. Skip it for real-time data, for results that depend on options beyond file contents, or where cached outputs would be very large.
Download the skill