Agent skill

Sanity Live Cache Components

by robotostudio in robotostudio/turbo-start-sanity

Integrates Sanity Live with Next.js Cache Components in next-sanity v13+ apps.

MITAuto-check passedDevelopment

Install Sanity Live Cache Components

skills CLI
$ npx skills add robotostudio/turbo-start-sanity --skill sanity-live-cache-components -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install robotostudio/turbo-start-sanity sanity-live-cache-components --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/robotostudio/turbo-start-sanity.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/sanity-live-cache-components .claude/skills/sanity-live-cache-components && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
sanity-live-cache-components
GitHub stars
182
Token cost
~2.8k tokens
SKILL.md length
889 words
Files
5
Skills in repo
3
Repo updated
First seen
Licence
MIT

At a glance

Integrates Sanity Live with Next.js Cache Components in next-sanity v13+ apps.

  • Works in 5 steps: Install next-sanity@^13 → Configure next.config.ts → Configure defineLive and export helpers → …
  • Migrating a Next.js app to cacheComponents with Sanity
  • SKILL.md covers Prerequisites, Reference files, 1. Install next-sanity@^13 and 2. Configure next.config.ts, plus 4 more sections
  • Calls npm and pnpm; needs SANITY_API_READ_TOKEN

What it does

Sanity Live Cache Components is an agent skill from robotostudio/turbo-start-sanity. Integrates Sanity Live with Next.js Cache Components in next-sanity v13+ apps. Sets up sanityFetch, <SanityLive, 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 cacheComponents with Sanity, when adding sanityFetch, when wiring <SanityLive/<VisualEditing, or when refactoring components that hardcode perspective/stega.

Its SKILL.md is about 2.8k tokens, which your agent loads only when the skill is triggered. The skill folder holds 5 other files (for example `reference/dynamic-segments.md`, `reference/layouts.md` and `reference/live-helpers.md`).

It sits in Development, covering Refactoring. It works with Next.js and Turborepo. The repository describes itself as: Sanity + Next.js page-builder template. The licence is MIT.

When your agent uses it

  • Migrating a Next.js app to cacheComponents with Sanity
  • Adding sanityFetch
  • Wiring <SanityLive/<VisualEditing
  • Refactoring components that hardcode perspective/stega

Example prompts

  • “Use the sanity-live-cache-components skill to integrate Sanity Live with Next.js Cache Components in next-sanity v13+ apps”
  • “/sanity-live-cache-components”

Requirements

  • Node.js
  • A credential in SANITY_API_READ_TOKEN

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Install next-sanity@^13
  2. Configure next.config.ts
  3. Configure defineLive and export helpers
  4. Render in a root layout
  5. Apply the three-layer pattern to pages and layouts

What it can do on your machine

Read from SKILL.md and the folder at commit 8155b99. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npm
    • pnpm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • nextjs.org

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • SANITY_API_READ_TOKEN

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Sanity Live Cache Components loads about 2.8k tokens when it runs. Until then it costs about 129 tokens; SKILL.md has 889 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~129
When it runs · the whole SKILL.md, loaded when a task matches
~2.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from robotostudio/turbo-start-sanity at commit 8155b99, republished under its MIT licence (© robotostudio). 889 words, ~2,753 tokens.

Download SKILL.mdSave it as .claude/skills/sanity-live-cache-components/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
sanity-live-cache-components
description
Integrates Sanity Live with Next.js Cache Components in next-sanity v13+ apps. Sets up sanityFetch, <SanityLive>, 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 cacheComponents with Sanity, when adding sanityFetch, when wiring <SanityLive>/<VisualEditing>, or when refactoring components that hardcode perspective/stega.

Sanity Live + Cache Components

Wires next-sanity into a Next.js 16+ app with cacheComponents: true. Data is fetched with sanityFetch (which calls cacheTag/cacheLife internally), and <SanityLive> in the root layout revalidates cached content over an EventSource connection to Sanity Content Lake. Visual Editing and Presentation Tool are fully supported when draft mode is enabled.

Read the relevant guide in node_modules/next/dist/docs/ (when available) before writing code. If a guide conflicts with this skill, follow this skill.

This skill assumes familiarity with the next-cache-components skill — it covers 'use cache', cacheLife, cacheTag, and the cookies/headers/params rule. The only Sanity-relevant exception: await draftMode() is allowed inside 'use cache' (Next.js bypasses caching when draft mode is enabled — see the use cache reference).

Prerequisites

  • Next.js 16.2+ installed in the project (check package.json or run pnpm list next / npm ls next — don't use pnpm view next version, that reports the registry's latest, not what's installed).
  • AGENTS.md exists, or follow the guide.
  • These environment variables are set:
    • NEXT_PUBLIC_SANITY_PROJECT_ID
    • NEXT_PUBLIC_SANITY_DATASET
    • SANITY_API_READ_TOKEN
  • Embedded Sanity Studio configuration (sanity.config.ts, sanity.cli.ts, anything under sanity/) needs no changes — this skill only touches the Next.js app surface.

Reference files

FileWhen to read
reference/live-helpers.mdFull client.ts / live.ts, sanityFetch* and getDynamicFetchOptions details
reference/three-layer-pattern.mdThe Page → Dynamic → Cached pattern for page.tsx, including the searchParams variant
reference/layouts.mdNon-blocking data fetching inside layout.tsx with a shared 'use cache' helper
reference/dynamic-segments.mdHigh-performance [slug] routes: loading.tsx + partial generateStaticParams, or non-blocking dynamic params in a layout

1. Install next-sanity@^13

bash
npm install next-sanity@^13 --save-exact
Migrating an existing Sanity Live setup

If the app is already using defineLive, this skill is a refactor, not a rewrite. The 5-step sequence below still applies, but watch for these specific differences:

  • Don't overwrite client.ts or live.ts if they exist. Append missing options. Preserve any existing token and stega.* settings — see reference/live-helpers.md.
  • Search the codebase for hardcoded perspective: 'published' and stega: false in sanityFetch callsites and refactor them to source perspective/stega via getDynamicFetchOptions and the three-layer pattern.
  • Search for sanityFetch calls inside generateStaticParams → swap for sanityFetchStaticParams.
  • Search for sanityFetch calls inside generateMetadata / sitemap.ts / opengraph-image.tsx / etc. → swap for sanityFetchMetadata.
  • Search for sanityFetch calls directly inside a 'use server' function → split into a separate 'use cache' helper.
  • Verify there is exactly one <SanityLive> and one <VisualEditing> in the tree. Multiple renders are undefined behavior.

The "Anti-patterns to grep for" section at the bottom of this file lists the search patterns.


2. Configure next.config.ts

Enable cacheComponents and set cacheLife.default to sanity so default revalidation is 1 year (instead of 15 minutes). sanityFetch is optimized for on-demand revalidation and doesn't need time-based revalidation.

ts
// next.config.ts
import type {NextConfig} from 'next'
import {sanity} from 'next-sanity/live/cache-life'

const nextConfig: NextConfig = {
  cacheComponents: true,
  cacheLife: {default: sanity},
}

export default nextConfig

3. Configure defineLive and export helpers

Create src/sanity/lib/client.ts and src/sanity/lib/live.ts. The minimal defineLive call:

ts
// src/sanity/lib/live.ts (excerpt)
export const {SanityLive, sanityFetch} = defineLive({
  client,
  serverToken: token,
  browserToken: token,
  strict: true,
})

Full file contents (including client.ts, getDynamicFetchOptions, sanityFetchMetadata, sanityFetchStaticParams) and per-helper guidance: reference/live-helpers.md.

The helpers exported from live.ts:

HelperUsed in
sanityFetch'use cache' components rendered from page.tsx / layout.tsx
sanityFetchMetadatagenerateMetadata, generateViewport, sitemap.ts, robots.ts, opengraph-image.tsx, etc.
sanityFetchStaticParamsgenerateStaticParams only
getDynamicFetchOptionsResolving perspective/stega outside any 'use cache' boundary
SanityLiveRendered once in a root layout

4. Render <SanityLive> in a root layout

<SanityLive> and <VisualEditing> both belong in a layout.tsx, never a page.tsx. Both must be rendered at most once across the whole tree — duplicate renders are undefined behavior.

  • includeDrafts is required when defineLive is configured with strict: true (the recommended setup). TypeScript will surface the error if it's missing; pass includeDrafts={isDraftMode} so live revalidation includes drafts only in draft mode.
  • Preserve any existing optional callback props on <SanityLive> when migrating: onError, onWelcome, onReconnect. They are commonly wired to a toast/notification helper and silently dropping them regresses UX.
tsx
// src/app/layout.tsx
import {SanityLive} from '@/sanity/lib/live'
import {VisualEditing} from 'next-sanity/visual-editing'
import {draftMode} from 'next/headers'

export default async function RootLayout({children}: LayoutProps<'/'>) {
  const {isEnabled: isDraftMode} = await draftMode()
  return (
    <html lang="en">
      <body>
        {children}
        <SanityLive includeDrafts={isDraftMode} />
        {isDraftMode && <VisualEditing />}
      </body>
    </html>
  )
}
Show full SKILL.md (313 more words)Show less
With an embedded Sanity Studio

If a route mounts NextStudio from next-sanity/studio (e.g. app/studio/[[...index]]/page.tsx), <SanityLive> must live in a layout the embedded studio doesn't share. Use route groups: put <SanityLive> in src/app/(website)/layout.tsx and keep the rest of the app under src/app/(website).


5. Apply the three-layer pattern to pages and layouts

Every route that should be statically prerendered uses the same shape:

text
Page/Layout (Layer 1: draftMode branch)
  ├── NOT draft mode → <CachedX perspective="published" stega={false} />  (no Suspense)
  └── draft mode → <Suspense fallback={...}>
                      <DynamicX params={params} />  (Layer 2: awaits dynamic APIs)
                        └── <CachedX perspective={p} stega={s} />  (Layer 3: 'use cache')

Critical rule: Only Layer 3 carries 'use cache'. The top-level Page / Layout must not have 'use cache' — it awaits params, searchParams, or cookies() (via getDynamicFetchOptions), and those dynamic APIs are forbidden inside 'use cache'. Layer 3 carrying 'use cache' is enough for the whole route to prerender into the static shell. Adding 'use cache' to the top-level function is the most common failure mode — TypeScript and the runtime will both complain.

Pick the right reference for the file you're editing:


Anti-patterns to grep for

When auditing an app, search for these and refactor:

  • perspective: 'published' and stega: false hardcoded together in a sanityFetch call → use the three-layer pattern, source perspective/stega via getDynamicFetchOptions.
  • sanityFetch( directly inside a function whose body begins with 'use server' → split into a separate 'use cache' helper.
  • sanityFetch( inside generateStaticParams → swap for sanityFetchStaticParams.
  • sanityFetch( inside generateMetadata / generateViewport / sitemap.ts / robots.ts / opengraph-image.tsx etc. → swap for sanityFetchMetadata and resolve perspective via getDynamicFetchOptions.
  • await draftMode() immediately followed by await getDynamicFetchOptions() at the top of a page.tsx or layout.tsx without a sibling loading.tsx → move those dynamic-API calls into a child component wrapped in <Suspense> so the static shell can prerender.
  • More than one <SanityLive> or <VisualEditing> rendered in the tree → consolidate to a single render in the right layout.

© robotostudio, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files in .claude/skills/sanity-live-cache-components of robotostudio/turbo-start-sanity.

  • SKILL.md
  • reference/dynamic-segments.md
  • reference/layouts.md
  • reference/live-helpers.md
  • reference/three-layer-pattern.md

Open the folder on GitHubat commit 8155b99

Compare with similar skills

Sanity Live Cache Components next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Sanity Live Cache Components compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Sanity Live Cache Components this skillrobotostudio/turbo-start-sanity182—~2.8kAutomated safety check: PassMIT
Nuqstrycompai/crm11k1 repos~1.7kAutomated safety check: PassMIT
Runtime Debugvercel/next.js143k1 repos~618Automated safety check: PassMIT
React Best Practicesshapeshift/web2061 repos~2kAutomated safety check: PassMIT
Nextjs App Architecturejakubwarkusz/themes1231 repos~2.5kAutomated safety check: PassMIT
Clean Code Refactorerfike/fastapi-blog101—~402Automated safety check: PassMIT

Similar skills

  • Nuqs

    trycompai/crm

    nuqs (type-safe URL query state) best practices for Next.js and other React frameworks.

    11k GitHub starsUsed in 1 repo~1.7k tokens
    DevelopmentAuto-check passed
  • Runtime Debug

    vercel/next.js

    Official

    Debug and verification workflow for runtime-bundle and module-resolution regressions.

    143k GitHub starsUsed in 1 repo~618 tokens
    DevelopmentAuto-check passed
  • React Best Practices

    shapeshift/web

    Comprehensive React and Next.js performance optimization guide with 40+ rules for eliminating waterfalls, optimizing bundles, and improving rendering.

    206 GitHub starsUsed in 1 repo~2k tokens
    DevelopmentAuto-check passed
  • Nextjs App Architecture

    jakubwarkusz/themes

    Build or audit Next.js 16 App Router apps using a next-beats-style React Server Components architecture.

    123 GitHub starsUsed in 1 repo~2.5k tokens
    DevelopmentAuto-check passed
  • Clean Code Refactorer

    fike/fastapi-blog

    Skill for identifying code smells and refactoring code using Clean Code, SOLID, and DRY principles.

    101 GitHub stars~402 tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Official

    Integrates Sanity Live with Next.js Cache Components in next-sanity v13+ apps.

    176 GitHub stars~4.2k tokensUpdated yesterday
    DevelopmentAuto-check passed

More from robotostudio/turbo-start-sanity

  • Sanity Best Practices

    robotostudio/turbo-start-sanity

    Sanity development best practices for schema design, GROQ queries, TypeGen, Visual Editing, images, Portable Text, Studio structure, localization, migrations, Sanity Functions, Blueprints, and…

    182 GitHub stars~940 tokensUpdated 3 days ago
    Auto-check passed
  • New Block

    robotostudio/turbo-start-sanity

    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.

    182 GitHub stars~2.8k tokensUpdated 3 days ago
    Auto-check passed

Categories

Questions about Sanity Live Cache Components

What does Sanity Live Cache Components do?

Integrates Sanity Live with Next.js Cache Components in next-sanity v13+ apps. Sanity Live Cache Components is an agent skill from robotostudio/turbo-start-sanity.js Cache Components in next-sanity v13+ apps.

When should I use Sanity Live Cache Components?

Sanity Live Cache Components fits situations like: migrating a Next.js app to cacheComponents with Sanity; adding sanityFetch; wiring <SanityLive/<VisualEditing; refactoring components that hardcode perspective/stega.

How do I install Sanity Live Cache Components in Claude Code?

Run `npx skills add robotostudio/turbo-start-sanity --skill sanity-live-cache-components -a claude-code`. Or copy the skill folder (.claude/skills/sanity-live-cache-components in robotostudio/turbo-start-sanity) into .claude/skills/sanity-live-cache-components in your project. Claude Code loads it when a task matches its description.

How do I install Sanity Live Cache Components in Codex?

Run `npx skills add robotostudio/turbo-start-sanity --skill sanity-live-cache-components -a codex`. Or copy the skill folder (.claude/skills/sanity-live-cache-components in robotostudio/turbo-start-sanity) into .agents/skills/sanity-live-cache-components in your project. Codex loads it when a task matches its description.

Can I use Sanity Live Cache Components in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add robotostudio/turbo-start-sanity --skill sanity-live-cache-components -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/sanity-live-cache-components, .gemini/skills/sanity-live-cache-components, .github/skills/sanity-live-cache-components and .opencode/skills/sanity-live-cache-components in your project.

What does Sanity Live Cache Components need to run?

Going by SKILL.md and its folder, Sanity Live Cache Components needs the command-line tools its instructions call (npm and pnpm) and credentials named SANITY_API_READ_TOKEN. Our summary lists: Node.js; A credential in SANITY_API_READ_TOKEN.

Does Sanity Live Cache Components access the network?

SKILL.md names 1 domain. As links in the text: nextjs.org. This is read from the text; nothing was executed.

Is Sanity Live Cache Components safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Sanity Live Cache Components use?

Sanity Live Cache Components is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Sanity Live Cache Components use?

About 2.8k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Sanity Live Cache Components?

Skills that share tags, products or a category with Sanity Live Cache Components: Nuqs (trycompai/crm, 11k stars), Runtime Debug (vercel/next.js, 143k stars), React Best Practices (shapeshift/web, 206 stars) and Nextjs App Architecture (jakubwarkusz/themes, 123 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Sanity Live Cache Components?

robotostudio (a GitHub organization) maintains it in robotostudio/turbo-start-sanity, which has 182 GitHub stars. The repository holds 3 skills in this directory. The repository was last updated on October 5, 2026.

Source: robotostudio/turbo-start-sanity on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.