sanity-best-practices

from sanity-io/agent-toolkit

Collection of resources to help AI agents build better with Sanity.

56 stars3 forksUpdated Jan 24, 2026
npx skills add https://github.com/sanity-io/agent-toolkit --skill sanity-best-practices

SKILL.md

Sanity Best Practices

Comprehensive best practices guide for Sanity development, maintained by Sanity. Contains rules across 10 categories, prioritized by impact to guide schema design, query optimization, and frontend integration.

When to Apply

Reference these guidelines when:

  • 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

Rule Categories by Priority

PriorityCategoryImpactPrefix
1GROQ PerformanceCRITICALgroq-
2Schema DesignHIGHschema-
3Visual EditingHIGHvisual-
4ImagesHIGHimage-
5Portable TextHIGHpte-
6Page BuilderMEDIUMpagebuilder-
7Studio ConfigurationMEDIUMstudio-
8TypeGenMEDIUMtypegen-
9LocalizationMEDIUMi18n-
10MigrationLOW-MEDIUMmigration-

How to Use

Read individual rule files for detailed explanations and code examples:

rules/groq-optimizable-filters.md
rules/schema-data-over-presentation.md
rules/_sections.md

Each rule file contains:

  • Brief explanation of why it matters
  • Incorrect code example with explanation
  • Correct code example with explanation
  • Additional context and references
  • Framework-specific notes (when applicable)

Framework Integration

Framework-specific guidance (Next.js, Astro, Remix, etc.) is available in the rules/*.mdc files in the repository root. The skill references them when relevant but doesn't duplicate content.

Full Compiled Document

For the complete guide with all rules expanded: AGENTS.md

Repository Stats

Stars56
Forks3
LicenseMIT License