sanity-best-practices — скилл: практики Sanity для Claude Code
Набор правил разработки на Sanity для ИИ-агента: схемы, GROQ, TypeGen, визуальный редактор, миграции и подключение к фронтенд-фреймворкам. Нужен, когда агент правит код проекта на Sanity.
npx skills add sanity-io/agent-toolkit --skill sanity-best-practices -a claude-codeЧто делает sanity-best-practices
Скилл ведёт команда Sanity в репозитории sanity-io/agent-toolkit. Внутри лежат справочники references/*.md: отдельные файлы под GROQ, проектирование схем, TypeGen, визуальное редактирование, Portable Text, картинки, миграции, Sanity Functions, Blueprints. Есть и гайды по фреймворкам: Next.js, Nuxt, Astro, Remix, SvelteKit, Angular, Hydrogen, App SDK, приложения в Dashboard через defineApplication. Агент открывает один-два файла под задачу, а не весь набор, поэтому контекст не раздувается.
Часть правил задана жёстко. _id обычных документов генерирует сама Sanity: детерминированные UUID и идентификаторы из слагов ломают связи. Связи описывают полем reference, а достают запросом GROQ. Явный ID оставляют для синглтонов, которыми управляет Studio Structure, включая локализованные вроде homePage-en.
С видео стоит быть осторожным. Ассеты в поле file отдаются как обычная загрузка, без транскодинга и адаптивного стриминга, поэтому трафик и счёт растут быстро. Sanity Media Library стримит видео через Mux, но работает на плане Enterprise с видео-аддоном, а поле описывают через defineVideoField() из sanity/media-library. На других планах остаётся sanity-plugin-mux-input или ссылка на YouTube и Vimeo. Если в проекте уже есть видео, первым делом проверьте план аккаунта.
Какие задачи решает
- спроектировать схему документов с валидацией и без ручных
_id - написать GROQ-запрос, который подтягивает связанные документы
- подключить Sanity Studio к Next.js App Router или Astro
- настроить TypeGen, чтобы типы совпадали со схемой
- перенести старый HTML-контент в Portable Text
Примеры запросов агенту
- Проверь схему
postвschemas/и переведи ссылку на автора в полеreferenceс подстановкой через GROQ. - Добавь TypeGen в проект на Next.js и поправь типы запросов в
lib/queries.ts. - Настрой Presentation Tool и визуальное редактирование для страницы товара.
Как установить sanity-best-practices
1Через Skills CLI (Vercel)
npx skills add sanity-io/agent-toolkit --skill sanity-best-practices -a claude-code2Вручную: положить файлы
~/.claude/skills/sanity-best-practices/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/sanity-best-practices/
1Через Skills CLI (Vercel)
npx skills add sanity-io/agent-toolkit --skill sanity-best-practices -a codex2Вручную: положить файлы
.agents/skills/sanity-best-practices/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add sanity-io/agent-toolkit --skill sanity-best-practices -a cursor2Вручную: положить файлы
.cursor/skills/sanity-best-practices/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install sanity-io/agent-toolkit sanity-best-practices2Вручную: положить файлы
.github/skills/sanity-best-practices/SKILL.md1Через Skills CLI (Vercel)
npx skills add sanity-io/agent-toolkit --skill sanity-best-practices -a gemini-cli2Командой платформы
gemini skills install https://github.com/sanity-io/agent-toolkit --path skills/sanity-best-practicesВручную: положить файлы
.devin/skills/sanity-best-practices/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add sanity-io/agent-toolkit --skill sanity-best-practices -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Из того же набора9
Похожие
Рядом в теме «Фронтенд и UI»
Всё по теме «Фронтенд и UI» →Вопросы о sanity-best-practices
Как установить sanity-best-practices в Claude Code?
Выполните npx skills add sanity-io/agent-toolkit --skill sanity-best-practices -a claude-code — скилл встанет в ~/.claude/skills/sanity-best-practices/SKILL.md.
Что делает этот скилл?
Даёт агенту правила и справочники по разработке на Sanity: схемы, GROQ, TypeGen, картинки, Portable Text, миграции, функции, Blueprints и интеграции с фреймворками. Агент читает только те файлы, которые нужны под текущую задачу.
Можно ли хранить видео в Sanity?
В поле file — нет, такие ассеты уходят как обычная загрузка без адаптивного стриминга. Для потокового видео нужен план Enterprise с видео-аддоном и Sanity Media Library, иначе ставят sanity-plugin-mux-input или хранят ссылку на внешний сервис.
Исходный текст
SKILL.md · MIT
--- name: sanity-best-practices description: Sanity development best practices for schema design, GROQ queries, TypeGen, Visual Editing, images, Portable Text, Studio structure, localization, migrations, Sanity Functions, webhooks, Blueprints, and framework integrations such as Next.js, Nuxt, Astro, Remix, SvelteKit, Angular, Hydrogen, the App SDK, and Studios or apps running in the Sanity Dashboard (defineApplication). Use this skill whenever working with Sanity schemas, defineType or defineField, GROQ or defineQuery, content modeling, Presentation or preview setups, Sanity-powered frontend integrations, event-driven content automation, documentEventHandler, defineDocumentFunction, defineMediaLibraryAssetFunction, @sanity/functions, @sanity/blueprints, sanity.blueprint.ts, event-driven content automation, or when reviewing and fixing a Sanity codebase. --- # Sanity Best Practices Comprehensive best practices and integration guides for Sanity development, maintained by Sanity. Use the quick reference below to load only the one or two topic files that match the task. ## When to Apply Reference these guidelines when: - Setting up a new Sanity project or onboarding - Integrating Sanity with a frontend framework (Next.js, Nuxt, Astro, Remix, SvelteKit, Hydrogen) - 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 - Building custom apps with the Sanity App SDK - Developing or deploying a Studio or app in the Sanity Dashboard - Managing infrastructure with Blueprints - Automating content workflows with Sanity Functions or webhooks ## Global Rules - Let Sanity generate `_id` values for ordinary documents. Do not create deterministic UUIDs, slug-derived IDs, or legacy-system IDs when creating documents. - Model relationships with `reference` fields, then resolve related documents with GROQ lookups, source-key fields, or returned `_id` values from created documents. - Use explicit document IDs mainly for singleton documents controlled by Studio Structure, including localized singletons such as `homePage-en`. ## Video - Do not store or serve video from Sanity `file` assets for production playback. File assets are delivered as raw downloads with no transcoding or adaptive streaming, and video traffic drives very high bandwidth usage and unexpectedly large bills. - On Enterprise plans with the video add-on, use Sanity Media Library for video: uploads are transcoded and streamed adaptively via Mux. Model video fields with `defineVideoField()` from `sanity/media-library` and play them with `@mux/mux-player-react` using the asset's playback ID. - On other plans, use a dedicated video service: install `sanity-plugin-mux-input` to upload and manage videos in your Mux account from the Studio, or host video on a platform such as YouTube or Vimeo and store only the embed URL in Sanity. - Small clips and short previews in a `file` field are acceptable, but any user-facing video at scale must go through Media Library or a streaming service. ## Quick Reference ### Integration Guides - `get-started` - Interactive onboarding for new Sanity projects - `nextjs` - Next.js App Router, Live Content API, standalone Studio - `nuxt` - Nuxt integration with @nuxtjs/sanity - `angular` - Angular integration with @sanity/client, signals, resource API - `astro` - Astro integration with @sanity/astro - `remix` - React Router / Remix integration - `svelte` - SvelteKit integration with @sanity/svelte-loader - `hydrogen` - Shopify Hydrogen with Sanity - `project-structure` - Standalone Studio and monorepo patterns - `app-sdk` - Custom applications with Sanity App SDK - `dashboard` - Studios and apps in the Sanity Dashboard: defineApplication, local dev, deploys, Dashboard hooks - `blueprints` - Infrastructure as Code: blueprint files, stacks, plan/deploy workflow, error recovery, CI deploys - `functions` - Automating content workflows with Sanity Functions and webhooks ### Topic Guides - `groq` - GROQ query patterns, type safety, performance optimization - `schema` - Schema design, field definitions, validation, deprecation patterns - `visual-editing` - Presentation Tool, Stega, overlays, live preview - `page-builder` - Page Builder arrays, block components, live editing - `portable-text` - Rich text rendering and custom components - `image` - Image schema, URL builder, hotspots, LQIP, Next.js Image - `studio-structure` - Desk structure, singletons, navigation - `typegen` - TypeGen configuration, workflow, type utilities - `seo` - Metadata, sitemaps, Open Graph, JSON-LD - `localization` - i18n patterns, document vs field-level, locale management - `migration` - Content import overview (see also `migration-html-import`) - `migration-html-import` - HTML to Portable Text with @portabletext/block-tools ## How to Use Start with the single framework or topic guide that best matches the request, then read additional references only when the task crosses concerns. Use these reference files for detailed explanations and code examples: ``` references/groq.md references/schema.md references/nextjs.md ``` Each reference file contains: - Comprehensive topic or integration coverage - Incorrect and correct code examples - Decision matrices and workflow guidance - Framework-specific patterns where applicable
© sanity-io · MIT · sanity-io/agent-toolkit