sanity-best-practices
This skill provides best practices for Sanity headless CMS development across schema design, GROQ queries, framework integrations (Next.js, Nuxt, Astro…
Identity proven by GitHub's verified organisation badge (sanity-io)
- Agents
- Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, claude.ai and API
- License
- MIT (permissive)
- Pin
- 88d6cdfpinned Oct 9, 2026
- Context cost
- about 1,100 tokenswhen the skill loads
- GitHub stars
- 188on sanity-io/agent-toolkit
- Scripts
- None found
What it does
“Sanity development best practices for schema design, GROQ queries, TypeGen, Visual Editing, images, Portable Text, Studio structure, localization, migrations, Sanity Functions, webhooks, Blueprints, and framework integrations such as Next.js, Nuxt, Astro, Remix, SvelteKit, Angular, Hydrogen, and the App SDK. Use this skill whenever working with Sanity schemas, defineType or defineField, GROQ or defineQuery, content modeling, Presentation or preview setups, Sanity-powered frontend integrations, event-driven content automation, documentEventHandler, defineDocumentFunction, defineMediaLibraryAssetFunction, @sanity/functions, @sanity/blueprints, sanity.blueprint.ts, event-driven content automation, or when reviewing and fixing a Sanity codebase.”
Generated summary from the skill's own text
This skill provides best practices for Sanity headless CMS development across schema design, GROQ queries, framework integrations (Next.js, Nuxt, Astro, Remix, SvelteKit, Angular, Hydrogen), Visual Editing, images, Portable Text, TypeGen, localization, and content automation via Functions and webhooks. It includes reference guides for both foundational concepts and framework-specific patterns.
When to use it
- Setting up new Sanity projects or onboarding teams to the platform
- Integrating Sanity with frontend frameworks and building schemas
- Writing GROQ queries or optimizing content modeling performance
- Implementing Visual Editing, live preview, and page builders
When not to
- Troubleshooting specific production incidents or error messages
- Obtaining customer support or account-related assistance
- Building custom Sanity plugins or extending the Studio UI
Install
These commands install from the publisher's repository and need no account.
skills CLI
npx skills add sanity-io/agent-toolkit --skill sanity-best-practicesInstalls from the repository's default branch, which may have changed since the commit we checked.
GitHub CLI 2.90 or later
gh skill install sanity-io/agent-toolkit sanity-best-practices@88d6cdfa7cb06c99edd5f376efa4dac21ae3f877Installs the commit we checked (88d6cdf).
Copy by hand
Download the folder at 88d6cdf and put it in .claude/skills/sanity-best-practices for Claude Code and in .agents/skills/sanity-best-practices for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.
Claude Code plugin
/plugin install sanity@claude-plugins-officialThe publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.
Copy for your agent
A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.
Prompt
Install the agent skill "sanity-best-practices" by Sanity. Source, pinned to commit 88d6cdfa7cb06c99edd5f376efa4dac21ae3f877: https://github.com/sanity-io/agent-toolkit/tree/88d6cdfa7cb06c99edd5f376efa4dac21ae3f877/skills/sanity-best-practices 1. Download that folder at exactly this commit. Do not use the default branch. 2. Copy every file unchanged, keeping the folder structure, into .claude/skills/sanity-best-practices/ for Claude Code and .agents/skills/sanity-best-practices/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist. 3. Do not edit the files, and do not run any script in the folder unless I ask you to. 4. When you are done, list the files you copied and where you put them. Listing and checks: https://www.agentnative.dev/skills/sanity/sanity-best-practices
SKILL.md at the pin
--- name: sanity-best-practices description: Sanity development best practices for schema design, GROQ queries, TypeGen, Visual Editing, images, Portable Text, Studio structure, localization, migrations, Sanity Functions, webhooks, Blueprints, and framework integrations such as Next.js, Nuxt, Astro, Remix, SvelteKit, Angular, Hydrogen, and the App SDK. Use this skill whenever working with Sanity schemas, defineType or defineField, GROQ or defineQuery, content modeling, Presentation or preview setups, Sanity-powered frontend integrations, event-driven content automation, documentEventHandler, defineDocumentFunction, defineMediaLibraryAssetFunction, @sanity/functions, @sanity/blueprints, sanity.blueprint.ts, event-driven content automation, or when reviewing and fixing a Sanity codebase. --- # Sanity Best Practices Comprehensive best practices and integration guides for Sanity development, maintained by Sanity. Use the quick reference below to load only the one or two topic files that match the task. ## When to Apply Reference these guidelines when: - Setting up a new Sanity project or onboarding - Integrating Sanity with a frontend framework (Next.js, Nuxt, Astro, Remix, SvelteKit, Hydrogen) - Writing GROQ queries or optimizing performance - Designing content schemas - Implementing Visual Editing and live preview - Working with images, Portable Text, or page builders - Configuring Sanity Studio structure - Setting up TypeGen for type safety - Implementing localization - Migrating content from other systems - Building custom apps with the Sanity App SDK - Managing infrastructure with Blueprints - Automating content workflows with Sanity Functions or webhooks ## Global Rules - Let Sanity generate `_id` values for ordinary documents. Do not create deterministic UUIDs, slug-derived IDs, or legacy-system IDs when creating documents. - Model relationships with `reference` fields, then resolve related documents with GROQ lookups, source-key fields, or returned `_id` values from created documents. - Use explicit document IDs mainly for singleton documents controlled by Studio Structure, including localized singletons such as `homePage-en`. ## Video - Do not store or serve video from Sanity `file` assets for production playback. File assets are delivered as raw downloads with no transcoding or adaptive streaming, and video traffic drives very high bandwidth usage and unexpectedly large bills. - On Enterprise plans with the video add-on, use Sanity Media Library for video: uploads are transcoded and streamed adaptively via Mux. Model video fields with `defineVideoField()` from `sanity/media-library` and play them with `@mux/mux-player-react` using the asset's playback ID. - On other plans, use a dedicated video service: install `sanity-plugin-mux-input` to upload and manage videos in your Mux account from the Studio, or host video on a platform such as YouTube or Vimeo and store only the embed URL in Sanity. - Small clips and short previews in a `file` field are acceptable, but any user-facing video at scale must go through Media Library or a streaming service. ## Quick Reference ### Integration Guides - `get-started` - Interactive onboarding for new Sanity projects - `nextjs` - Next.js App Router, Live Content API, standalone Studio - `nuxt` - Nuxt integration with @nuxtjs/sanity - `angular` - Angular integration with @sanity/client, signals, resource API - `astro` - Astro integration with @sanity/astro - `remix` - React Router / Remix integration - `svelte` - SvelteKit integration with @sanity/svelte-loader - `hydrogen` - Shopify Hydrogen with Sanity - `project-structure` - Standalone Studio and monorepo patterns - `app-sdk` - Custom applications with Sanity App SDK - `blueprints` - Infrastructure as Code: blueprint files, stacks, plan/deploy workflow, error recovery, CI deploys - `functions` - Automating content workflows with Sanity Functions and webhooks ### Topic Guides - `groq` - GROQ query patterns, type safety, performance optimization - `schema` - Schema design, field definitions, validation, deprecation patterns - `visual-editing` - Presentation Tool, Stega, overlays, live preview - `page-builder` - Page Builder arrays, block components, live editing - `portable-text` - Rich text rendering and custom components - `image` - Image schema, URL builder, hotspots, LQIP, Next.js Image - `studio-structure` - Desk structure, singletons, navigation - `typegen` - TypeGen configuration, workflow, type utilities - `seo` - Metadata, sitemaps, Open Graph, JSON-LD - `localization` - i18n patterns, document vs field-level, locale management - `migration` - Content import overview (see also `migration-html-import`) - `migration-html-import` - HTML to Portable Text with @portabletext/block-tools ## How to Use Start with the single framework or topic guide that best matches the request, then read additional references only when the task crosses concerns. Use these reference files for detailed explanations and code examples: ``` references/groq.md references/schema.md references/nextjs.md ``` Each reference file contains: - Comprehensive topic or integration coverage - Incorrect and correct code examples - Decision matrices and workflow guidance - Framework-specific patterns where applicable
From sanity-io/agent-toolkit at 88d6cdf, shown as plain text under its license: MIT (permissive). The license text is in LICENSE.
View SKILL.md on GitHub at 88d6cdfFiles
- SKILL.md5.3 KB · 39c6413b567b
- references/
- angular.md19 KB · b0d1d5bf29b9
- app-sdk.md12 KB · 0ba5903e2933
- astro.md5.0 KB · 63e85d32d081
- blueprints.md14 KB · 813d55c13ac7
- functions.md30 KB · d1e819bb173e
- get-started.md21 KB · d2f2d9a07cd5
- groq.md15 KB · 5817989b22c7
- hydrogen.md6.9 KB · 1385bec2e770
- image.md3.4 KB · 9499a46f4373
- localization.md12 KB · 7559e4d8f26a
- migration-html-import.md5.3 KB · b4bbc6a4772a
- migration.md2.8 KB · 28552a4b9733
- nextjs.md17 KB · 6b5901fdd3ba
- nuxt.md6.0 KB · abec78e73957
- page-builder.md8.4 KB · d40dff55d277
- portable-text.md10 KB · 146f5cbfca48
- project-structure.md3.6 KB · 1f3823dc94a0
- remix.md9.0 KB · 09b96c418cc7
- schema.md12 KB · afcf017a9a92
- seo.md8.5 KB · 4abb2a237bfb
- studio-structure.md3.7 KB · 3cb8ba6fea2d
- svelte.md10 KB · 6d9ac31e8cc9
- typegen.md6.2 KB · ba0f22b7024b
- visual-editing.md8.5 KB · fef7d2f407f0
25 files, 256 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.
Skill folder on GitHub at 88d6cdfMore from Sanity
sanity-live-cache-components
Integrates Sanity Live with Next.js Cache Components in next-sanity v13+ apps, setting up shared cached data fetching through sanityFetch, live content…
Claude Code, Codex, Cursor +4 · about 4K tokens · pinned 6 days ago
content-experimentation-best-practices
This skill provides guidance for designing and running content experiments using A/B and multivariate testing.
Claude Code, Codex, Cursor +4 · about 360 tokens · pinned 6 days ago
content-modeling-best-practices
Guides agents through structured content modeling principles for headless CMSes like Sanity, covering schema design, content reuse strategies, and field…
Claude Code, Codex, Cursor +4 · about 340 tokens · pinned 6 days ago
portable-text-conversion
Converts HTML and Markdown content into Portable Text blocks for Sanity using markdownToPortableText, htmlToBlocks, or manual construction.
Claude Code, Codex, Cursor +4 · about 510 tokens · pinned 6 days ago
portable-text-serialization
This skill enables rendering Portable Text content across multiple frameworks and output formats using the @portabletext library family.
Claude Code, Codex, Cursor +4 · about 940 tokens · pinned 6 days ago
sanity-migration
This skill plans, executes, and validates migrations from various content management systems and data sources into Sanity.
Claude Code, Codex, Cursor +4 · about 1.2K tokens · pinned 6 days ago
Related in Coding workflow
prisma-next-build
This skill integrates Prisma Next's contract-emit into the Vite build system via the @prisma-next/vite-plugin-contract-emit plugin, automatically re-emitting…
by PrismaOfficial publisher
Claude Code, Codex, Cursor +4 · about 2.3K tokens · pinned 6 days ago
planning
This skill orchestrates multi-workflow projects with dependencies and shared data tables by creating a task graph in the orchestrator via the create-tasks tool.
by n8nOfficial publisher
Claude Code, Codex, Cursor +3 · about 2.4K tokens · pinned 6 days ago
progressive-building
This skill implements incremental workflow development for agents building or extending workflows.
by n8nOfficial publisher
Claude Code, Codex, Cursor +3 · about 1.4K tokens · pinned 6 days ago
workflow-builder
Builds and edits n8n workflows using the TypeScript SDK.
by n8nOfficial publisher
Claude Code, Codex, Cursor +3 · about 14.2K tokens · pinned 6 days ago
remotion-upgrade
This skill upgrades Remotion and its related packages to the latest stable version.
by RemotionOfficial publisher
Claude Code, Codex, Cursor +3 · about 460 tokens · pinned 6 days ago
remotion-upgrade
This skill upgrades Remotion and related packages across a project, automatically detecting the package manager and workspaces.
by RemotionOfficial publisher
Claude Code, Codex, Cursor +3 · about 460 tokens · pinned 6 days ago