ワンクリックで
sanity-data-operations
Manage Sanity content -- schema changes, data migrations, debugging queries, batch operations, and revalidation.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Manage Sanity content -- schema changes, data migrations, debugging queries, batch operations, and revalidation.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Migrate from Next.js 15 to Next.js 16 and handle breaking changes
Configure Content Security Policy and security headers for the portfolio
Deploy Next.js to Cloudflare Workers using OpenNext adapter
Manage the canary token honeypot system for detecting security scanning
Write, debug, and optimize GROQ queries for Sanity CMS in this portfolio
Advanced TypeScript patterns and type safety as used in this portfolio
| name | sanity-data-operations |
| description | Manage Sanity content -- schema changes, data migrations, debugging queries, batch operations, and revalidation. |
| Field | Value |
|---|---|
| Project ID | namias-cms (from NEXT_PUBLIC_SANITY_PROJECT_ID) |
| Dataset | production (from NEXT_PUBLIC_SANITY_DATASET) |
| Studio URL | http://localhost:3333 (local) / https://namias-cms.sanity.studio (prod) |
| API version | 2024-01-01 |
List all document types:
cd studio && npx sanity schema list
View a specific schema:
cd studio && npx sanity schema describe <documentType>
Common document types in this project:
| Type | Purpose |
|---|---|
profile | Hero section: name, title, role rotator, email, image |
project | Portfolio projects with title, slug, summary, tech, images |
experience | Work history: role, company, dates, highlights |
certification | Credentials: issuer, dates, expiry, credential URL |
blogPost | Blog articles with Portable Text body, categories |
socialLink | Social media links displayed in Connect section |
skill | Skills displayed in the Skills section |
siteSettings | Global site configuration |
Check if data exists via API:
curl "https://namias-cms.api.sanity.io/v2024-01-01/data/query/production?query=*[_type=='profile'][0]{name,email}"
Common query patterns:
// All projects
*[_type == "project"] | order(order asc) { title, slug, summary }
// Single project by slug
*[_type == "project" && slug.current == $slug][0]
// Published documents only (exclude drafts)
*[_type == "project" && !(_id in path("drafts.**"))]
// Count documents
count(*[_type == "blogPost"])
Debug in Sanity Studio:
http://localhost:3333Using Sanity CLI:
cd studio && npx sanity document create <type>
cd studio && npx sanity document edit <documentId>
cd studio && npx sanity document delete <documentId>
Using GROQ mutations (via API):
curl -X POST "https://namias-cms.api.sanity.io/v2024-01-01/data/mutate/production" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{
"mutations": [{
"patch": {
"id": "<documentId>",
"set": { "title": "New Title" }
}
}]
}'
How revalidation works:
/api/sanity/revalidate when content changesrevalidateTag() to invalidate cached dataTrigger manual revalidation:
curl -X POST "http://localhost:3000/api/sanity/revalidate" \
-H "Content-Type: application/json" \
-d '{"secret": "<SANITY_REVALIDATE_SECRET>"}'
Check revalidation is working:
revalidate period (or on manual trigger)Common revalidation issues:
| Symptom | Cause | Fix |
|---|---|---|
| Changes don't appear | Webhook not configured | Check Sanity webhook settings |
| Stale data persists | Tag not invalidated | Check revalidateTag() calls in route handlers |
| 401 on revalidate | Wrong secret | Verify SANITY_REVALIDATE_SECRET env var |
| Build shows old data | ISR cache | Redeploy or wait for revalidation period |
Sanity webhook setup:
https://<your-domain>/api/sanity/revalidatecreate, update, delete_type in ["project", "experience", "certification", "blogPost", "profile"]SANITY_REVALIDATE_SECRETnpm run sanity:seed
This runs scripts/sanity/seed-demo.ts which creates sample documents for development.
Add a new field to an existing document:
studio/schemas/<documentType>.tscd studio && npx sanity typegen generate (if using typegen)localhost:3333Add a new document type:
studio/schemas/<newType>.tsstudio/schemas/index.tsstructureDeskTool in studio/deskStructure.tsrevalidate on fetch calls ({ next: { revalidate: 60 } })null responses from Sanity (always use ?? defaultValue)