sanity-install-rules

Installs Sanity agent rules directly into the local project. Use when setting up a new editor environment.

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

When & Why to Use This Skill

The sanity-install-rules skill automates the setup of official Sanity agent rules within your local development environment. It streamlines the integration of Sanity.io best practices into AI-powered editors like Cursor by automatically downloading and configuring MDC files for schemas, GROQ queries, typegen, and framework-specific optimizations, ensuring your AI assistant has the full context needed for Sanity development.

Use Cases

  • New Project Onboarding: Quickly bootstrap a new Sanity project by installing all necessary AI context rules, saving developers from manual configuration of editor rules.
  • Framework-Specific Optimization: Automatically detect and install tailored rules for Next.js, Remix, Nuxt, or Svelte to provide the AI with framework-aware coding patterns.
  • Standardizing Best Practices: Ensure consistent development across teams by deploying official Sanity guidelines for GROQ, portable text, and visual editing directly into the local workspace.
namesanity-install-rules
descriptionInstalls Sanity agent rules directly into the local project. Use when setting up a new editor environment.

Install Agent Rules

This skill downloads the official Sanity agent rules and saves them to the user's local .cursor/rules directory.

Procedure

  1. Check Environment

    • Check if .cursor/rules/ exists. If not, create it.
  2. Fetch & Write Rules

    • Load sanity://rules/sanity-schema.mdc -> Write to .cursor/rules/sanity-schema.mdc
    • Load sanity://rules/sanity-groq.mdc -> Write to .cursor/rules/sanity-groq.mdc
    • Load sanity://rules/sanity-typegen.mdc -> Write to .cursor/rules/sanity-typegen.mdc
    • Load sanity://rules/sanity-visual-editing.mdc -> Write to .cursor/rules/sanity-visual-editing.mdc
    • Load sanity://rules/sanity-migration.mdc -> Write to .cursor/rules/sanity-migration.mdc
    • Load sanity://rules/sanity-page-builder.mdc -> Write to .cursor/rules/sanity-page-builder.mdc
    • Load sanity://rules/sanity-image.mdc -> Write to .cursor/rules/sanity-image.mdc
    • Load sanity://rules/sanity-portable-text.mdc -> Write to .cursor/rules/sanity-portable-text.mdc
    • Load sanity://rules/sanity-studio-structure.mdc -> Write to .cursor/rules/sanity-studio-structure.mdc
    • Load sanity://rules/sanity-get-started.mdc -> Write to .cursor/rules/sanity-get-started.mdc
    • Load sanity://rules/sanity-project-structure.mdc -> Write to .cursor/rules/sanity-project-structure.mdc
    • Load sanity://rules/sanity-localization.mdc -> Write to .cursor/rules/sanity-localization.mdc
    • Load sanity://rules/sanity-seo.mdc -> Write to .cursor/rules/sanity-seo.mdc
    • Load sanity://rules/sanity-hydrogen.mdc -> Write to .cursor/rules/sanity-hydrogen.mdc

    Framework Specifics (Conditional):

    • Ask user or detect framework.
    • If Next.js: Load sanity://rules/sanity-nextjs.mdc
    • If Remix: Load sanity://rules/sanity-remix.mdc
    • If Svelte: Load sanity://rules/sanity-svelte.mdc
    • If Nuxt: Load sanity://rules/sanity-nuxt.mdc
    • If Astro: Load sanity://rules/sanity-astro.mdc
  3. Update Configuration

    • Check for .cursorrules or agents.md.
    • Append a reference to the new rules if needed.
  4. Confirmation

    • Tell the user: "Agent rules have been installed locally. Your AI editor now knows Sanity best practices."