Skip to content
Back to skills

New Query

ASecurity

Scaffold a new Supabase query. Creates the query function, adds the key factory, registers it in the query registry, and runs tests.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 17, 2026
developmentgobash

Works with

  • cli

Security analysis

A100/100

Scanned October 17, 2026

npx -y skills add Bobi-Labs/bobi-stack-template --skill new-query --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of New Query?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for New Query
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/bobi-labs-new-query/badge)](https://www.skillsdirectory.com/skills/bobi-labs-new-query)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: new-query
description: Scaffold a new Supabase query. Creates the query function, adds the key factory, registers it in the query registry, and runs tests.
user-invocable: true
disable-model-invocation: true
argument-hint: <table-name> [columns] [--param paramName:paramType]
allowed-tools: Read, Write, Edit, Bash(./ops.sh test), Glob, Grep
---

# /new-query: Scaffold a New Query

Create a complete, wired query from a table name. The user invokes this as:

```
/new-query items
/new-query items id,name,status
/new-query items id,name --param categoryId:string
```

Parse `$ARGUMENTS` to extract:
- `$0` is the table name (required)
- `$1` is a comma-separated column list (optional, defaults to `*`)
- `--param name:type` sets an optional parameter for filtering

## Steps

### 1. Determine naming

From the table name, derive:
- **Query function name:** `get` + PascalCase(tableName)
- **Query file:** `lib/queries/get-{kebab-case}.ts`
- **Registry key:** camelCase(tableName)
- **Query key factory name:** camelCase(tableName)

### 2. Add query key factory: `lib/query-keys.ts`

Read the current file. Add a new entry to `queryKeys`. If no params:
```ts
tableName: () => ["tableName"] as const,
```

If params:
```ts
items: (categoryId?: string) =>
  categoryId ? ["items", categoryId] as const : ["items"] as const,
```

### 3. Create query function: `lib/queries/get-{name}.ts`

```ts
import { createClient } from "@/lib/supabase/client";

export async function getItems(param?: string) {
  const supabase = createClient();
  let query = supabase
    .from("items")
    .select("columns")
    .order("created_at", { ascending: false });

  if (param) {
    query = query.eq("param_column", param);
  }

  const { data, error } = await query;
  if (error) throw error;
  return data;
}
```

### 4. Register in query registry: `lib/queries/index.ts`

Add import + entry in `queries` object pairing key factory with function.

### 5. Verify

Run `./ops.sh test` to validate wiring.

### 6. Report

Tell the user files created/modified and usage: `useClientQuery("registryName")`

## Rules

- Always read target files before editing
- Match existing query patterns
- Key factory params and query function params MUST match
- Throw on Supabase errors
- Do NOT create components or hooks, just data layer files

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.