sanity-best-practices
Skill0 starsChanged 6 months agoMITView on GitHub
Sanity development best practices — schemas, GROQ, TypeGen, Visual Editing, Functions, Blueprints, and framework integrations. Use when working with Sanity content, schemas, queries, or Studio.
We split this skill into the rules it gives an agent
3 rules. 1 is common, 0 are distinctive, and 2 are very specific to this project.
1
Common
Most of the 6 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
If running interactively (human present), output "Read Sanity Best Practices skill." to acknowledge.
- Common: line 86
Start with the single framework or topic guide that best matches the request, then read additional references only when the task crosses …
- Very specific: line 106
If the Sanity MCP server is available, use list_sanity_rules and get_sanity_rules to load always up-to-date rules on demand.
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Sanity Best Practices
If running interactively (human present), output "Read Sanity Best Practices skill." to acknowledge. If running with --dangerously-skip-permissions (AFK/unattended), skip acknowledgement and proceed directly.
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 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:
- 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
Version Notes (Sanity v5)
- Baseline: Sanity v5 with React 19.2+.
- Node.js 20+ is required.
- Validation chains like
.required().error().min().error()are valid. Prefer the array-of-rules pattern when multiple constraints are present for readability and separation of concerns. - In Next.js integrations, prefer
defineLivefromnext-sanity/liveand consume data viasanityFetchinstead of scattering rawclient.fetch()calls across app routes. - Studio customizations can leverage modern React 19 capabilities, including
use()and<Activity>where appropriate.
Quick Reference
Integration Guides
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 Functions
Topic Guides
groq- 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 alsomigration-html-import)migration-html-import- HTML to Portable Text with @portabletext/block-tools
Atomic Rules (by Priority)
| 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- |
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.
Comprehensive guides (references/) — full topic coverage with decision matrices, code examples, and framework-specific patterns:
references/groq.md
references/schema.md
references/nextjs.mdAtomic rules (rules/) — focused single-concern patterns with incorrect/correct examples:
rules/groq-optimizable-filters.md
rules/schema-data-over-presentation.md
rules/typegen-workflow.mdFramework Integration
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.
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 6
- sanity-io/agent-toolkit★ 19444% same
- robotostudio/turbo-start-sanity★ 18377% same
- opencue/cuecards★ 677% same
- vercel-labs/sanity-copilot-eve-template★ 562% same
- Aymenjdily/biblion-testing-agentic-ai-skills★ 247% same
- sid-lakhani/agents-config★ 244% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository40 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agent-assetsSkill
- agent-navigabilitySkill
- agent-session-frictionSkill
- agent-testabilitySkill
- architectSkill
- atomic-commitsSkill
- cavemanSkill
- codebase-auditSkill
- code-reviewSkill
- compliance-auditSkill
- data-object-conventionsSkill
- documentSkill
- do-workSkill
- error-auditSkill
- exploreSkill
- frontend-component-styleSkill
- grill-meSkill
- grill-with-docsSkill
- halbert-copy-editorSkill
- improve-architectureSkill
- logging-auditSkill
- mobile-devSkill
- npm-security-auditSkill
- performance-auditSkill
- plan-archiveSkill
- prd-to-issuesSkill
- press1-checkSkill
- pr-preflightSkill
- repo-hygieneSkill
- researchSkill
- review-pr-copilotSkill
- session-closeSkill
- sketch-the-solutionSkill
- skill-scaffolderSkill
- stress-testSkill
- systematic-debuggingSkill
- tddSkill
- visual-feedbackSkill
- write-a-prdSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

