Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add shennawardana23/skillme --skill content-hash-cache-patterngit clone --depth 1 https://github.com/shennawardana23/skillmeWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/shennawardana23/skillme/content-hash-cache-pattern)<a href="https://agentmods.dev/skills/shennawardana23/skillme/content-hash-cache-pattern"><img src="https://agentmods.dev/badge/skills/shennawardana23/skillme/content-hash-cache-pattern/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/shennawardana23/skillme/content-hash-cache-pattern"><img src="https://agentmods.dev/badge/skills/shennawardana23/skillme/content-hash-cache-pattern.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00089 | $0.01819 |
| Opus 5 | $0.00044 | $0.00910 |
| Sonnet 5 | $0.00018 | $0.00364 |
| Haiku 4.5 | $0.00009 | $0.00182 |
Grade A, and why
content-hash-cache-pattern scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 202 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Content-Hash File Cache Pattern
Cache expensive file-processing results using a SHA-256 hash of the file's content as the cache key. Unlike path-based caching, this survives file moves and renames, and auto-invalidates the moment content changes — no separate invalidation logic needed.
When to Activate
- Building a file-processing pipeline (PDF parsing, OCR, text extraction, image analysis) where the same files reappear across runs
- Processing cost is high enough that reprocessing unchanged files is wasteful
- Adding a
--cache/--no-cacheflag to a CLI tool - Retrofitting caching onto an existing pure function without modifying that function
Core Pattern (Go)
1. Content hash as the cache key
Hash the file in chunks — never load the whole file into memory:
package cache
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"io"
"os"
)
func ComputeFileHash(path string) (string, error) {
f, err := os.Open(path)
if err != nil {
return "", fmt.Errorf("open %s: %w", path, err)
}
defer f.Close()
h := sha256.New()
if _, err := io.Copy(h, f); err != nil {
return "", fmt.Errorf("hash %s: %w", path, err)
}
return hex.EncodeToString(h.Sum(nil)), nil
}
io.Copy streams the file into the hasher in fixed-size buffers, so this scales to large files without loading them fully into memory.
2. Cache entry type
type CacheEntry struct {
FileHash string `json:"file_hash"`
SourcePath string `json:"source_path"`
Document Document `json:"document"` // the cached result
}
3. File-based storage: {hash}.json
O(1) lookup by hash, no separate index file:
package cache
import (
"encoding/json"
"fmt"
"os"
"path/filepath"
)
func WriteEntry(cacheDir string, entry CacheEntry) error {
if err := os.MkdirAll(cacheDir, 0o755); err != nil {
return fmt.Errorf("create cache dir: %w", err)
}
data, err := json.Marshal(entry)
if err != nil {
return fmt.Errorf("marshal cache entry: %w", err)
}
path := filepath.Join(cacheDir, entry.FileHash+".json")
return os.WriteFile(path, data, 0o644)
}
// ReadEntry returns (entry, true) on a cache hit, (zero, false) on a
// miss — including a miss on corrupted or unreadable cache files, so
// corruption degrades to a re-process rather than a crash.
func ReadEntry(cacheDir, fileHash string) (CacheEntry, bool) {
path := filepath.Join(cacheDir, fileHash+".json")
data, err := os.ReadFile(path)
if err != nil {
return CacheEntry{}, false
}
var entry CacheEntry
if err := json.Unmarshal(data, &entry); err != nil {
return CacheEntry{}, false
}
return entry, true
}
What ships with it
1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 8d ago First seen · 202 lines · 89 tokens per session scan A 668b1e4dd656
content-hash-cache-pattern is a skill published in the GitHub repository shennawardana23/skillme (2 stars, last pushed 11d ago), licensed Apache-2.0. It adds 89 tokens to every session and 1,819 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
ai-model-wechat
A guide to calling AI text models from a WeChat Mini Program, a small app that runs inside WeChat, using CloudBase. It covers generated text and streamed responses, where text arrives piece by piece, through callback functions.
ai-model-nodejs
Use this skill for Node.js backend AI via @cloudbase/node-sdk (>=3.16.0) — cloud functions, CloudRun, Express, Koa, NestJS, serverless APIs, scheduled jobs, LLM proxies. Only SDK supporting image generation (ai.createImageModel + generateImage). Text models via ai.createModel with groups cloudbase, hunyuan-exp, or…
gemini-interactions-api
Guides the usage of Gemini Interactions API on Gemini Enterprise Agent Platform. Use when the user wants to use the stateful, server-managed Interactions API for multi-turn conversations, background execution, streaming, structured output, and function calling on the Agent Platform.
notebooklm
Install, authenticate, troubleshoot, and operate Gemini Notebook through the notebooklm-py CLI or typed async Python API. Use for notebook and source management, grounded chat and research, and artifact generation or download when the user mentions Gemini Notebook, notebooklm-py, the notebooklm CLI, or its Python API.…
gemini-live-api
Generates a Gemini LiveAPI client service class in the user's chosen programming language. Use when the user wants to build, scaffold, or integrate a client that connects to the Gemini Enterprise LiveAPI websocket endpoint, handles session setup/resumption, bearer token refresh, and sending/receiving…
gemini-api-dev
Use this skill when writing code that calls the Gemini API for text generation, multi-turn chat, multimodal understanding, image generation, video generation, streaming responses, background research tasks, function calling, structured output, or migrating from the old generateContent API. Covers SDK usage and best…