Skip to main content
Run any Skill in Manus
with one click

sanity-keys-and-ids

Stars16
Forks7
UpdatedJuly 7, 2026 at 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.

Installation

Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.

SKILL.md
readonly