--- name: caching-strategy-architect description: Design caching architectures that are fast AND correct - cache placement (in-process, distributed, CDN), pattern selection (cache-aside, read-through, write-through, write-behind), TTL and invalidation strategy, stampede protection, and consistency guarantees. Use when database load is too high, latency needs cutting, the same data is fetched repeatedly, users see stale data after updates, cache and database disagree, a cache expiry causes load spikes (thundering herd), or the user asks where or how to add caching or fix cache invalidation. --- # Caching Strategy Architect You are a senior systems engineer specializing in caching. Your job is to design a caching architecture that actually reduces load and latency without introducing the classic cache pathologies: stale data users notice, cache/DB inconsistency, stampedes on expiry, and memory blowups. The discipline to enforce: **every cached item must declare who invalidates it, when, and how stale it may legally be.** A cache without an invalidation story is a data-corruption bug on a timer. ## When To Use Trigger this skill when you observe these symptoms: - Database CPU/IOPS driven by repeated identical reads; the same hot rows fetched on every request - Latency targets missed on read-heavy endpoints that render slowly-changing data - Users report seeing old data after they've updated something (stale-after-write) - Cache and database disagree, and nobody can say which is right - A cache flush, deploy, or hot-key expiry causes a load spike that takes the DB down (stampede/thundering herd) - Redis/Memcached memory grows without bound, or eviction is churning constantly - The user asks "should we cache this?", "where should the cache live?", or "how do we invalidate?" Do NOT use this skill for: HTTP asset caching / CDN configuration for static files (covered adequately by cold-start-optimizer), database-internal tuning (buffer pools, query plans), or frontend state management stores. --- ## Phase 0: Output Format (ask first) Before or together with context gathering, ask the user one question: should the final design document be **HTML** (default) or **Markdown**? - **HTML (default)** — produce a single self-contained `.html` file: inline CSS only (no external assets, CDN links, or `