skills/sanity-best-practices/SKILL.md
Sanity development best practices — schemas, GROQ, TypeGen, Visual Editing, Functions, Blueprints, and framework integrations. Use when working with Sanity content, schemas, queries, or Studio.
npx skillsauth add arndvs/ctrlshft sanity-best-practicesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Output "Read Sanity Best Practices skill." to chat to acknowledge you read this file.
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.
Reference these guidelines when working with: schema design, GROQ queries, TypeGen, Visual Editing, images, Portable Text, Studio structure, localization, migrations, Sanity Functions, Blueprints, or framework integrations (Next.js, Nuxt, Astro, Remix, SvelteKit, Angular, Hydrogen, App SDK). Triggered by: defineType, defineField, defineQuery, content modeling, Presentation/preview setups, documentEventHandler, defineDocumentFunction, defineMediaLibraryAssetFunction, @sanity/functions, @sanity/blueprints, sanity.blueprint.ts, event-driven content automation, or reviewing a Sanity codebase. More specifically, reference these guidelines when:
.required().error().min().error() are valid. Prefer the array-of-rules pattern when multiple constraints are present for readability and separation of concerns.defineLive from next-sanity/live and consume data via sanityFetch instead of scattering raw client.fetch() calls across app routes.use() and <Activity> where appropriate.get-started - Interactive onboarding for new Sanity projectsnextjs - Next.js App Router, Live Content API, embedded Studionuxt - Nuxt integration with @nuxtjs/sanityangular - Angular integration with @sanity/client, signals, resource APIastro - Astro integration with @sanity/astroremix - React Router / Remix integrationsvelte - SvelteKit integration with @sanity/svelte-loaderhydrogen - Shopify Hydrogen with Sanityproject-structure - Monorepo and embedded Studio patternsapp-sdk - Custom applications with Sanity App SDKblueprints - Infrastructure as Code with Sanity Blueprintsfunctions - Automating content workflows with Sanity Functionsgroq - GROQ query patterns, type safety, performance optimizationschema - Schema design, field definitions, validation, deprecation patternsvisual-editing - Presentation Tool, Stega, overlays, live previewpage-builder - Page Builder arrays, block components, live editingportable-text - Rich text rendering and custom componentsimage - Image schema, URL builder, hotspots, LQIP, Next.js Imagestudio-structure - Desk structure, singletons, navigationtypegen - TypeGen configuration, workflow, type utilitiesseo - Metadata, sitemaps, Open Graph, JSON-LDlocalization - i18n patterns, document vs field-level, locale managementmigration - Content import overview (see also migration-html-import)migration-html-import - HTML to Portable Text with @portabletext/block-tools| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | GROQ Performance | CRITICAL | groq- |
| 2 | Schema Design | HIGH | schema- |
| 3 | Visual Editing | HIGH | visual- |
| 4 | Images | HIGH | image- |
| 5 | Portable Text | HIGH | pte- |
| 6 | Page Builder | MEDIUM | pagebuilder- |
| 7 | Studio Configuration | MEDIUM | studio- |
| 8 | TypeGen | MEDIUM | typegen- |
| 9 | Localization | MEDIUM | i18n- |
| 10 | Migration | LOW-MEDIUM | migration- |
Start with the single framework or topic guide that best matches the request, then read additional references only when the task crosses concerns.
Comprehensive guides (references/) — full topic coverage with decision matrices, code examples, and framework-specific patterns:
references/groq.md
references/schema.md
references/nextjs.md
Atomic rules (rules/) — focused single-concern patterns with incorrect/correct examples:
rules/groq-optimizable-filters.md
rules/schema-data-over-presentation.md
rules/typegen-workflow.md
If the Sanity MCP server is available, use list_sanity_rules and get_sanity_rules to load always up-to-date rules on demand. If the MCP server is not configured, run npx sanity@latest mcp configure to set it up.
development
Use when implementing UI, checking dark/light mode, or validating animations — adds a visual feedback loop via browser screenshots so frontend changes are verified, not assumed.
development
Use when Claude Code sessions had many manual approval ("press 1") prompts or when auditing hook permissions; identifies which Bash commands required approval.
tools
Use after merging a PR or during periodic cleanup to archive plan-mode files by linking them to merged PRs.
testing
Use when stress-testing a plan against the project's domain model — grills the design, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise.