# generate-types-from-supabase

generate-types-from-supabase analyzes Supabase schema and generates TypeScript types for DTOs and Command Models. Cuts down manual type definition work by deriving structures from your database.

- command · `type=command` · Claude Code, Codex, GitHub Copilot, Gemini CLI · ★ 267 repo stars
- Author: przeprogramowani
- License: AGPL-3.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/przeprogramowani/ai-rules-builder/tree/HEAD/.claude/commands/generate-types-from-supabase.md
- Updated: 2026-02-20
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/commands/generate-types-from-supabase

## What it does

The command reads your database model definitions and produces typed Data Transfer Objects and command structures. It examines entity schemas, isolates relevant fields, applies TypeScript transformations (Pick, Omit, Partial), and binds each DTO back to the original table definition.

Works in steps: studies model structure, builds DTOs with correct types, validates connections between commands and entities. Output goes to `src/types.ts` ready to use.

Requires the database schema to be available as `@database.types.ts`. Keeps types in sync with Supabase changes and enforces strict typing across your API layer.

## Requirements
- Works with: Supabase

## Install

### Claude Code (native platform)

**Manually: put the files in place**
- File: `.claude/commands/generate-types-from-supabase.md` — Call it with /generate-types-from-supabase. For all projects use ~/.claude/commands/

### Codex

**Manually: put the files in place**
- File: `~/.codex/prompts/generate-types-from-supabase.md` — Call it with /prompts:generate-types-from-supabase. Codex marks this format deprecated in favour of skills

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/prompts/generate-types-from-supabase.prompt.md`

### Gemini CLI

**Manually: put the files in place**
- File: `.gemini/commands/generate-types-from-supabase.toml` — Gemini stores commands as TOML: the prompt text goes into the prompt field

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/przeprogramowani/ai-rules-builder/tree/HEAD/.claude/commands/generate-types-from-supabase.md

## When to use it
- Generate DTO types matching Supabase table schemas
- Create Command Models tied to database entities
- Prevent drift between type definitions and actual data structures
- Apply type transformations for Create, Update, and Read operations

## Example prompts
- Generate DTOs for all tables from the database schema
- Create Create and Update Command Models from entity definitions
- Analyze `@database.types.ts` and write types to `src/types.ts`

## Similar
- [supabase-migration-assistant](https://affpapa.org/en/nevibecode/commands/supabase-migration-assistant.md) — command · 982 installs
- [supabase-type-generator](https://affpapa.org/en/nevibecode/commands/supabase-type-generator.md) — command · 948 installs
- [nextjs-typescript-tailwindcss-supabase](https://affpapa.org/en/nevibecode/skills/nextjs-typescript-tailwindcss-supabase.md) — skill · 1400 installs
- [supabase](https://affpapa.org/en/nevibecode/skills/bobmatnyc-supabase.md) — skill · 219 installs
- [typescript-react-nextui-supabase-cursorrules-promp](https://affpapa.org/en/nevibecode/rules/typescript-react-nextui-supabase-cursorrules-promp.md) — rule · ★ 41178 repo stars
- [typescript-nextjs-supabase-cursorrules-prompt-file](https://affpapa.org/en/nevibecode/rules/typescript-nextjs-supabase-cursorrules-prompt-file.md) — rule · ★ 41178 repo stars

From the same set: [przeprogramowani/ai-rules-builder](https://affpapa.org/en/nevibecode/by/przeprogramowani/ai-rules-builder.md) — 24 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
