AgentSkillsCN

sanity-best-practices

全面的 Sanity 开发最佳实践,涵盖 GROQ 性能、Schema 设计、可视化编辑、图片处理、Portable Text、页面构建器、Studio 配置、TypeGen、本地化与迁移等环节。当您需要构建、评审或优化 Sanity 应用程序时,请使用此技能。

SKILL.md
--- frontmatter
name: sanity-best-practices
description: Comprehensive Sanity development best practices covering GROQ performance, schema design, Visual Editing, images, Portable Text, page builders, Studio configuration, TypeGen, localization, and migrations. Use this skill when building, reviewing, or optimizing Sanity applications.
license: MIT
metadata:
  author: sanity
  version: "1.0.0"

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:

code
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 via the Sanity MCP server using list_sanity_rules and get_sanity_rules tool calls when available. If the MCP server is not configured, run npx sanity@latest mcp configure to set it up.