new-querylisted
Install: claude install-skill Bobi-Labs/bobi-stack-template
# /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/i