next-cache-components-optimizer

next-cache-components-optimizer is a skill for Claude Code, Codex from sanity-io/next-sanity. It costs 170 tokens per session (6,003 once invoked), scanned A, a copy of next-cache-components-optimizer, MIT.

A Next.js workflow for making a route appear quickly on first load and during in-app navigation. It uses Cache Components and an automated browser test to check that the route's shared page shell is ready promptly.

In plain words
What is it for?
Use it to optimize individual Next.js routes, investigate slow initial or client-side navigation, and add end-to-end checks for the route's loading behavior.
Why use it?
It turns a speed goal into a repeatable test, then guides fixes until the test passes and protects the result from later regressions.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: installed under .agents/ (shared by several agents).

Good fit Use it to optimize individual Next.js routes, investigate slow initial or client-side navigation, and add end-to-end checks for the route's loading behavior.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/sanity-io/next-sanity/next-cache-components-optimizer
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 sanity-io/next-sanity --skill next-cache-components-optimizer
Clone the repo
git clone --depth 1 https://github.com/sanity-io/next-sanity

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 next-cache-components-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/skills/sanity-io/next-sanity/next-cache-components-optimizer.svg)](https://agentmods.dev/skills/sanity-io/next-sanity/next-cache-components-optimizer)
Your own site
<a href="https://agentmods.dev/skills/sanity-io/next-sanity/next-cache-components-optimizer"><img src="https://agentmods.dev/badge/skills/sanity-io/next-sanity/next-cache-components-optimizer.svg" alt="Measured on agentmods" height="20"></a>
Per session 170 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 6,003 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.
Origin 97% copy Near-identical to another mod 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.00170 $0.06003
Opus 5 $0.00085 $0.03002
Sonnet 5 $0.00034 $0.01201
Haiku 4.5 $0.00017 $0.00600

Measured 8d ago against content hash bea6ca9e35d2, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

next-cache-components-optimizer 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 8d 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.

Origin

This is a copy

97% identical to next-cache-components-optimizer — 24 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.agents/skills/next-cache-components-optimizer/SKILL.md · 480 lines

How it starts

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

next-cache-components-optimizer

Set up an agentic optimization loop that drives a Next.js route from "not instant" to "instant" and keeps it there. The loop is test-driven: encode the goal as a failing @next/playwright instant() test, work it to green, and ship the test as the regression guard. Run it once per target route. Work the phases P → G in order; each ends in a gate. Fix recipes live in two lazily-read references — reference/patterns.md (before→after for each blocker type) and reference/real-app-patterns.md (parallel routes, auth gates, the empty-shell and responsive-skeleton failure modes). Read one only when its phase points there.

What is invariant, and what is yours

One thing here is fixed. The rest is yours. Read this before treating any command, platform, or env var below as a requirement.

  • Invariant: the verification loop. Maximizing the shell is worthless unless you can prove it. The proof is an automated check: under a lock that gates dynamic data, the static shell still commits. RED shows the gap, GREEN shows it closed, the test ships as the regression guard. It must run on a production-like build and must not be able to pass vacuously. Stand the loop up once; every later optimization is then verifiable by construction. The loop is the deliverable, not any one route.
  • The mechanism: @next/playwright instant(). This skill uses instant() as a ruler, not a stopwatch (phase A). It comes from @next/playwright (installed alongside @playwright/test, on the same release line as next), so it isn't tied to any host. Keep it. Timing a navigation by hand is too flaky to trust, and is the failure mode this skill exists to prevent.
  • Yours: the rig. How you build, deploy, authenticate, configure Playwright, and loop belongs to your stack, not to this skill. A local next build && next start, a CI/staging container, and a per-push preview deploy are equally valid rigs; the verdict comes from the build, never the platform. Phase 0 maps the invariant onto your repo. Read every platform name, env-var spelling, and command below as an example to translate, not a requirement.

Read the full file on GitHub · 480 lines

Files

What ships with it

5 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 8d ago First seen · 480 lines · 170 tokens per session scan A bea6ca9e35d2

Subscribe to this mod's changes

next-cache-components-optimizer is a skill published in the GitHub repository sanity-io/next-sanity (949 stars, last pushed yesterday), licensed MIT. It adds 170 tokens to every session and 6,003 once invoked, about $0.0009 per session on Opus 5. A static security scan graded it A with 0 findings. It is 97% identical to next-cache-components-optimizer, differing in 24 lines, and is treated as a copy.

Related

Other skills, from other repositories

new-block

Scaffold a new page builder block for Turbo Start Sanity end-to-end — Sanity schema, GROQ projection, styled React component, Markdown serializer, tests, and all registrations. Use when asked to add, create, or scaffold a new page builder block, section, or content module (e.g. "add a testimonials block", "create a…

robotostudio/turbo-start-sanity · 83 tokens

sanity-live-cache-components

Integrates Sanity Live with Next.js Cache Components in next-sanity v13+ apps. Sets up sanityFetch, , Visual Editing, Presentation Tool, draft mode handling, and the three-layer (Page/Dynamic/Cached) component pattern with explicit perspective/stega prop-drilling. Use when configuring or migrating a Next.js app to…

robotostudio/turbo-start-sanity · 110 tokens

next-cache-components

Next.js 16 Cache Components - PPR, use cache directive, cacheLife, cacheTag, updateTag.

robotostudio/turbo-start-sanity · 26 tokens

create-example

Create a new Liveblocks example app for the gallery under examples/. Use when asked to build a new example, demo, or showcase app, or when restructuring an existing example. Covers scaffolding, gallery conventions (exampleId, examplePreview, database.ts, HelpButton), providers configuration, AI patterns, styling…

liveblocks/liveblocks · 77 tokens

vercel-composition-patterns

React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.

robotostudio/turbo-start-sanity · 58 tokens

vercel-react-best-practices

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance…

robotostudio/turbo-start-sanity · 67 tokens