Install any skill in seconds. Free to start, no credit card required.
Get Started Free →React Query conventions for data fetching in Supabase Studio. Use when writing or reviewing query hooks, mutation hooks, or query keys in apps/studio/data/ — including adding the first fetch or mutation for a new API endpoint or resource. Covers queryOptions pattern, keys.ts structure, mutation hook template, and imperative fetching.
.claude/skills/supabase-studio-queries/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | -19% | 0% |
| case-02 | ✗→✓ | ▲ Improved | -9% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 1% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 16% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 7% | 0% |
Follow the patterns in apps/studio/data/. Reference examples:
apps/studio/data/table-editor/table-editor-query.tsapps/studio/data/edge-functions/edge-functions-update-mutation.tsapps/studio/data/edge-functions/keys.tsDefine a keys.ts per domain. Export *Keys helpers using array keys with as const. Never inline query keys in components.
tsexport const edgeFunctionsKeys = { list: (projectRef: string | undefined) => ['projects', projectRef, 'edge-functions'] as const, detail: (projectRef: string | undefined, slug: string | undefined) => ['projects', projectRef, 'edge-function', slug, 'detail'] as const, }
Use queryOptions from @tanstack/react-query. This gives type safety and works with both useQuery() and queryClient.fetchQuery().
Rules:
XVariables, XData, and XError types (prefixed with the domain name)getX(variables, signal?) function:signal for cancellationhandleError(error) on failure (which throws); returns data on successqueryClient.fetchQuery(xQueryOptions(...)) for imperative fetchingxQueryOptions() using queryOptionsenabled so the query doesn't run until required variables existIS_PLATFORM from lib/constants in enabledxQueryOptions — callers override by destructuring: { ...xQueryOptions(vars), enabled: true }tsimport { queryOptions } from '@tanstack/react-query' import { xKeys } from './keys' import { get, handleError } from '@/data/fetchers' import { IS_PLATFORM } from '@/lib/constants' import { ResponseError } from '@/types' export type XVariables = { projectRef?: string } export type XError = ResponseError async function getX({ projectRef }: XVariables, signal?: AbortSignal) { if (!projectRef) throw new Error('projectRef is required') const { data, error } = await get('/v1/projects/{ref}/x', { params: { path: { ref: projectRef } }, signal, }) if (error) handleError(error) return data } export type XData = Awaited<ReturnType<typeof getX>> export const xQueryOptions = ({ projectRef }: XVariables) => queryOptions({ queryKey: xKeys.list(projectRef), queryFn: ({ signal }) => getX({ projectRef }, signal), enabled: IS_PLATFORM && typeof projectRef !== 'undefined', })
tsimport { useQuery } from '@tanstack/react-query' import { xQueryOptions } from '@/data/x/x-query' const { data, isPending, isError } = useQuery(xQueryOptions({ projectRef: project?.ref }))
tsconst queryClient = useQueryClient() const { data: project } = useSelectedProjectQuery() const handleClick = useCallback( async (id: number) => { const data = await queryClient.fetchQuery(xQueryOptions({ id, projectRef: project?.ref })) // use data... }, [project?.ref, queryClient] )
Variables type with projectRef, identifiers, and payloadupdateX(vars) function with required variable validation and handleErroruseXMutation():UseMutationOptions (omit mutationFn)list() + detail() keys in onSuccess with await Promise.all([...])toast.error(...) when onError isn't providedtsimport { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query' import { toast } from 'sonner' import { xKeys } from './keys' type XUpdateVariables = { projectRef: string; slug: string; payload: XPayload } export const useXUpdateMutation = ({ onSuccess, onError, ...options }: UseMutationOptions<XData, XError, XUpdateVariables> = {}) => { const queryClient = useQueryClient() return useMutation({ mutationFn: updateX, async onSuccess(data, variables, context) { await Promise.all([ queryClient.invalidateQueries({ queryKey: xKeys.detail(variables.projectRef, variables.slug), }), queryClient.invalidateQueries({ queryKey: xKeys.list(variables.projectRef) }), ]) await onSuccess?.(data, variables, context) }, async onError(error, variables, context) { if (onError === undefined) toast.error(`Failed to update: ${error.message}`) else onError(error, variables, context) }, ...options, }) }
isPending for initial load, isFetching for background refetches| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 22,500 | 10,263 | -54% | 1 | 1 | 0% | 4,212 | 3,398 | -19% | 0 | 0 | — |
case-02 | fail→pass | 22,637 | 14,702 | -35% | 1 | 1 | 0% | 4,876 | 4,428 | -9% | 0 | 0 | — |
case-03 | fail→fail | 18,079 | 14,676 | -19% | 1 | 1 | 0% | 3,809 | 4,076 | +7% | 0 | 0 | — |
case-04 | pass→pass | 11,838 | 9,361 | -21% | 1 | 1 | 0% | 1,907 | 2,782 | +46% | 0 | 0 | — |
case-05 | pass→pass | 16,623 | 16,070 | -3% | 1 | 1 | 0% | 3,175 | 4,104 | +29% | 0 | 0 | — |
case-06 | pass→pass | 16,567 | 13,234 | -20% | 1 | 1 | 0% | 3,242 | 3,895 | +20% | 0 | 0 | — |
case-07 | fail→pass | 11,943 | 8,155 | -32% | 1 | 1 | 0% | 2,569 | 2,593 | +1% | 0 | 0 | — |
case-08 | fail→pass | 14,737 | 9,674 | -34% | 1 | 1 | 0% | 2,556 | 2,958 | +16% | 0 | 0 | — |
case-09 | pass→pass | 11,405 | 6,999 | -39% | 1 | 1 | 0% | 2,040 | 2,805 | +38% | 0 | 0 | — |
case-10 | fail→pass | 12,428 | 6,329 | -49% | 1 | 1 | 0% | 2,063 | 2,212 | +7% | 0 | 0 | — |
case-11 | fail→pass | 26,690 | 6,124 | -77% | 1 | 1 | 0% | 2,375 | 2,326 | -2% | 0 | 0 | — |
case-12 | fail→pass | 18,988 | 20,799 | +10% | 1 | 1 | 0% | 1,595 | 3,279 | +106% | 0 | 0 | — |
case-13 | fail→pass | 10,725 | 7,198 | -33% | 1 | 1 | 0% | 1,994 | 2,449 | +23% | 0 | 0 | — |
case-14 | fail→pass | 12,872 | 6,415 | -50% | 1 | 1 | 0% | 2,099 | 2,461 | +17% | 0 | 0 | — |
case-15 | pass→pass | 11,514 | 3,936 | -66% | 1 | 1 | 0% | 1,769 | 1,941 | +10% | 0 | 0 | — |
case-16 | fail→fail | 13,640 | 11,792 | -14% | 1 | 1 | 0% | 2,506 | 3,537 | +41% | 0 | 0 | — |
case-17 | pass→pass | 9,187 | 3,553 | -61% | 1 | 1 | 0% | 1,360 | 1,852 | +36% | 0 | 0 | — |
case-18 | pass→pass | 13,959 | 7,789 | -44% | 1 | 1 | 0% | 2,583 | 2,907 | +13% | 0 | 0 | — |
case-19 | pass→fail | 15,720 | 7,499 | -52% | 1 | 1 | 0% | 2,668 | 2,611 | -2% | 0 | 0 | — |
case-20 | fail→pass | 13,132 | 6,311 | -52% | 1 | 1 | 0% | 2,131 | 2,304 | +8% | 0 | 0 | — |
case-21 | pass→pass | 8,752 | 4,869 | -44% | 1 | 1 | 0% | 1,451 | 2,000 | +38% | 0 | 0 | — |
case-22 | pass→pass | 10,401 | 3,931 | -62% | 1 | 1 | 0% | 1,735 | 1,909 | +10% | 0 | 0 | — |
case-23 | pass→pass | 3,677 | 2,522 | -31% | 1 | 1 | 0% | 563 | 1,558 | +177% | 0 | 0 | — |
case-24 | pass→pass | 9,665 | 3,376 | -65% | 1 | 1 | 0% | 1,717 | 1,768 | +3% | 0 | 0 | — |
case-25 | pass→pass | 8,115 | 4,964 | -39% | 1 | 1 | 0% | 1,246 | 1,969 | +58% | 0 | 0 | — |
case-26 | pass→pass | 8,871 | 6,568 | -26% | 1 | 1 | 0% | 1,575 | 2,536 | +61% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 26 cases were attempted. The headline lift of +35 percentage points is the difference between those two pass rates over the 26 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.