sanity
БесплатноБез исполняемых скриптовНе проверенSanity is a headless CMS that stores structured content in a hosted Content Lake, edited in a React-based Studio and queried with GROQ. Use when defining…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Sanity
Overview
Sanity keeps content as JSON documents in a hosted Content Lake. You define document types in code, edit them in Sanity Studio (a React app you own and deploy), and read them from any frontend with GROQ through @sanity/client. Rich text is stored as Portable Text (structured JSON, not HTML). For Next.js, next-sanity bundles the client, a live-content helper (defineLive), Draft Mode and the visual-editing overlay. Versions checked: sanity 6.20.0, @sanity/client 8.11.0, next-sanity 13.4.0 (npm, October 2026).
Instructions
Create a Studio or add Sanity to an app
npm create sanity@latest -- --dataset production --template clean --typescript --output-path studio
cd studio && npm run dev # Studio on http://localhost:3333
npx sanity@latest init # inside an existing Next.js project: detects it and embeds the Studio
Current packages require Node.js 22.12 or later (next-sanity also accepts 20.19+). Datasets are public by default; use a private dataset or a read token for anything sensitive.
Schemas
Define types with defineType and defineField from sanity, and register them in sanity.config.ts under schema.types. Studio plugins are tools such as structureTool() (from sanity/structure, replaces the old desk tool) and presentationTool() (from sanity/presentation).
import {defineType, defineField, defineArrayMember} from 'sanity'
export const post = defineType({
name: 'post',
title: 'Post',
type: 'document',
fields: [
defineField({name: 'title', type: 'string', validation: (rule) => rule.required().max(90)}),
defineField({name: 'slug', type: 'slug', options: {source: 'title'}, validation: (rule) => rule.required()}),
defineField({name: 'cover', type: 'image', options: {hotspot: true}}),
defineField({name: 'author', type: 'reference', to: [{type: 'author'}]}),
defineField({name: 'body', type: 'array', of: [defineArrayMember({type: 'block'}), defineArrayMember({type: 'image'})]}),
],
})
Model content for reuse: use references for shared documents and objects for page-builder blocks. After changing schemas run npx sanity schemas extract and npx sanity typegen generate to get typed query results.
GROQ
*[_type == "post" && defined(slug.current)] | order(publishedAt desc)[0...10]{
_id, title, "slug": slug.current, "author": author->name
}
Project only the fields you need; -> follows a reference. Wrap queries in defineQuery (from groq or next-sanity) so TypeGen can type them. The client is createClient({projectId, dataset, apiVersion, useCdn}) from @sanity/client. Always pin apiVersion to a date. Since API version 2025-02-19 the client's default perspective is published; use perspective: 'drafts' with a token to read drafts. useCdn: true suits published reads in the browser or high-traffic pages; use false when fresh data is required (static generation, webhook-triggered revalidation, preview).
Images and Portable Text
import {createImageUrlBuilder} from '@sanity/image-url'
const builder = createImageUrlBuilder(client)
export const urlFor = (source: any) => builder.image(source)
// urlFor(post.cover).width(1200).height(630).auto('format').url()
The package is @sanity/image-url (not sanity-image-url); install it with npm i @sanity/image-url (sanity depends on it for the Studio, but next-sanity does not install it). Hotspot and crop data are applied automatically when you pass the image object. Render Portable Text with @portabletext/react (<PortableText value={post.body} />, components prop for custom blocks).
Next.js (App Router) with live content and visual editing
Environment: NEXT_PUBLIC_SANITY_PROJECT_ID, NEXT_PUBLIC_SANITY_DATASET, and a server-only SANITY_API_READ_TOKEN with the Viewer role. Add the frontend origin (for example http://localhost:3000) as a CORS origin with credentials: npx sanity cors add http://localhost:3000 --credentials.
// src/sanity/lib/client.ts
import {createClient} from 'next-sanity'
export const client = createClient({
projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID!,
dataset: process.env.NEXT_PUBLIC_SANITY_DATASET!,
apiVersion: '2026-02-01',
useCdn: true,
stega: {studioUrl: 'http://localhost:3333'},
})
// src/sanity/lib/live.ts
import {defineLive} from 'next-sanity/live'
import {client} from './client'
export const {sanityFetch, SanityLive} = defineLive({
client,
serverToken: process.env.SANITY_API_READ_TOKEN,
browserToken: process.env.SANITY_API_READ_TOKEN,
})
- Fetch in server components with
sanityFetch({query, params})instead ofclient.fetch; it handles caching, perspective (published vs drafts in Draft Mode) and stega encoding. Passstega: falseingenerateMetadataandgenerateStaticParams, because invisible characters break titles and URLs. - In the root layout render `
Установить sanity в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл sanity?
Sanity is a headless CMS that stores structured content in a hosted Content Lake, edited in a React-based Studio and queried with GROQ. Use when defining Sanity schemas, writing GROQ queries, configuring Sanity Studio, rendering Portable Text, or wiring Sanity into Next.js with next-sanity, Draft Mode and visual editing. Trigger words: sanity, groq, sanity studio, portable text, content lake, sanity schema, next-sanity.
Как установить скилл sanity?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл sanity запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic