Claude-skill-registry caching
Enforces project caching conventions when implementing cache layers using React cache(), Next.js unstable_cache, Upstash Redis, and Cloudinary. This skill ensures consistent patterns for cache keys, tags, TTL configuration, cache invalidation, and domain-specific CacheService helpers.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/caching" ~/.claude/skills/majiayu000-claude-skill-registry-caching && rm -rf "$T"
manifest:
skills/data/caching/SKILL.mdtags
source content
Caching Skill
Purpose
This skill enforces the project caching conventions automatically during cache implementation. It ensures consistent patterns across the 4-layer caching strategy:
- React
- Same-request deduplication (e.g.,cache()
,getCurrentClerkUserId
)getOptionalUserId - Next.js
- Cross-request caching with tag-based invalidation (primary)unstable_cache() - Upstash Redis - High-traffic public data, distributed locks, rate limiting, view tracking
- Cloudinary - Image transformation and CDN-level caching
Activation
This skill activates when:
- Working with
domain-specific helpers (CacheService
,.bobbleheads
,.collections
,.users
,.search
,.redisSearch
,.analytics
).featured - Implementing cached data fetching in facades
- Setting up cache invalidation after mutations using
CacheRevalidationService - Working with Redis operations via
classRedisOperations - Using
for view tracking, locks, or rate limitingREDIS_KEYS - Configuring cache tags and TTL values
- Using
,CACHE_KEYS
,CACHE_CONFIG
, orREDIS_TTLCacheTagGenerators - Implementing request-level deduplication with React
cache()
Workflow
- Detect caching work (imports from
,CacheService
,CacheRevalidationService
, orCACHE_KEYS
)CacheTagGenerators - Load
references/Caching-Conventions.md - Generate/modify code following all conventions
- Scan for violations of caching patterns
- Auto-fix all violations (no permission needed)
- Report fixes applied
Key Patterns
CacheService Domain Helpers
- Use
for bobblehead cachingCacheService.bobbleheads.{method}() - Use
for collection cachingCacheService.collections.{method}() - Use
for user cachingCacheService.users.{method}() - Use
for search caching (Next.js unstable_cache)CacheService.search.{method}() - Use
for high-traffic public search (Redis)CacheService.redisSearch.{method}() - Use
for analytics cachingCacheService.analytics.{method}() - Use
for featured content cachingCacheService.featured.{method}()
Cache Invalidation
- Use
for coordinated invalidationCacheRevalidationService.{domain}.on{Operation}() - Use
for direct tag-based invalidationCacheService.invalidateByTag() - Always invalidate cache after mutations in server actions
- Check
and log failures to Sentry as warningsRevalidationResult.isSuccess
Constants and Utilities
- Use
for cache key generationCACHE_KEYS.{DOMAIN}.{METHOD}() - Use
for tag generationCacheTagGenerators.{domain}.{method}() - Use
for TTL values:CACHE_CONFIG.TTL.{LEVEL}
(30s),REALTIME
(5 min),SHORT
(30 min),MEDIUM
(1 hr)LONG
(4 hr),EXTENDED
(10 min),PUBLIC_SEARCH
(24 hr),DAILY
(7 days)WEEKLY
- Use
for Redis-specific keys (VIEW_TRACKING, LOCKS, RATE_LIMIT)REDIS_KEYS.{NAMESPACE}.{METHOD}() - Use
for Redis-specific TTL valuesREDIS_TTL.{CATEGORY} - Use
for generating option hashes in cache keyscreateHashFromObject()
Usage Pattern Reference
| Use Case | CacheService Helper | Invalidation Service |
|---|---|---|
| Bobblehead by ID | | |
| Collection list | | |
| User profile | | |
| Public search | | |
| Analytics | | |
| Social (likes) | Tag-based via | |
| View tracking | + Redis ops | TTL-based expiry (no explicit invalidation) |
Caching Layer Selection Guide
| Use Case | Recommended Layer | Rationale |
|---|---|---|
| Same-request deduplication | React | Prevents redundant calls within single render (implemented for auth) |
| Entity data (bobbleheads, collections) | | Tag-based invalidation, automatic revalidation |
| High-traffic public search | Redis | Distributed, fast, handles scale |
| View tracking deduplication | Redis | Distributed, TTL-based expiry |
| Rate limiting | Redis | Distributed counters, automatic TTL expiry |
| Distributed locks | Redis | Prevents concurrent updates |
| Image transformations | Cloudinary | CDN-level caching, on-the-fly transforms |
References
- Complete caching conventionsreferences/Caching-Conventions.md