Codex already lives in your terminal, a few keystrokes from sanity exec and a mutation script. The difference between Codex on a Scratch folder and a script with a robot token is that one shows you the diff first. The pass you want, tighten every excerpt and fill the empty SEO descriptions, should be a diff you read, not a transaction you commit and hope about.
Scratch pulls your dataset down, one file per published document. Codex edits the fields on your laptop and reports back like a code change; Scratch shows each one as a diff; it publishes only the changes you approve, as sparse patches through Sanity's transactional Mutation API. Your schema, assets, and drafts stay untouched.
How it works
- Scratch pulls your dataset into files. Every published document becomes a local JSON file, organized by document type, with your deployed Studio schema keeping your authored field order and titles.
- Codex edits the documents. Point Codex at the Scratch folder and describe the change. It works the dataset the way it works a codebase, and you read the result like a pull request. Tighten every excerpt to two sentences and fill the empty SEO descriptions. Codex works the files, never the live Content Lake.
- You review every diff and publish. Scratch shows each changed field beside the original, word by word. Approve what holds up, and Scratch publishes only those changes through the Mutation API.
What people use it for
The content edits that turn into GROQ queries and mutation scripts because the Studio only does one document at a time:
- Run a tone or terminology pass across every post, page, and product.
- Fill empty SEO titles and meta descriptions across a document type.
- Normalize slugs and titles so published URLs are consistent.
- Rewrite Portable Text bodies without flattening them to plain text.
- Re-point references in bulk, like moving posts between authors or categories.
Run it on 50 documents to feel the loop, then turn it loose on the dataset.
Why not the Sanity MCP server?
The Sanity MCP, or a mutation script with a robot token, hands Codex a live write path to the Content Lake. Every mutation publishes immediately to the same content your site serves, with no review in between.
Scratch gives Codex the same full read and write access, but against a local copy. The publish step is pulled out and handed to you. Codex can change anything editable; only you can commit it. On the content your site renders to visitors, that is the difference that matters.
What Codex edits in Sanity
- Titles, slugs, and string fields across every document type
- Portable Text rich text, kept as the structured blocks Sanity stores
- Numbers, booleans, datetimes, tags, and nested objects like SEO settings
- References between documents, single or arrays
Scratch edits field values, never your schema: document types, validation rules, and the Studio stay defined exactly as you wrote them. System fields are read-only, image and file assets are out of scope, and drafts are untouched. For the full picture, see Scratch for Sanity.
Questions people ask
Is this the Sanity MCP server?
No. The MCP hands Codex a live mutation path to your Content Lake. Scratch keeps it. Codex gets the same access, and publishing is a separate step you approve, one document at a time.
Does it mangle Portable Text?
No. Portable Text stays the structured blocks Sanity stores, so marks, links, and nested lists survive the round trip. Images and custom blocks inside rich text stay as they are: Codex edits the prose around them.
Can I roll a change back after it publishes?
Yes. Scratch keeps the original beside the rewrite, so every published change reverts per document. You decide which version stays.
How is this different from a GROQ query and a mutation script?
A script does exactly what you spelled out and nothing smarter, and it publishes straight to the Content Lake with no document-by-document review. Codex handles the documents a single script cannot, and Scratch still holds every change for review before it commits.
Can it run across a whole dataset from one prompt?
Yes, that is the use case. Run it on 50 documents to feel the flow, then point it at the whole dataset.
Do I need to be technical?
Connecting Sanity takes a robot token from sanity.io/manage, which is a copy-paste step. Scratch finds the project and dataset itself. After that the loop is the same as any Scratch source: run Codex on the folder, then approve the diffs.
See it on your own dataset
The fastest way to trust it is to watch it run on your data. Book a 30-minute demo on your Sanity dataset →, or try Scratch free and take the first pass yourself.