Skip to content
CLI tool · Databases

Supabase CLI for AI agents

The Supabase CLI for coding agents: run the local stack, create and diff migrations, generate types, and dry-run pushes, with the remote commands to avoid.

supabaseby SupabaseOfficial MCP option
What it is

What Supabase CLI does for an agent

The Supabase CLI is Supabase's official tool for local development. It runs the full Supabase stack locally in Docker, manages SQL migrations, generates TypeScript types from the schema, and links a project to push changes.

Installed as a dev dependency, it runs as npx supabase. The local stack is where an agent should do its work: migrations can be created, reset, and tested freely there, and only a reviewed migration reaches the hosted database.

Official site: supabase.com

Install

Install Supabase CLI

The install commands from the official docs. Check it worked with supabase --version.

Homebrew
brew install supabase/tap/supabase
Project dev dependency
npm install supabase --save-dev
Auth

Signing in Supabase CLI for an agent

Local development needs no sign-in. Linking a hosted project needs supabase login, or a personal access token in SUPABASE_ACCESS_TOKEN for CI.

Sign in (human)
supabase login
Link a hosted project
supabase link --project-ref your-project-ref

Environment variables: SUPABASE_ACCESS_TOKEN. Set them in the agent's environment; never paste values into prompts or commit them.

Common agent tasks

What agents use Supabase CLI for

Example commands with placeholder names. Swap in your own project, app, or file names.

  1. Start the local stack

    supabase
    supabase start

    Needs Docker running. Prints local URLs and keys.

  2. Create a new migration file

    supabase
    supabase migration new add_profiles
  3. Diff local schema changes into a migration

    supabase
    supabase db diff -f add_profiles
  4. Generate TypeScript types from the local database

    supabase
    supabase gen types typescript --local > src/types/supabase.ts
  5. Preview which migrations a push would apply

    supabase
    supabase db push --dry-run
Safety

Safety rules for agents

Safe to run without asking

  • supabase status
  • supabase db push --dry-run
  • supabase gen types --local
  • supabase migration list

Ask a human first

  • supabase db push
  • supabase db reset --linked
  • supabase functions deploy
  • supabase secrets set
  • Do all schema work against the local stack; supabase db reset is fine locally and catastrophic with --linked.
  • Never run supabase db reset --linked; it wipes the hosted database.
  • Show the dry-run output of db push before a human applies migrations.
  • Keep the service role key out of client code, logs, and chat.
Agent instructions

AGENTS.md or CLAUDE.md snippet

Paste this into the instruction file your agent reads at the start of every session, then adjust the rules to your setup.

AGENTS.md
## Supabase CLI (supabase)

Use `supabase` for running Supabase locally, writing database migrations, and generating types.

- Check it is installed with `supabase --version`. If it is missing, ask before installing it.
- Auth: credentials are set up by a human. Never print or commit them (SUPABASE_ACCESS_TOKEN).
- Run without asking (read-only): `supabase status`, `supabase db push --dry-run`, `supabase gen types --local`, `supabase migration list`.
- Ask a human first (changes or deletes things): `supabase db push`, `supabase db reset --linked`, `supabase functions deploy`, `supabase secrets set`.
- Do all schema work against the local stack; supabase db reset is fine locally and catastrophic with --linked.
- Never run supabase db reset --linked; it wipes the hosted database.
- Show the dry-run output of db push before a human applies migrations.
- Keep the service role key out of client code, logs, and chat.
- Prefer JSON output where the command supports it, and keep output short.
CLI or MCP server?

Supabase CLI or an MCP server?

An official MCP option exists. Supabase publishes an official MCP server for managing projects, running SQL, and reading logs, with a read-only mode. Point it at a development project; use the CLI for migrations in the repository.

Rule of thumb: in a terminal agent that a human has signed in, the CLI is usually faster and cheaper in context. In a chat client without a shell, or when you want a fixed set of typed tools, use an MCP server.

Same category
All Databases tools
FAQ

Supabase CLI questions

How do I install Supabase CLI?

Homebrew: brew install supabase/tap/supabase. Other official options: Project dev dependency. Check the install with supabase --version, and see the Supabase docs for other platforms.

How does an AI agent authenticate Supabase CLI?

Local development needs no sign-in. Linking a hosted project needs supabase login, or a personal access token in SUPABASE_ACCESS_TOKEN for CI.

Which Supabase CLI commands are safe for an agent to run?

Commands that only read state are safe to run without asking: supabase status; supabase db push --dry-run; supabase gen types --local; supabase migration list. Ask a human before anything that changes or deletes something: supabase db push; supabase db reset --linked; supabase functions deploy; supabase secrets set.

Is there an MCP server for Supabase CLI?

Supabase publishes an official MCP server for managing projects, running SQL, and reading logs, with a read-only mode. Point it at a development project; use the CLI for migrations in the repository.