/nazarf-claude-code:supabase:types-genfrom nazarf-claude-code
Generate TypeScript types from Supabase database schema
Ships in nazarf-claude-code. Installing the plugin adds it to Claude Code.
Generate TypeScript types from the Supabase database schema.
Run the following command to generate types:
npx supabase gen types typescript --project-id YOUR_PROJECT_ID > lib/database.types.ts
Or if using local Supabase:
npx supabase gen types typescript --local > lib/database.types.ts
{
"scripts": {
"gen-types": "npx supabase gen types typescript --project-id $SUPABASE_PROJECT_ID > lib/database.types.ts",
"gen-types:local": "npx supabase gen types typescript --local > lib/database.types.ts"
}
}
import type { Database } from '@/lib/database.types'
// Get table type
type User = Database['public']['Tables']['users']['Row']
type UserInsert = Database['public']['Tables']['users']['Insert']
type UserUpdate = Database['public']['Tables']['users']['Update']
// Use with Supabase client
const supabase = createClient<Database>(url, key)
// Type-safe queries
const { data } = await supabase
.from('users')
.select('*')
.single() // data is typed as User
// Type-safe inserts
const { data } = await supabase
.from('users')
.insert({
email: '[email protected]',
name: 'John Doe'
}) // TypeScript validates the shape
// lib/database.helpers.ts
import type { Database } from './database.types'
// Extract table types
export type Tables<T extends keyof Database['public']['Tables']> =
Database['public']['Tables'][T]['Row']
export type Enums<T extends keyof Database['public']['Enums']> =
Database['public']['Enums'][T]
// Usage
import type { Tables } from '@/lib/database.helpers'
type User = Tables<'users'>
type Post = Tables<'posts'>
Run npm run gen-types after:
lib/ or types/any instead of generated types# .husky/pre-commit
#!/bin/sh
npm run gen-types
git add lib/database.types.ts
Issue: supabase command not found
npm install -g supabase
Issue: Missing project ID
# Find your project ID in Supabase dashboard
# Or set in .env
SUPABASE_PROJECT_ID=your-project-id
Issue: Types not updating
# Clear cache and regenerate
rm lib/database.types.ts
npm run gen-types
Generate and use TypeScript types to catch database-related bugs at compile time instead of runtime.
Files this command reads when invoked
What the command file sets; muted values are Claude Code's defaults
claude-sonnet-4-57-day visitors to each command page
npx claudepluginhub norens/nazarf-claude-code --plugin nazarf-claude-code13 commands in this plugin
/api:api-newRequirementsCreate a new Next.js API route with validation, error handling, and TypeScript/api:api-protectTarget API RouteAdd authentication, authorization, and security to API endpoints/api:api-testTargetTest API endpoints with automated test generation/misc:code-cleanupCode to CleanRefactor and clean up code following best practices/misc:code-explainCode Explanation and AnalysisExplain and analyze code structure, logic, and patterns/misc:code-optimizeCode to OptimizeAnalyze and optimize code for performance, memory, and efficiency3 plugins ship this exact command · first indexed Jun 20, 2026