sanity-scaffold

Interactively scaffold a new Sanity Schema Document or Object type using best-practice templates. Use when user wants to create new content types.

⭐37stars🔀3forks📁View on GitHub🕐Updated Dec 18, 2025⬇️2downloads

When & Why to Use This Skill

The sanity-scaffold skill is a specialized developer tool designed to automate the creation of Sanity.io schema documents and objects. By leveraging best-practice templates and an interactive guided workflow, it ensures that new content types are structured correctly, strictly typed, and automatically registered within the project's architecture, significantly reducing manual boilerplate and configuration errors.

Use Cases

  • 1. Rapid Content Modeling: Quickly scaffold new Sanity document types such as 'blogPost', 'product', or 'author' by following a guided prompt that handles file creation and field definition.
  • 2. Schema Standardization: Maintain consistency across a development team by using standardized templates that enforce the 'Data > Presentation' philosophy and uniform icon usage.
  • 3. Automated Project Integration: Streamline the development workflow by automatically updating schema index files and imports, ensuring new types are immediately recognized by the Sanity Studio.
  • 4. Singleton and Object Configuration: Efficiently set up complex embedded objects or singleton documents (like site settings) with built-in reminders for necessary Desk Structure configurations.
namesanity-scaffold
descriptionInteractively scaffold a new Sanity Schema Document or Object type using best-practice templates. Use when user wants to create new content types.

Schema Scaffolder

This skill guides the user to create a new Sanity document type, ensuring it follows the "Data > Presentation" philosophy and strict typing rules.

Procedure

  1. Discovery

    • Run ls -R src/schemaTypes (or schemas) to understand the project structure.
    • Read src/schemaTypes/index.ts (or equivalent) to see how schemas are registered.
  2. Input Gathering

    • Ask: "What is the name of the content type (e.g., 'blogPost', 'author')?"
    • Ask: "Is this a Document (standalone) or an Object (embedded)?"
    • Ask: "What are the key fields needed?"
  3. Drafting (Template Based)

    • Action: Read the template file: templates/document.ts (or templates/object.ts / templates/singleton.ts).
    • Action: Create the new file content by replacing the {{name}} and {{title}} placeholders in the template with the user's input.
    • Constraint: Ensure the icon import is preserved or updated to a relevant icon from @sanity/icons.
    • Singleton Note: If using singleton.ts, remind user that singletons require Desk Structure configuration (see template comments). Offer to help set up the structure.
  4. Execution

    • Write the generated file to the correct folder (e.g., src/schemaTypes/documents/).
    • Read src/schemaTypes/index.ts.
    • Add the import line for the new schema.
    • Add the new type to the export array.
  5. Verification

    • Run npm run typegen (if available) to verify syntax.
    • Confirm success to the user.