supabase-schema-architect — Claude Code subagent: Supabase schemas
A subagent that designs PostgreSQL schemas in Supabase, plans migrations and writes RLS policies. Useful when your database grows and access rules need sorting out.
npx claude-code-templates@latest --agent database/supabase-schema-architectWhat supabase-schema-architect does
The subagent covers three areas: schema, migrations, RLS. It designs normalized tables, relationships and indexes, prepares reversible migrations with a rollback plan, and describes Row Level Security policies with role-based access. Its tools are plain: Read, Write, Edit, Bash — it reads project files, edits them and runs commands.
The workflow runs in order: analyze the current schema, assess application requirements, write migration scripts and policies, then validate on staging and test the rollback. The reply includes a schema breakdown, new tables with columns and indexes, policies with a performance note, and implementation files — migration SQL, policy definitions, TypeScript types.
Some targets are baked into the prompt: normalization up to 3NF, snake_case naming, RLS coverage for tables holding sensitive data, migrations wrapped in transactions. Treat those as aims, not hard limits. Analyzing the current schema requires a Supabase connection over MCP; without it the agent works only with what sits in your project files.
What it helps with
- design a normalized schema for a new feature
- write a migration with a rollback plan that works
- lock down tables with RLS policies without breaking access
- lay out relationships and indexes so queries stay fast
- generate TypeScript types for a changed schema
Example prompts for the agent
- analyze the current Supabase schema and propose a migration for an orders table
- write RLS policies for the profiles table so a user sees only their own row
- draft a migration plan with rollback for renaming columns in users
How to install supabase-schema-architect
1claude-code-templates
npx claude-code-templates@latest --agent database/supabase-schema-architect2Manually: put the files in place
.claude/agents/supabase-schema-architect.mdFor all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention
Manually: put the files in place
.codex/agents/supabase-schema-architect.tomlCodex defines subagents in TOML: name, description, developer_instructions. Move the Markdown text into developer_instructions by hand. For all projects use ~/.codex/agents/
Manually: put the files in place
.cursor/agents/supabase-schema-architect.mdCursor also reads .claude/agents/
Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean
Questions about supabase-schema-architect
How do I install supabase-schema-architect in Claude?
Through the templates: npx claude-code-templates@latest --agent database/supabase-schema-architect. The agent file lands at .claude/agents/supabase-schema-architect.md.
What does supabase-schema-architect do?
It designs PostgreSQL schemas in Supabase, plans migrations with rollback, and writes Row Level Security policies. The output includes SQL, policy definitions and TypeScript types.
Does the agent need a Supabase MCP server?
For analyzing the current schema, yes — that step goes through MCP. Without it the agent relies only on your project files.