Install
openclaw skills install @squidpunch/sanity-cmsPublish content to any Sanity CMS instance. Use when asked to create a Sanity draft, push a document to Sanity, upload an image asset to Sanity, or convert content into a Sanity-formatted document. Works with any document type and schema — not limited to blog posts. Requires SANITY_PROJECT_ID and SANITY_API_TOKEN env vars.
openclaw skills install @squidpunch/sanity-cmsPublishes documents to Sanity CMS via the Content API. Works with any schema.
references/api.mdreferences/portable-text.mdFour ways to get schema info — try in this order:
A — File in workspace: User drops schema at a known path (e.g. sanity-schemas/blogPost.ts). Read it directly.
B — Pasted in chat: User pastes the schema TypeScript/JS. Read it from the conversation.
C — Remote URL: User shares a GitHub raw URL or similar. Fetch with web_fetch.
D — API introspection (no file needed): Query the dataset directly — see references/api.md (Schema Introspection section). Use array::unique(*[]._type) to discover document types, then fetch one sample document to infer field names and shapes. Works without any schema file at all.
Once you have the schema (by any method):
array fields with type: 'block', use Portable Text format — see references/portable-text.mdreference fields (categories, authors, tags), query existing documents via GROQ — see references/api.mdBuild a JSON object matching the schema:
_id — the script generates a drafts. prefixed UUID automaticallybrain/projects/<slug>-sanity.json or similar)The script is at scripts/publish_draft.sh within this skill directory. Resolve the path relative to where the skill is installed (e.g. ~/.openclaw/skills/sanity-cms/scripts/publish_draft.sh or <workspace>/skills/sanity-cms/scripts/publish_draft.sh).
bash <skill-dir>/scripts/publish_draft.sh \
path/to/document.json \
path/to/cover-image.png # optional
Optional env overrides:
| Var | Default | Purpose |
|---|---|---|
SANITY_DATASET | production | Target dataset |
COVER_IMAGE_FIELD | coverImage | Field name for cover image |
DRAFT_PREFIX | true | Set to false to publish immediately |
Example with overrides:
SANITY_DATASET=staging COVER_IMAGE_FIELD=mainImage \
bash <skill-dir>/scripts/publish_draft.sh doc.json cover.jpg
After the script prints a draft ID, report to the user:
| Var | Description |
|---|---|
SANITY_PROJECT_ID | Sanity project ID |
SANITY_API_TOKEN | Write-enabled token (Editor or higher) |
SANITY_DATASET | Dataset (optional, default: production) |
DRAFT_PREFIX=true) unless the user explicitly wants to publish livereference fields, query for the referenced document IDs via GROQ before building the JSON — see references/api.md