Skip to main content
在 Manus 中运行任何 Skill
一键导入

sanity-keys-and-ids

星标16
分支7
更新时间2026年7月7日 16:25

How to handle Sanity document `_id`s and array `_key`s correctly across every write surface in this repo. Covers why deterministic IDs (hashed emails, derived strings) are an anti-pattern, the reference-field + GROQ-filter pattern that replaces them, and the per-surface mechanism for `_key` generation: `autoGenerateArrayKeys` for `@sanity/client`, automatic key handling in App SDK hooks (`useEditDocument`, `useApplyDocumentActions`), and automatic key handling in `sanity/migrate`. Use when writing or reviewing any code that creates, upserts, or patches Sanity content -- particularly `client.create*`, `client.patch().commit()`, mutations from `@sanity/sdk-react`, or `defineMigration`. Triggers on `_id`, `_key`, `generateKey`, hashed document IDs, `createIfNotExists`, `append/insert/setIfMissing`, and any helper that builds a Sanity `_id` or `_key` from another value.

安装

用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。

SKILL.md
readonly