// Expert assistance for writing, optimizing, and debugging GROQ queries. Use when writing queries or debugging performance.
| name | sanity-groq |
| description | Expert assistance for writing, optimizing, and debugging GROQ queries. Use when writing queries or debugging performance. |
This skill helps users write GROQ queries that are efficient, correct, and compatible with Sanity TypeGen.
Analyze Request
Drafting Queries
defineQuery (or groq tag)./* groq */ comment for syntax highlighting.{ ... }. Never return * (naked projection).const QUERY = defineQuery(/* groq */ `*[_type == "post" && slug.current == $slug][0]{ title, body }`);
Optimization Checks
*[_type == "..."] without {}. -> Warn: "Fetch only what you need."slug == "${slug}"). -> Warn: "Use parameters ($slug)."...). -> Warn: "Be explicit to reduce payload size."TypeGen Integration
npm run typegen (or equivalent).import { type QUERYResult } from './sanity.types'.