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.

referencescontent-reuse.md

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

Content Reuse Patterns

Effective content models maximize reuse while minimizing duplication. Here are patterns for achieving both.

The Content Reuse Spectrum

Full Duplication ←————————————————→ Full Reference
(Copy everything)                    (Link to one source)

Most real-world content sits somewhere in between.

Pattern 1: Shared Components

Create reusable content blocks that can be embedded anywhere.

Use case: Testimonials, FAQs, CTAs that appear on multiple pages.

// Standalone testimonial documents
defineType({
  name: 'testimonial',
  type: 'document',
  fields: [
    defineField({ name: 'quote', type: 'text' }),
    defineField({ name: 'author', type: 'string' }),
    defineField({ name: 'company', type: 'string' }),
  ]
})

// Reference in page builders
defineField({
  name: 'pageBuilder',
  type: 'array',
  of: [
    { type: 'reference', to: [{ type: 'testimonial' }] }
  ]
})

Pattern 2: Shared Field Sets

Extract common fields into reusable definitions.

Use case: SEO fields, social metadata, common dates.

// Shared field definition
export const seoFields = [
  defineField({ name: 'seoTitle', type: 'string' }),
  defineField({ name: 'seoDescription', type: 'text' }),
  defineField({ name: 'ogImage', type: 'image' }),
]

// Spread into multiple types
defineType({
  name: 'page',
  fields: [
    defineField({ name: 'title', type: 'string' }),
    ...seoFields
  ]
})

defineType({
  name: 'post',
  fields: [
    defineField({ name: 'title', type: 'string' }),
    ...seoFields
  ]
})

Pattern 3: Taxonomy References

Centralize classification for consistent tagging.

Use case: Categories, tags, topics that span content types.

// Central taxonomy
defineType({
  name: 'category',
  type: 'document',
  fields: [
    defineField({ name: 'title', type: 'string' }),
    defineField({ name: 'slug', type: 'slug' }),
  ]
})

// Used across content types
defineField({
  name: 'categories',
  type: 'array',
  of: [{ type: 'reference', to: [{ type: 'category' }] }]
})

Pattern 4: Content Fragments

Small, reusable pieces that combine into larger content.

Use case: Bios, addresses, contact info.

// Fragment type
defineType({
  name: 'contactInfo',
  type: 'object',
  fields: [
    defineField({ name: 'email', type: 'email' }),
    defineField({ name: 'phone', type: 'string' }),
    defineField({ name: 'address', type: 'text' }),
  ]
})

// Reused across types
defineType({
  name: 'office',
  fields: [
    defineField({ name: 'name', type: 'string' }),
    defineField({ name: 'contact', type: 'contactInfo' }),
  ]
})

Anti-Pattern: Over-Abstraction

Not everything needs to be reusable. If content is only used in one place, embedding is simpler.

Signs of over-abstraction:

  • References that are only used once
  • Editors navigating multiple documents for one page
  • Complex queries joining rarely-shared content

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.