← ClaudeAtlas

new-mutationlisted

Scaffold a new Supabase mutation. Creates the Zod schema and mutation function, registers it in the mutation registry, and runs tests.
Bobi-Labs/bobi-stack-template · ★ 2 · Web & Frontend · score 69
Install: claude install-skill Bobi-Labs/bobi-stack-template
# /new-mutation: Scaffold a New Mutation Create a complete, wired mutation from an action + table name. The user invokes this as: ``` /new-mutation create-item /new-mutation create-item name:string status:string price:number /new-mutation update-item name:string --invalidates items /new-mutation delete-item ``` Parse `$ARGUMENTS` to extract: - `$0`: action-table in kebab-case (required) - Remaining positional args: `field:type` pairs for Zod schema (optional) - `--invalidates key1,key2`: query key names to invalidate (optional, defaults to table's plural key) ## Steps ### 1. Determine naming - **Action:** `create`, `update`, or `delete` - **Table:** the rest after action - **Function name:** camelCase(action + table) - **Files:** `lib/mutations/{action}-{table}.ts`, `lib/schemas/{action}-{table}.ts` ### 2. Create Zod schema in `lib/schemas/{action}-{table}.ts` Map field types: `string` → `z.string().min(1)`, `number` → `z.coerce.number()`, `uuid` → `z.string().uuid()`, `boolean` → `z.boolean()`, `enum:a,b,c` → `z.enum(["a","b","c"])`. Add `?` suffix for optional. For `update-*`, add `id: z.string().uuid()` automatically. For `delete-*`, skip the schema and validate the id inline. ### 3. Create mutation function in `lib/mutations/{action}-{table}.ts` **Create:** Zod parse → insert → return `{ success, data }` or `{ success: false, error }` **Update:** Zod parse → build updates → update by id → return result **Delete:** Validate UUID → delete → return result ### 4.