All skills
sanity-io avatar

/content-modeling-best-practices

@ad50ea4 official
by Sanitysanity-io/agent-toolkit187 stars
30

Structured content modeling guidance for schema design, content architecture, content reuse, references versus embedded objects, separation of concerns, and taxonomies across Sanity and other headless CMSes. Use this skill when designing or refactoring content types, deciding field shapes, debating reusable versus nested content, planning omnichannel content models, or reviewing whether a schema is too page-shaped or presentation-driven.

Use this Skill: https://skilld.dev/gh/sanity-io/agent-toolkit/content-modeling-best-practices

This session only. Nothing lands on disk.

referencesreference-vs-embedding.md

≈586 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Reference vs Embedding Content

When should content be linked (referenced) vs copied (embedded)? This decision affects reusability, query complexity, and editing workflows.

The Trade-offs

Aspect Reference Embedded Object
Reusability ✅ Shared across documents ❌ Copied per document
Single source ✅ Update once, reflects everywhere ❌ Must update each copy
Query complexity Requires joins/expansion Inline, simpler queries
Editing UX Separate editing interface All fields in one place
Independence Can exist on its own Only exists within parent

When to Reference

Use references when content:

  • Is reusable — Same author across many articles
  • Needs central management — Update product info once
  • Has its own lifecycle — Published/draft independent of parent
  • Should stay in sync — Price changes reflect everywhere

Examples:

  • Author profiles
  • Product catalog items
  • Shared testimonials
  • Category taxonomy
  • Reusable CTAs

When to Embed

Use embedded objects when content:

  • Is unique to this document — Page-specific hero
  • Doesn't make sense alone — SEO metadata
  • Should be copied, not linked — Historical snapshot
  • Simplifies editing — All fields in one form

Examples:

  • SEO metadata
  • Page-specific sections
  • Address information
  • Social links
  • Configuration options

Sanity Implementation

// Reference: Author is reusable
defineField({
  name: 'author',
  type: 'reference',
  to: [{ type: 'author' }]
})

// Embedded: SEO is page-specific
defineField({
  name: 'seo',
  type: 'object',
  fields: [
    defineField({ name: 'title', type: 'string' }),
    defineField({ name: 'description', type: 'text' })
  ]
})

The Hybrid Approach

Sometimes you want both: a reference for the canonical data, plus embedded overrides.

defineField({
  name: 'featuredProduct',
  type: 'object',
  fields: [
    defineField({ 
      name: 'product', 
      type: 'reference', 
      to: [{ type: 'product' }] 
    }),
    defineField({ 
      name: 'overrideTitle', 
      type: 'string',
      description: 'Optional: Override the product title for this context'
    }),
  ]
})

Query uses coalesce(overrideTitle, product->title).

Source: SKILL.md on GitHub

No alerts16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill consists of purely instructional documentation regarding content modeling and schema design best practices for Sanity and headless CMS structures. It contains no executable scripts, system commands, external network connections, or data operations, and is completely safe.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer6mo

    5 files scanned · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at ad50ea4. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 6 months ago
  • sanity
  • headless-cms
  • content-modeling
  • schema-design
  • content-architecture
  • references
  • taxonomies
  • structured-content

README badge

README badge for sanity-io/agent-toolkit/content-modeling-best-practices

Guides schema design for Sanity and headless CMSes through principles like content-as-data, single source of truth, and editor-centric structure. Covers references vs embedded objects, separation of concerns, content reuse patterns, and taxonomy design to avoid page-shaped or presentation-driven schemas.

Generated from the current SKILL.md.

Does this skill apply to CMSes other than Sanity?
Yes. The skill covers general content modeling principles that apply to any headless CMS, with Sanity-specific implementation notes included where relevant.
What specific decisions does this skill help with?
It guides decisions on schema design, references versus embedded objects, content reuse patterns, taxonomy structures, and whether a model is too page-shaped or presentation-driven.
Does this skill provide code examples or just principles?
The skill provides structured guidance documents covering separation of concerns, reference vs embedding, content reuse, and taxonomy classification. It is principles-focused rather than code-focused.
Can I use this when refactoring an existing content model?
Yes. The skill is designed for both new projects and refactoring existing structures to improve reusability and flexibility.

Generated from the current SKILL.md. These answers refresh after source changes.