caching

caching is a skill for Claude Code, Codex from zebbern/claude-code-guide. It costs 32 tokens per session (1,584 once invoked), scanned A, original, MIT.

Guidance for designing and reviewing caches, which store reusable data so software can retrieve it faster. It covers cache expiration, cache keys, invalidation, cache layers, and cases where caching should be avoided.

In plain words
What is it for?
Use it when adding or reviewing in-memory, Redis, CDN, or TanStack Query caching, including TTL choices and update or delete flows.
Why use it?
It reduces stale-data bugs, conflicting cache entries, and sudden load caused when many requests refresh the same data.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when adding or reviewing in-memory, Redis, CDN, or TanStack Query caching, including TTL choices and update or delete flows.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/zebbern/claude-code-guide/caching
About the project

Claude Code Guide is a reference collection for configuring and using Claude Code, Anthropic’s command-line coding agent. Developers use it to learn commands, skills, agents, MCP, automation, security, integrations, and troubleshooting. Its catalogue add-ons provide many of the documented skills and agents.

zebbern/claude-code-guide · 4,664 stars · on GitHub

Install

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.

Any agent
npx skills add zebbern/claude-code-guide --skill caching
Clone the repo
git clone --depth 1 https://github.com/zebbern/claude-code-guide

Made for: Claude Code, Codex.

Wrote 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.

agentmods badge for caching

README.md
[![agentmods](https://agentmods.dev/badge/skills/zebbern/claude-code-guide/caching/github.svg)](https://agentmods.dev/skills/zebbern/claude-code-guide/caching)
Your own site
<a href="https://agentmods.dev/skills/zebbern/claude-code-guide/caching"><img src="https://agentmods.dev/badge/skills/zebbern/claude-code-guide/caching/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.

agentmods 80×15 button for caching

Your own site · 80×15
<a href="https://agentmods.dev/skills/zebbern/claude-code-guide/caching"><img src="https://agentmods.dev/badge/skills/zebbern/claude-code-guide/caching.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,584 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00032 $0.01584
Opus 5.5 $0.00013 $0.00634
Sonnet 5.5 $0.00006 $0.00317
Haiku 4.5 $0.00003 $0.00158

Measured 1mo ago against content hash 0d4edff8dcc7, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

caching 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 1mo 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.

skills/caching/SKILL.md · 163 lines

How it starts

The opening of the file, as written. The whole thing — 163 lines — stays where its author put it; the contents beside it link to each section on GitHub.

WHEN_TO_USE

  • When implementing a cache layer (in-memory, Redis, CDN) for an API or service.
  • When choosing TTL values or invalidation strategies for cached data.
  • When designing cache key schemas to avoid collisions or stale-data bugs.
  • When reviewing code that reads from or writes to any cache.
  • When debugging stale data, cache stampedes, or inconsistent responses.
  • When configuring TanStack Query staleTime/gcTime for client-side caching.

INVALIDATION

  • [P0-MUST] Define an invalidation strategy for every cache. Stale data is worse than no cache.
  • [P0-MUST] Invalidate caches when the underlying data changes — do not rely solely on TTL expiry.
  • [P1-SHOULD] Prefer event-driven invalidation (on write/update/delete) over time-based expiry alone.
  • [P1-SHOULD] Use cache versioning (include a version key) when data schemas change.

TTL_GUIDELINES

  • [P1-SHOULD] Set TTLs based on data volatility: static config (hours/days), user profiles (minutes), real-time data (seconds or no cache).
  • [P1-SHOULD] Use stale-while-revalidate: serve stale data immediately while refreshing in the background.
  • [P2-MAY] Use shorter TTLs in development and longer TTLs in production.

CACHE_KEYS

  • [P0-MUST] Include all query parameters that affect the result in the cache key.
  • [P1-SHOULD] Use a consistent key format: <entity>:<id>:<variant> (e.g., user:123:profile, products:list:page=2).
  • [P1-SHOULD] Namespace keys by service or module to prevent collisions.
  • [P2-MAY] Hash long or complex keys to keep storage efficient.

CACHE_LAYERS

  • [P1-SHOULD] Use the appropriate cache layer for the use case:
Layer Best For TTL Range
In-memory (Map, LRU) Hot data, single-instance apps Seconds to minutes
Redis / Memcached Shared cache across instances, sessions Minutes to hours
CDN / Edge Static assets, public API responses Hours to days
HTTP cache headers Browser caching, API responses Varies by resource

Read the full file on GitHub · 163 lines

Changes

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.

  1. 1mo ago First seen · 163 lines · 32 tokens per session scan A 0d4edff8dcc7

Subscribe to this mod's changes

caching is a skill published in the GitHub repository zebbern/claude-code-guide (4,664 stars, last pushed yesterday), licensed MIT. It adds 32 tokens to every session and 1,584 once invoked, about $0.0001 per session on Opus 5.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-30.