sanity-singletons
БесплатноБез исполняемых скриптовНе проверенConfigure singleton documents in a Sanity Studio using the document.singletons registry. Use when a developer wants a fixed-id document (settings, navigation…
от sanity-io★ 203 звезды на GitHubОб этом скилле
Sanity Singletons
A "singleton" is a document with a fixed id that can be created exactly once. Common examples: site settings, navigation, footer content. Studio supports singletons as a first-class primitive via the document.singletons configuration registry plus a small set of Structure Tool helpers.
Requires sanity 6.17.0 or later. Check the installed version in the lockfile before using this API. On older Studios, either upgrade first or use the userland pattern (fixed documentId in a custom structure, plus manual newDocumentOptions and duplicate filtering) described in sanity-best-practices → studio-structure.
When to use this skill
- A developer asks how to create a "settings document" or "singleton".
- A studio configuration needs a
document.singletonsregistry entry. - Structure Tool needs to render a singleton as a list item or document pane.
- You're migrating an existing userland singleton implementation to the first-class API.
- You're migrating from a third-party singleton plugin such as
sanity-plugin-singleton-management(or its predecessorsanity-plugin-singleton-tools).
Registering a singleton
Singletons are registered in configuration, not on the schema type. A singleton definition binds a definition id to a document id and a schema type:
import {defineConfig, defineSingleton} from 'sanity'
export default defineConfig({
schema: {
types: [/* siteSettings and campaign are ordinary document types */],
},
document: {
singletons: [
// String shorthand — expands to
// {id: 'siteSettings', documentId: 'siteSettings', schemaType: 'siteSettings'}
'siteSettings',
// Definition object. `defineSingleton` is an optional typed identity
// helper; a plain object literal works too. `id` is omitted here, so it
// inherits each `documentId`.
defineSingleton({
documentId: 'springCampaign',
schemaType: 'campaign',
title: 'Spring campaign', // optional display metadata
initialValue: {season: 'spring'}, // optional per-singleton initial value
}),
defineSingleton({
documentId: 'summerCampaign',
schemaType: 'campaign',
title: 'Summer campaign',
initialValue: {season: 'summer'},
}),
],
},
})
Key facts:
defineSingletonproduces a singleton definition, not a document schema. The schema type it references is defined separately withdefineTypeand needs no singleton-specific configuration.- Multiple singletons may share a schema type (like the two campaigns above), each with its own
title,icon, andinitialValue(falling back to the schema type's), and a shared schema type may also back ordinary documents. - The definition id is the singleton's stable identity, and it is optional — it inherits
documentIdwhen omitted. Structure code references it (S.listItem().singleton('springCampaign')). Set it explicitly only to be verbose, to guard against future collisions, or to address a singleton universally when different workspaces or environments map it to different document ids. - A resolver function is also accepted:
singletons: (prev, context) => [...prev, ...]. Resolvers only ever receive fully resolved definitions (string shorthands are expanded first).
Validation at config-resolution time (all failures aggregate into one ConfigResolutionError):
id: non-empty, unique across definitions (inherited ids count — an explicit id may not collide with another definition's inherited one). Used verbatim as a Structure Tool node id, so it is limited to[a-zA-Z0-9._-]and may not start with__edit__. It also may not match the name of a document type that no singleton claims, since the default content list keys both by id (the string shorthand never trips this — the type it names is claimed by the definition itself). A type claimed by a singleton withallowNonSingletonDocuments: truekeeps its own list item, so it counts as unclaimed for this check.documentId: non-empty, unique, published-id shaped (nodrafts./versions.prefix, only[a-zA-Z0-9._-]).schemaType: must name an existing document type. Need not be unique.- Templates: an untagged template must not reuse a definition id (the generated singleton template claims it); at most one template may carry a given
singletontag; tags must reference registered definitions.
What Studio does automatically
- Generates a dedicated initial value template per singleton — tagged with the definition id via
ResolvedTemplate.singleton, value fromdefinition.initialValue ?? schemaType.initialValue— instead of the plain per-type template (unless the type opts in withallowNonSingletonDocuments), and removes tagged templates from every "create new" surface (global create menu, structure panes, reference inputs). The tagged template stays insource.templates, so opening the singleton before it exists s
Установить sanity-singletons в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл sanity-singletons?
Configure singleton documents in a Sanity Studio using the document.singletons registry. Use when a developer wants a fixed-id document (settings, navigation, footer) edited in place, hidden from the default content list, with no "create new" or "duplicate" affordances — or when migrating a userland singleton implementation or a third-party singleton plugin (e.g. sanity-plugin-singleton-management) to the first-class API.
Как установить скилл sanity-singletons?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл sanity-singletons запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic