agentleFS
PradnyeshpPradnyeshp/Claude-Skills/.claude/skills/cache/SKILL.md

cache

Skill2 starsChanged 4 months agoMITView on GitHub

Add a caching layer to an expensive function, query, or endpoint — in-memory, Redis, or HTTP — with correct keys, TTL, and invalidation. Use when the user says "add caching", "cache this result", "memoize this", "cache the API response", "add a Redis cache", or "this is recomputed too often".

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Add caching for the target in $ARGUMENTS.

    line 15
  2. Distinctive:

    After adding, summarize what's cached, the key, the TTL/invalidation, the layer, and the staleness trade-off.

    line 34

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Caching infrastructure signals

!grep -rilE "redis|ioredis|memcached|node-cache|lru-cache|functools\\.lru_cache|cachetools|@cache" --include='*.*' package.json pyproject.toml 2>/dev/null | grep -vE 'node_modules|\.git' | head -8

Instructions

Add caching for the target in $ARGUMENTS. If it's unclear what's expensive or how fresh the data must be, ask before adding a cache — a wrong TTL or key serves stale or leaked data. Reuse the project's existing cache client/library.

Method

  1. Confirm it's worth caching. Caching fits expensive, frequently-repeated, read-heavy work whose inputs repeat and whose result tolerates some staleness. If the data must be exact and real-time, or writes dominate, say caching is the wrong tool here.
  2. Pick the layer for the need, preferring infra the project already has:
    • In-process (memoization, lru-cache, functools.lru_cache) — single instance, small/hot data, fine to lose on restart.
    • Shared (Redis/Memcached) — multi-instance, larger data, must be consistent across processes.
    • HTTP (Cache-Control/ETag) — cacheable GET responses, push caching to client/CDN.
  3. Build a correct key. Include every input the result depends on — args, the user/tenant for per-user data, locale, version. A key that omits an input serves one caller's data to another (a real security bug for per-user responses). Namespace keys to avoid collisions.
  4. Set TTL and invalidation deliberately. Choose a TTL from how stale the data may acceptably be. Where correctness matters, invalidate or update the entry on the write that changes the underlying data (write-through / explicit delete on mutation) rather than relying on TTL alone. State the staleness window you're accepting.
  5. Handle the edges: cache misses and cache-store failures must fall back to the source (fail open — a down cache shouldn't take down the feature); avoid caching errors/empties unintentionally; and be aware of stampedes on hot keys (consider a lock/single-flight for very hot entries).

Rules

  1. Key on every input the value depends on — especially user/tenant for per-user data. A missing key dimension serves wrong or another user's data; treat that as a correctness/security risk, not a tuning detail.
  2. Have an invalidation story, not just a TTL, whenever a write can change the cached value — and state the accepted staleness window.
  3. Reuse the project's cache client/config; use a shared store when the app runs multiple instances rather than a per-process cache that fragments.
  4. Fail open on cache-store errors and on misses — fall back to recomputation; never let the cache layer become a new single point of failure. Don't change the function's observable result, only its speed/freshness.
  5. After adding, summarize what's cached, the key, the TTL/invalidation, the layer, and the staleness trade-off.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.