sanity
Assists with building content platforms using Sanity's structured content and real-time collaboration features. Use when defining schemas, writing GROQ queries, configuring Sanity Studio, or integrating with Next.js for content-driven sites. Trigger words: sanity, groq, sanity studio, structured content, portable text, content lake, sanity schema.
What this skill does
# Sanity
## Overview
Sanity is a structured content platform with real-time collaboration, GROQ querying, and a customizable React-based Studio. Content is stored in the Content Lake with CDN delivery, Portable Text for structured rich content, and visual editing capabilities for live frontend previews.
## Instructions
- When defining schemas, use `defineType()` and `defineField()` with validation rules, model content for reuse by separating pages from content blocks, and use references over inline objects for shared content.
- When querying data, write GROQ queries with projections to fetch only needed fields, use the `->` dereference operator for joined data, and set `useCdn: true` for production reads.
- When customizing Sanity Studio, configure desk structure for sidebar navigation, add custom input components for specialized editing, and create custom publish workflows with actions.
- When building rich content, use Portable Text which is structured data (not HTML) that renders on any platform, with customizable toolbar, custom blocks, and inline objects.
- When integrating with Next.js, use `next-sanity` with ISR, preview mode, and visual editing, and `@sanity/visual-editing` for click-to-edit overlays in the frontend.
- When managing environments, use datasets (production, staging, development) for content isolation, GROQ-powered webhooks for filtered build triggers, and set `apiVersion` to a specific date to avoid breaking changes.
- When handling images, use Sanity's image with hotspot for focal point selection and `sanity-image-url` for generating responsive image URLs with transforms.
## Examples
### Example 1: Build a content-driven marketing site
**User request:** "Set up Sanity with Next.js for a marketing site with modular page builder"
**Actions:**
1. Define page, hero, feature, CTA, and testimonial schemas as reusable block types
2. Configure Sanity Studio with desk structure and live preview
3. Set up `next-sanity` with ISR and GROQ queries for each page type
4. Enable visual editing with `@sanity/visual-editing` for click-to-edit overlays
**Output:** A modular marketing site where editors build pages from reusable content blocks with live preview.
### Example 2: Implement real-time content preview
**User request:** "Add live preview to our Sanity + Next.js site so editors see changes as they type"
**Actions:**
1. Configure Sanity Studio's Presentation tool for side-by-side editing
2. Set up `@sanity/visual-editing` in the Next.js frontend for click-to-edit overlays
3. Use `client.listen()` for real-time content updates in preview mode
4. Configure draft content display with `!(_id in path("drafts.**"))` filtering
**Output:** A live editing experience where content changes appear in the frontend as editors type.
## Guidelines
- Use `defineType()` and `defineField()` for schema definitions; they provide TypeScript types for the Studio.
- Model content for reuse: separate pages from content blocks so blocks can appear on any page.
- Use references over inline objects for content that appears in multiple places.
- Query with GROQ projections to fetch only needed fields, not entire documents.
- Use the CDN API (`useCdn: true`) for production reads; it is free and fast.
- Set `apiVersion` to a specific date to avoid breaking changes.
- Use Portable Text for rich content; it is structured data that renders on any platform.
Related in Web Dev
generating-lwc-components
IncludedLightning Web Components with PICKLES methodology and 165-point scoring. Use this skill when the user creates or edits LWC components, builds wire service patterns, or writes Jest tests for LWC. TRIGGER when: user creates/edits LWC components, touches lwc/**/*.js, .html, .css, .js-meta.xml files, or asks about wire service, SLDS, or Jest LWC tests. DO NOT TRIGGER when: Apex classes (use generating-apex), Aura components, or Visualforce.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Set up queries with useQuery, mutations with useMutation, configure QueryClient caching strategies, implement optimistic updates, and handle infinite scroll with useInfiniteQuery. Use when: setting up data fetching in React projects, migrating from v4 to v5, or fixing object syntax required errors, query callbacks removed issues, cacheTime renamed to gcTime, isPending vs isLoading confusion, keepPreviousData removed problems.
document-processor-api
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
nutrient-document-processing
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Covers useMutationState, simplified optimistic updates, throwOnError, network mode (offline/PWA), and infiniteQueryOptions. Use when setting up data fetching, fixing v4→v5 migration errors (object syntax, gcTime, isPending, keepPreviousData), or debugging SSR/hydration issues with streaming server components.
accelint-nextjs-best-practices
IncludedNext.js performance optimization and best practices. Use when writing Next.js code (App Router or Pages Router); implementing Server Components, Server Actions, or API routes; optimizing RSC serialization, data fetching, or server-side rendering; reviewing Next.js code for performance issues; fixing authentication in Server Actions; or implementing Suspense boundaries, parallel data fetching, or request deduplication.