immacualate/claude-forge/cache-components
- community
- ext:[{"type":"config","description":"Configuration overrides"}]
Checking that the SKILL.md file is still in the repository.
Expert guidance for Next.js Cache Components and Partial Prerendering (PPR). **PROACTIVE ACTIVATION**: Use this skill automatically when working in Next.js projects that have `cacheComponents: true` in their next.config.ts/next.config.js. When this config is detected, proactively apply Cache Components patterns and best practices to all React Server Component implementations. **DETECTION**: At the start of a session in a Next.js project, check for `cacheComponents: true` in next.config. If enabled, this skill's patterns should guide all component authoring, data fetching, and caching decisions. **USE CASES**: Implementing 'use cache' directive, configuring cache lifetimes with cacheLife(), tagging cached data with cacheTag(), invalidating caches with updateTag()/revalidateTag(), optimizing static vs dynamic content boundaries, debugging cache issues, and reviewing Cache Component implementations.
Install
npx vskill@latest install immacualate/claude-forge/cache-componentsSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as sangrokjung/claude-forge/cache-components.
Next.js Cache Components
Auto-activation: This skill activates automatically in projects withcacheComponents: truein next.config.
Project Detection
When starting work in a Next.js project, check if Cache Components are enabled:
If cacheComponents: true is found, apply this skill's patterns proactively when:
- Writing React Server Components
- Implementing data fetching
- Creating Server Actions with mutations
- Optimizing page performance
- Reviewing existing component code
Cache Components enable Partial Prerendering (PPR) - mixing static HTML shells with dynamic streaming content for optimal performance.
Philosophy: Code Over Configuration
Cache Components represents a shift from segment configuration to compositional code:
| Before (Deprecated) | After (Cache Components) | |
|---|---|---|
export const revalidate = 3600 | cacheLife('hours') inside 'use cache' | |
export const dynamic = 'force-static' | Use 'use cache' and Suspense boundaries | |
| All-or-nothing static/dynamic | Granular: static shell + cached + dynamic |
Key Principle: Components co-locate their caching, not just their data. Next.js provides build-time feedback to guide you toward optimal patterns.
Core Concept
Mental Model: The Caching Decision Tree
When writing a React Server Component, ask these questions in order:
Key insight: The 'use cache' directive is for data that's the _same across users_. User-specific data stays dynamic with Suspense.
Quick Start
Enable Cache Components
Basic Usage
Core APIs
1. 'use cache' Directive
Marks code as cacheable. Can be applied at three levels:
Important: All cached functions must be async.
2. cacheLife() - Control Cache Duration
Predefined profiles: 'default', 'seconds', 'minutes', 'hours', 'days', 'weeks', 'max'
3. cacheTag() - Tag for Invalidation
4. updateTag() - Immediate Invalidation
For read-your-own-writes semantics:
5. revalidateTag() - Background Revalidation
For stale-while-revalidate pattern:
When to Use Each Pattern
| Content Type | API | Behavior | |
|---|---|---|---|
| Static | No directive | Rendered at build time | |
| Cached | 'use cache' | Included in static shell, revalidates | |
| Dynamic | Inside <Suspense> | Streams at request time |
Parameter Permutations & Subshells
Critical Concept: With Cache Components, Next.js renders ALL permutations of provided parameters to create reusable subshells.
Next.js renders these routes:
Why this matters: The category subshell (/products/jackets/[slug]) can be reused for ANY jacket product, even ones not in generateStaticParams. Users navigating to an unlisted jacket get the cached category shell immediately, with product details streaming in.
generateStaticParams Requirements
With Cache Components enabled:
- Must provide at least one parameter - Empty arrays now cause build errors (prevents silent production failures)
- Params prove static safety - Providing params lets Next.js verify no dynamic APIs are called
- Partial params create subshells - Each unique permutation generates a reusable shell
Cache Key = Arguments
Arguments become part of the cache key:
Build-Time Feedback
Cache Components provides early feedback during development. These build errors guide you toward optimal patterns:
Error: Dynamic data outside Suspense
Solution: Wrap dynamic components in <Suspense>:
Error: Uncached data outside Suspense
Solution: Either cache the data or wrap in Suspense:
Error: Request data inside cache
Solution: Extract runtime data outside cache boundary (see "Handling Runtime Data" above).
Additional Resources
- For complete API reference, see REFERENCE.md
- For common patterns and recipes, see PATTERNS.md
- For debugging and troubleshooting, see TROUBLESHOOTING.md
Code Generation Guidelines
When generating Cache Component code:
- Always use `async` - All cached functions must be async
- Place `'use cache'` first - Must be first statement in function body
- Call `cacheLife()` early - Should follow
'use cache'directive - Tag meaningfully - Use semantic tags that match your invalidation needs
- Extract runtime data - Move
cookies()/headers()outside cached scope - Wrap dynamic content - Use
<Suspense>for non-cached async components
Proactive Application (When Cache Components Enabled)
When cacheComponents: true is detected in the project, automatically apply these patterns:
When Writing Data Fetching Components
Ask yourself: "Can this data be cached?" If yes, add 'use cache':
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/cache-components/SKILL.md
Popularity
- Repository stars
- 5
- 7-day trend score
- 9
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
configConfiguration overrides
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/immacualate/claude-forge/cache-components)