# Overview

The Fakebase CLI gives your project a local PostgreSQL database for development and keeps its schema as plain SQL migration files in your repository. You run it from your terminal, and coding agents run the same commands.

Fakebase is for development databases. It never touches production.

## Quick start

With the CLI [installed](https://fakebase.studio/docs/cli-install.md), run these in the root of your project:

```bash
fakebase init --start
fakebase db env
fakebase migrate create add_users
fakebase migrate up
```

1. `fakebase init --start` sets up the project and starts PostgreSQL in Docker.
2. `fakebase db env` writes `DATABASE_URL` to `.env.local` for your app.
3. `fakebase migrate create add_users` creates a migration file. Write your SQL in it.
4. `fakebase migrate up` previews the migration, asks you to confirm, and applies it.

## Commands

| Command                                                                    | What it does                                            |
| -------------------------------------------------------------------------- | ------------------------------------------------------- |
| [`fakebase init`](https://fakebase.studio/docs/cli-database.md#set-up-a-project)                     | Sets up Fakebase in the current folder                  |
| [`fakebase db start`](https://fakebase.studio/docs/cli-database.md#start-and-stop)                   | Starts the database                                     |
| [`fakebase db stop`](https://fakebase.studio/docs/cli-database.md#start-and-stop)                    | Stops the database. Your data is kept.                  |
| [`fakebase db status`](https://fakebase.studio/docs/cli-database.md#start-and-stop)                  | Shows whether the database is running                   |
| [`fakebase db env`](https://fakebase.studio/docs/cli-database.md#connect-your-app)                   | Writes the connection URL to `.env.local`               |
| [`fakebase db inspect`](https://fakebase.studio/docs/cli-database.md#see-the-schema)                 | Shows tables, columns, keys, and indexes                |
| [`fakebase migrate create`](https://fakebase.studio/docs/cli-migrations.md#create-a-migration)       | Creates a new migration file                            |
| [`fakebase migrate validate`](https://fakebase.studio/docs/cli-migrations.md#check-before-you-apply) | Checks migration files for mistakes                     |
| [`fakebase migrate diff`](https://fakebase.studio/docs/cli-migrations.md#check-before-you-apply)     | Previews pending migrations without applying them       |
| [`fakebase migrate up`](https://fakebase.studio/docs/cli-migrations.md#apply-migrations)             | Applies pending migrations                              |
| [`fakebase migrate status`](https://fakebase.studio/docs/cli-migrations.md#see-where-you-are)        | Lists applied and pending migrations                    |
| [`fakebase migrate history`](https://fakebase.studio/docs/cli-migrations.md#see-where-you-are)       | Lists applied migrations and when they ran              |
| [`fakebase migrate import`](https://fakebase.studio/docs/cli-migrations.md#import-older-migrations)  | Converts migrations from the older Fakebase format      |
| [`fakebase studio`](https://fakebase.studio/docs/cli-database.md#see-the-schema)                     | Opens the project, or one migration, in Fakebase Studio |
| [`fakebase doctor`](https://fakebase.studio/docs/cli-install.md#check-your-setup)                    | Checks your setup and tells you what to fix             |
| [`fakebase agent install`](https://fakebase.studio/docs/build-with-agents.md)                        | Teaches Cursor, Claude Code, and Codex to use Fakebase  |

## Scripts and agents

Every command takes `--json` for one machine-readable result, and `--yes` to skip prompts. Migrations that can delete data also need `--allow-destructive`, even with `--yes`.

Add `--help` to any command for its flags.

---

## Next steps

- [Install](https://fakebase.studio/docs/cli-install.md): Install the Fakebase CLI with npm, or run it with npx without installing.
- [Database](https://fakebase.studio/docs/cli-database.md): Set up a project, run its local PostgreSQL database, and connect your app with the Fakebase CLI.
- [Migrations](https://fakebase.studio/docs/cli-migrations.md): Create, check, and apply plain-SQL migrations with the Fakebase CLI.
