shadow-cache
Skill1 starsChanged yesterdayMITView on GitHub
Client & Server Caching Architecture. Use when implementing or debugging TanStack Query/SWR invalidation, Redis caching, cache stampede protection, optimistic UI updates, or Idempotency-Key patterns.
In this repository51 other files it gives its agents.
- antislop-codeSkill
- antislop-copywritingSkill
- antislop-humanSkill
- antislop-layoutmobileSkill
- antislopSkill
- antislop-uiSkill
- context7Skill
- handoffSkill
- shadow-accessibilitySkill
- shadow-apiSkill
- shadow-architectSkill
- shadow-authSkill
- shadow-bootstrapSkill
- shadow-browserSkill
- shadow-compatSkill
- shadow-concurrencySkill
- shadow-dataSkill
- shadow-dbSkill
- shadow-debugSkill
- shadow-designSkill
- shadow-discoverySkill
- shadow-docSkill
- shadow-domainSkill
- shadow-eaSkill
- shadow-evalSkill
- shadow-finopsSkill
- shadow-gitSkill
- shadow-grcSkill
- shadow-handoverSkill
- shadow-integrateSkill
- shadow-maintainSkill
- shadow-mobileSkill
- shadow-modernizeSkill
- shadow-monarchSkill
- shadow-observeSkill
- shadow-opsSkill
- shadow-perfSkill
- shadow-planSkill
- shadow-pmoSkill
- shadow-presalesSkill
- shadow-privacySkill
- shadow-qualitySkill
- shadow-realtimeSkill
- shadow-refactorSkill
- shadow-releaseSkill
- shadow-resilienceSkill
- shadow-searchSkill
- shadow-secSkill
- shadow-supplychainSkill
- shadow-testSkill
- shadow-uatSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 1 is distinctive, and 6 are 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.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Use this skill when designing or debugging data fetching, caching layers (TanStack Query, SWR, Redis, HTTP Cache-Control), cache …
- Distinctive: line 15
Never scatter ad-hoc string arrays across components.
- Very specific: line 26
Every useMutation (POST, PUT, PATCH, DELETE) MUST invalidate affected list and detail keys in onSuccess (or roll back cleanly in onError …
- Very specific: line 28
Keep Zustand/Context strictly for true client UI state (sidebar open, theme, multi-step wizard draft).
- Very specific: line 38
Every cached key (except explicit persistent queues/locks) MUST have a TTL (EX).
- Very specific: line 42
When an ID lookup misses in the DB, cache a short-lived sentinel ("__NULL__" with EX 30) to protect the database against repeated lookups …
- Very specific: line 51
If a duplicate request arrives while "PROCESSING", return 409 Conflict.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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.
Files
Shadow Cache (/shadow-cache) — Client/Server Caching, Invalidation & Realtime Sync
Use this skill when designing or debugging data fetching, caching layers (TanStack Query, SWR, Redis, HTTP Cache-Control), cache invalidation, optimistic UI updates, or request idempotency.
1. Client-Side Server-State Management (TanStack Query / SWR)
- Structured Query Keys Factory:
- Never scatter ad-hoc string arrays across components. Define a typed query-key factory per domain:
export const orderKeys = { all: ['orders'] as const, lists: () => [...orderKeys.all, 'list'] as const, list: (filters: OrderFilterDto) => [...orderKeys.lists(), filters] as const, details: () => [...orderKeys.all, 'detail'] as const, detail: (id: string) => [...orderKeys.details(), id] as const, };
- Never scatter ad-hoc string arrays across components. Define a typed query-key factory per domain:
- Deterministic Mutation Invalidation:
- Every
useMutation(POST,PUT,PATCH,DELETE) MUST invalidate affected list and detail keys inonSuccess(or roll back cleanly inonErrorwhen using optimistic updates).
- Every
- Never Duplicate Server State in Global Client Stores (
Zustand/Redux):- Keep
Zustand/Contextstrictly for true client UI state (sidebar open, theme, multi-step wizard draft); letTanStack Queryown API responses, caching, background refetching, and pagination.
- Keep
2. Server-Side Redis & HTTP Caching Patterns
- Key Naming & Tenant Isolation:
- Prefix every Redis key with environment, tenant, domain, and schema version:
prod:tenant_42:user_profile:v1:user_99. - Never cache tenant-specific data under a global key without
tenant_idoruser_id!
- Prefix every Redis key with environment, tenant, domain, and schema version:
- Explicit TTL + Jitter (Anti-Cache-Avalanche):
- Every cached key (except explicit persistent queues/locks) MUST have a
TTL(EX). Add random jitter ($\pm 10%$) to TTLs on bulk-warmed keys so thousands of keys do not expire at the exact same second.
- Every cached key (except explicit persistent queues/locks) MUST have a
- Cache Stampede / Thundering Herd Protection:
- For expensive aggregation/dashboard queries, use single-flight locking (mutex lock or stale-while-revalidate) so 200 concurrent requests on a cache miss trigger only 1 database query instead of 200.
- Negative Caching:
- When an ID lookup misses in the DB, cache a short-lived sentinel (
"__NULL__"withEX 30) to protect the database against repeated lookups for non-existent IDs.
- When an ID lookup misses in the DB, cache a short-lived sentinel (
3. Idempotency Keys for State-Mutating Endpoints (Idempotency-Key)
For payment, order creation, approval, or webhook endpoints:
- Accept an
Idempotency-Keyheader (or deterministic event ID). - Store
{ status: "PROCESSING" | "COMPLETED", statusCode, responseBody }in Redis/DB with a 24-hour TTL using atomicSET NX/ unique constraint. - If a duplicate request arrives while
"PROCESSING", return409 Conflict; if"COMPLETED", return the stored response without re-executing the business transaction.
- Coherency Boundaries & Multi-Tier Invalidation:
- Separate public catalog caches from tenant/user-authorized keys (
user_id/tenant_idin cache key mandatory to prevent cross-user leakage). - Define exact invalidation triggers across CDN/edge, Redis, and client
TanStack Querycaches so stale authorization or balance views never persist past security/mutation events.
- Separate public catalog caches from tenant/user-authorized keys (
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
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.

