---
url: /supabase-tools/plugins/plugin-mcp-server.md
description: >-
MCP server for @sbtools/mcp-server — exposes all 21 studio tools and 3
resources over stdio for Claude Desktop, Cursor, and VS Code Copilot.
---
# @sbtools/mcp-server
[](https://www.npmjs.com/package/@sbtools/mcp-server)
A thin MCP ([Model Context Protocol](https://modelcontextprotocol.io/)) server that exposes every `@sbtools/plugin-migration-studio` tool and resource to AI agents via stdio. No business logic lives here — it is a registration layer over the existing tool catalog.
## Quick Start
```bash
npx @sbtools/mcp-server --cwd /path/to/your/supabase-project
```
Or point directly at the built file if you are in the monorepo:
```bash
node packages/mcp-server/dist/index.js --cwd /path/to/your/supabase-project
```
## Claude Desktop Configuration
Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or the equivalent path on your OS:
```json
{
"mcpServers": {
"sbtools": {
"command": "node",
"args": ["/absolute/path/to/packages/mcp-server/dist/index.js"],
"cwd": "/absolute/path/to/your/supabase-project"
}
}
}
```
With `npx`:
```json
{
"mcpServers": {
"sbtools": {
"command": "npx",
"args": ["@sbtools/mcp-server"],
"cwd": "/absolute/path/to/your/supabase-project"
}
}
}
```
## `--cwd` Flag
The server walks up from its working directory looking for `supabase-tools.config.json` to locate the project root. If it is not found it falls back to `cwd`. Override explicitly:
```bash
node dist/index.js --cwd /path/to/project
```
## Tools (21)
All tools discovered from `@sbtools/plugin-migration-studio`'s tool catalog are registered automatically. The MCP tool name matches the studio tool ID exactly (e.g. `studio-introspect`, `studio-release-gate`).
### Understand Layer
| Tool ID | What it does |
|---|---|
| `studio-introspect` | Query live DB → `studio.schema.snapshot` artifact |
| `studio-sql-parse` | Parse migration files → `studio.sql.ast` artifact |
| `studio-intent-sync` | Confidence-score DB entities vs SQL → `studio.intent.sync-report` |
| `studio-intent-init` | Build intent graph from sync report → `studio.intent.graph` |
### Generate Layer
| Tool ID | What it generates |
|---|---|
| `studio-create-table` | `CREATE TABLE` migration |
| `studio-add-column` | `ALTER TABLE … ADD COLUMN` migration |
| `studio-add-index` | `CREATE INDEX` migration |
| `studio-add-constraint` | `ALTER TABLE … ADD CONSTRAINT` migration |
| `studio-add-rls-policy` | `CREATE POLICY` migration |
| `studio-add-function` | `CREATE OR REPLACE FUNCTION` migration |
| `studio-create-rpc` | RPC function (schema: public) migration |
| `studio-create-view` | `CREATE OR REPLACE VIEW` migration |
| `studio-greenfield-init` | Initialize empty intent graph for a new project |
### Validate Layer
| Tool ID | What it validates |
|---|---|
| `studio-rls-check` | RLS coverage gaps per entity |
| `studio-rpc-lint` | Function security (DEFINER, search\_path, exposure) |
| `studio-migration-plan` | Ordered SQL change plan vs intent graph |
| `studio-lint` | Migration file risk flags and naming violations |
| `studio-release-gate` | Aggregated pass/fail gate with blocking reasons |
### Graph & Mapping
| Tool ID | Description |
|---|---|
| `studio-intent-patch` | Mutate a single entity's managed-status |
| `studio-endpoint-map` | Derive PostgREST endpoints from intent graph entities/functions |
## Resources (3)
Resources are read-only and available in any MCP client that supports resource listing.
| Resource URI | Content |
|---|---|
| `sbtools://studio/catalog` | Full tool + workflow catalog (filterable JSON) |
| `sbtools://studio/intent-graph` | Current `studio.intent.graph` artifact data or `null` |
| `sbtools://studio/llm-context` | Single-call orientation: intent graph summary, artifact freshness, gate status, catalog |
Read `sbtools://studio/llm-context` first — it is the fastest way for an AI agent to understand the project state.
## Typical Agent Workflow
```
1. Read sbtools://studio/llm-context ← orient: what exists, what's stale
2. Call studio-introspect ← snapshot the live DB
3. Call studio-sql-parse ← parse migration history
4. Call studio-intent-sync ← score confidence
5. Call studio-intent-init ← build intent graph
6. Call studio-release-gate ← validate before any apply
```
## Monorepo Convenience
If the MCP server package is installed alongside `plugin-migration-studio`, you can start it via:
```bash
sbt mcp
# or
sbt mcp --cwd /path/to/project
```
## See Also
* [plugin-migration-studio →](./plugin-migration-studio) — all 21 tools with HTTP + CLI reference
* [CLI Reference →](../cli-reference) — `sbt mcp` command
---
---
url: /supabase-tools/plugins/plugin-db-test.md
description: >-
Run database tests using pgTAP. Supports live PostgreSQL (Docker) or in-memory
PGlite mode.
---
# @sbtools/plugin-db-test
[](https://www.npmjs.com/package/@sbtools/plugin-db-test)
Plugin that runs database tests using pgTAP. Supports live database mode (Docker) or in-memory PGlite mode.
## Quick Start
```bash
npm install @sbtools/plugin-db-test
```
Add to config: `{ "path": "@sbtools/plugin-db-test" }`
```bash
# Live mode (requires sbt start)
npm run sbt -- test
# In-memory mode (no Docker required)
npm run sbt -- test --mem
```
## Commands
| Command | Description |
|---------|-------------|
| `test` | Run pgTAP tests from supabase/tests |
| `test --mem` | Run tests in-memory via PGlite |
| `test --server` | Run tests against server |
```
$ npm run sbt -- test
Running pgTAP tests from supabase/tests
Mode: live (Docker)
supabase/tests/auth_policies.sql
ok 1 - anon cannot read profiles
ok 2 - authenticated user can read own profile
ok 3 - service_role bypasses RLS
supabase/tests/subscriptions.sql
ok 4 - active subscription required for premium
ok 5 - expired subscription denied
5/5 tests passed
```
## Configuration
Plugin config goes in `plugins[].config`:
```json
{
"plugins": [{
"path": "@sbtools/plugin-db-test",
"config": { "testsDir": "supabase/tests" }
}]
}
```
| Key | Default | Description |
|-----|---------|-------------|
| `testsDir` | `supabase/tests` | Directory containing .sql test files |
| `migrationsDir` | Root `paths.migrations` | Migrations to apply in --mem mode |
---
---
url: /supabase-tools/plugins/plugin-deno-functions.md
description: >-
Document Supabase Edge Functions by statically analysing TypeScript source
files.
---
# @sbtools/plugin-deno-functions
[](https://www.npmjs.com/package/@sbtools/plugin-deno-functions)
Plugin that documents Supabase Edge Functions by statically analysing TypeScript source files.
## Quick Start
```bash
npm install @sbtools/plugin-deno-functions
```
Add to config:
```json
{
"plugins": [
{
"path": "@sbtools/plugin-deno-functions",
"config": {
"baseUrl": "/functions/v1",
"configTomlPath": "supabase/config.toml"
}
}
]
}
```
```bash
npx sbt edge-functions
```
## Commands
| Command | Description |
|---------|-------------|
| `edge-functions` | List discovered edge functions |
| `edge-functions --brief` | Summary table only |
| `edge-functions --json` | Output raw JSON |
| `edge-functions --openapi` | Generate OpenAPI spec |
```
$ npx sbt edge-functions --brief
Edge Functions (4 discovered)
┌──────────────────┬────────┬─────────────────────────┐
│ Function │ Verify │ Endpoint │
├──────────────────┼────────┼─────────────────────────┤
│ send-email │ JWT │ /functions/v1/send-email │
│ process-payment │ JWT │ /functions/v1/process-… │
│ generate-report │ JWT │ /functions/v1/generate-… │
│ health-check │ none │ /functions/v1/health-c… │
└──────────────────┴────────┴─────────────────────────┘
```
## Configuration
| Key | Default | Description |
|-----|---------|-------------|
| `baseUrl` | `/functions/v1` | URL prefix for edge function endpoints |
| `configTomlPath` | `supabase/config.toml` | Path to Supabase config.toml |
## Integration
Results integrate into Backend Atlas, Swagger UI/ReDoc, and `sbt status`.
---
---
url: /supabase-tools/plugins/plugin-depgraph.md
description: >-
Visualize backend dependency relationships as interactive HTML graph and
Mermaid diagrams.
---
# @sbtools/plugin-depgraph
[](https://www.npmjs.com/package/@sbtools/plugin-depgraph)
Plugin that visualizes backend dependency relationships (tables, functions, triggers, policies, views, enums) as an interactive HTML graph and Mermaid diagrams.
## Quick Start
```bash
npm install @sbtools/plugin-depgraph
```
Add to config: `{ "path": "@sbtools/plugin-depgraph" }`
```bash
# Ensure atlas data exists first
npx sbt generate-atlas
# Generate dependency graphs
npx sbt depgraph
# → docs/dependency-graph.html
# → docs/dependency-graph.md
```
## Commands
| Command | Description |
|---------|-------------|
| `depgraph` | Generate both HTML and Mermaid |
| `depgraph --html` | HTML only |
| `depgraph --mermaid` | Mermaid only |
| `depgraph --json` | Raw JSON output |

*Dependencies page — interactive graph with focus depth, palette presets, and node detail panel*
## Relationships
Tracks: triggers→tables, policies→tables, functions→tables, views→tables, FK constraints, enum usage.
## Dashboard Graph Controls
The dashboard `Dependencies` page (`/depgraph`) supports:
* Node focus mode with selectable depth (`0..4`)
* Palette presets by node type (`Default`, `Colorblind-safe`, `High contrast`, `Muted`)
* Quick filters: orphan nodes, type multi-select, and connection-count buckets
* Search, pan/zoom, and node detail inspection
## Requirements
Run `sbt generate-atlas` first — plugin reads from `docs/backend-atlas-data.json`.
---
---
url: /supabase-tools/plugins/plugin-erd.md
description: >-
Generate Mermaid ERD diagrams for each public table. Connects to DB to
introspect columns, keys, and relationships.
---
# @sbtools/plugin-erd
[](https://www.npmjs.com/package/@sbtools/plugin-erd)
Plugin that generates Mermaid ERD diagrams for each public table. Connects to the database to introspect columns, primary keys, and foreign keys.
## Quick Start
```bash
npm install @sbtools/plugin-erd
```
Add to config: `{ "path": "@sbtools/plugin-erd" }`
```bash
# Ensure database is running
npx sbt start
npx sbt generate-erd
# Output: docs/entity-relations/
.md
```
## Commands
| Command | Description |
|---------|-------------|
| `generate-erd` | Generate Mermaid ERD for all public tables |
Sample generated ERD (`docs/entity-relations/users.md`):
````
```mermaid
erDiagram
users {
uuid id PK
text email
text full_name
timestamptz created_at
}
organizations {
uuid id PK
text slug
}
users ||--o{ memberships : "has"
organizations ||--o{ memberships : "has"
```
````
## Configuration
Plugin config goes in `plugins[].config`:
```json
{
"plugins": [{
"path": "@sbtools/plugin-erd",
"config": {
"erdOutput": "docs/development/entity-relations",
"displayColumns": ["name", "email", "full_name", "slug", "title"]
}
}]
}
```
| Key | Default | Description |
|-----|---------|-------------|
| `erdOutput` | `/entity-relations` | Output directory (derives from root `paths.docsOutput`) |
| `displayColumns` | `["name", "email", "full_name", "slug", "title"]` | Columns to display on referenced entities |
Global ERD display columns can also be set at the root level under `erd.displayColumns`.
## Dashboard Integration

*ERD page — Mermaid entity-relationship diagram with table list sidebar*
When active, the ERD plugin contributes to the dashboard automatically — no extra commands needed.
* **`getAtlasData()`** — reads the generated `.md` files from `erdOutput` at `sbt generate-atlas` time and adds an `erd_diagrams` category to `backend-atlas-data.json`
* **`getDashboardView()`** — declares the ERD section so the dashboard router shows it in the nav
The dashboard ERD page (`/erd`) renders each diagram as an interactive Mermaid SVG with table search and a raw source toggle. If `erd_diagrams` is missing from atlas data (e.g. `generate-erd` hasn't run yet), the dashboard falls back to reading `.md` files directly from the `erdOutput` directory at request time.
> **Note on `erdOutput`:** If you set a custom `erdOutput` path in plugin config, make sure it matches where `generate-erd` writes files. The dashboard resolves this path from `supabase-tools.config.json` at runtime — a mismatch causes the ERD page to appear empty.
---
---
url: /supabase-tools/plugins/plugin-frontend-usage.md
description: >-
Scan frontend .ts/.tsx/.js/.jsx files for Supabase SDK usage and generate
interactive HTML report.
---
# @sbtools/plugin-frontend-usage
[](https://www.npmjs.com/package/@sbtools/plugin-frontend-usage)
Plugin that scans frontend `.ts/.tsx/.js/.jsx` files for Supabase SDK usage and generates an interactive HTML report.
## Quick Start
```bash
npm install @sbtools/plugin-frontend-usage
```
Add to config: `{ "path": "@sbtools/plugin-frontend-usage" }`
```bash
npx sbt frontend-usage
# → docs/frontend-usage.html
```
## Commands
| Command | Description |
|---------|-------------|
| `frontend-usage` | Scan, generate HTML, open in browser |
| `frontend-usage --json` | Output raw JSON |
| `frontend-usage --no-open` | Skip opening report |
## Patterns Detected
Tables (`.from()`), RPCs (`.rpc()`), auth, storage, edge functions, REST calls.
## Configuration
| Key | Default | Description |
|-----|---------|-------------|
| `scanPaths` | `["src/"]` | Directories to scan |
---
---
url: /supabase-tools/plugins/plugin-logs.md
description: >-
Live Docker log tailing, pg_stat_statements query monitoring, and standalone
HTML log viewer.
---
# @sbtools/plugin-logs
[](https://www.npmjs.com/package/@sbtools/plugin-logs)
Plugin that adds live Docker log tailing, `pg_stat_statements` query monitoring, and a standalone HTML log viewer.
## Dashboard Integration
* The unified `sbt dashboard` also exposes live logs directly in the Logs page.
* Live stream is served by dashboard APIs (`/api/logs/stream`, `/api/logs/services`) so you can monitor logs without leaving the dashboard shell.
* `logs viewer` remains available as a standalone, dedicated viewer.
## Quick Start
```bash
npm install @sbtools/plugin-logs
```
Add to config: `{ "path": "@sbtools/plugin-logs" }`
```bash
# Tail all services
npx sbt logs
# Open log viewer
npx sbt logs viewer
# → http://localhost:3333
```
## Commands
| Command | Description |
|---------|-------------|
| `logs` | Tail all services (multiplexed) |
| `logs ` | Tail single service |
| `logs --list` | List services |
| `logs pg-stats` | Top 20 queries by execution time |
| `logs pg-stats --slow` | By mean execution time |
| `logs pg-stats --frequent` | By call count |
| `logs viewer` | Start HTML log viewer |
```
$ npx sbt logs --list
Available services:
✓ functions (running)
✓ db (running)
✓ rest (running)
✓ auth (running)
✓ kong (running)
✓ storage (running)
✓ realtime (running)
✓ studio (running)
```
## Configuration
| Key | Default | Description |
|-----|---------|-------------|
| `viewerPort` | 3333 | Log viewer port |
| `tailLines` | 100 | Initial tail lines |
| `dbContainer` | supabase-db | DB container name |
---
---
url: /supabase-tools/plugins/plugin-migration-audit.md
description: >-
Compare migration files with database tracking. Read-only drift detection,
CLI/JSON/HTML/Atlas reporting.
---
# @sbtools/plugin-migration-audit
[](https://www.npmjs.com/package/@sbtools/plugin-migration-audit)
Plugin that compares migration files on disk with `app_migrations.schema_migrations`. Detects drift, missing files, pending migrations. Reports via CLI, JSON, HTML, and Backend Atlas. **Read-only** — makes zero schema modifications.
## Quick Start
```bash
npm install @sbtools/plugin-migration-audit
```
Add to config: `{ "path": "@sbtools/plugin-migration-audit" }`
```bash
# Run audit (DB optional — disk-only if unreachable)
npx sbt migration-audit
# → docs/migration-audit.html
# → CLI summary + open in browser
```
```
$ npx sbt migration-audit
Migration Audit
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Migrations Dir supabase/migrations
Database Connected
Tracking Table Exists
Total: 63 Applied: 63 Pending: 0 Missing: 0
Migrations:
APPLIED 20251218135835_create_users.sql (2026-02-12T11:43:40)
APPLIED 20251218135847_add_organizations.sql (2026-02-12T11:43:40)
APPLIED 20251224154957_create_subscriptions.sql (2026-02-12T11:43:40)
...
✓ HTML report → docs/migration-audit.html
✓ Detail pages → docs/migration-audit/.html
```
Each migration has a detail page with SQL viewer, parsed operations, risk flags, and touched objects. Links from the main report and Backend Atlas cards.
## Commands
| Command | Description |
|---------|-------------|
| `migration-audit` | CLI summary + HTML report + open browser |
| `migration-audit --json` | Output raw audit JSON |
| `migration-audit --html` | Generate HTML only |
| `migration-audit --no-open` | Skip opening browser |

*Migrations page — audit summary, inventory table with applied/pending/missing filters*
## Issues Detected
| Code | Severity | Description |
|------|----------|-------------|
| `MISSING_FILE` | error | Applied in DB but file missing on disk |
| `PENDING_MIGRATION` | warning | Files not yet applied |
| `NO_TRACKING_TABLE` | warning | `app_migrations.schema_migrations` missing |
| `ORDERING_GAP` | warning | Applied out of chronological order |
| `TIMESTAMP_PARSE_FAILURE` | info | Non-standard filename (no YYYYMMDDHHMMSS prefix) |
| `EMPTY_MIGRATION` | info | 0-byte migration files |
## Artifact
Produces `migration.analysis` v1.0.0. Includes per-migration `sqlAnalysis` (operations, touched objects, risk flags, confidence). Consumed by migration-studio for schema fallback and migrations context.
## Configuration
No config fields required. Uses `paths.migrations` and `paths.docsOutput`. Database optional — uses `DATABASE_URL` / `SUPABASE_DB_URL` / `POSTGRES_URL` when available.
---
---
url: /supabase-tools/plugins/plugin-migration-studio.md
description: >-
Flagship plugin — 21 tools, 4 workflows, intent graph, release gate, HTTP tool
surface for AI agents.
---
# @sbtools/plugin-migration-studio
[](https://www.npmjs.com/package/@sbtools/plugin-migration-studio)
The flagship plugin. Provides a complete **backend design platform** for Supabase projects across five layers: Understand → Design → Generate → Validate → Apply. Every tool is available via both CLI (`sbt studio-`) and HTTP (`POST /api/studio/`), making the platform directly usable by AI agents.
## Installation
```bash
npm install @sbtools/plugin-migration-studio
```
```json
{
"plugins": [
{ "path": "@sbtools/plugin-migration-studio", "config": {} }
]
}
```
## Starting the Server
```bash
sbt migration-studio # port 3335 (default)
sbt migration-studio --port N # custom port
sbt migration-studio --restart # force-restart if port in use
```
## LLM / Agent Usage
> **Using Claude Desktop, Cursor, or VS Code?** The [`@sbtools/mcp-server`](./plugin-mcp-server) package exposes every tool below as a first-class MCP tool — no HTTP needed.
AI agents using the HTTP API can orient themselves in one call:
```
GET /api/studio/llm-context
```
Returns: intent graph summary, artifact freshness, full tool catalog with descriptions, migration count. Then the agent can call any tool:
```
POST /api/studio/introspect → snapshot the DB
POST /api/studio/intent-init → build intent graph
POST /api/studio/create-table → generate migration SQL
POST /api/studio/release-gate → validate before applying
POST /api/apply → apply if gate passes
```
Discover available tools and workflows:
```
GET /api/studio/catalog?audience=backend-dev&mode=managed&type=tools
```
## Tool Catalog (21 tools)
### Understand Layer
| CLI Command | HTTP Route | Produces Artifact |
|---|---|---|
| `studio-introspect` | `POST /api/studio/introspect` | `studio.schema.snapshot` |
| `studio-sql-parse` | `POST /api/studio/sql-parse` | `studio.sql.ast` |
| `studio-intent-sync` | `POST /api/studio/intent-sync` | `studio.intent.sync-report` |
| `studio-intent-init` | `POST /api/studio/intent-init` | `studio.intent.graph` |
### Generate Layer (Scaffold Tools)
| CLI Command | HTTP Route | What it generates |
|---|---|---|
| `studio-create-table` | `POST /api/studio/create-table` | `CREATE TABLE` migration |
| `studio-add-column` | `POST /api/studio/add-column` | `ALTER TABLE ... ADD COLUMN` |
| `studio-add-index` | `POST /api/studio/add-index` | `CREATE INDEX` |
| `studio-add-constraint` | `POST /api/studio/add-constraint` | `ALTER TABLE ... ADD CONSTRAINT` |
| `studio-add-rls-policy` | `POST /api/studio/add-rls-policy` | `CREATE POLICY` |
| `studio-add-function` | `POST /api/studio/add-function` | `CREATE OR REPLACE FUNCTION` |
| `studio-create-rpc` | `POST /api/studio/create-rpc` | RPC function (schema: public) |
| `studio-create-view` | `POST /api/studio/create-view` | `CREATE OR REPLACE VIEW` |
### Validate Layer
| CLI Command | HTTP Route | Produces Artifact |
|---|---|---|
| `studio-rls-check` / `studio-migration-lint` | `POST /api/studio/rls-check` | `studio.rls.plan` + `studio.rls.report` |
| `studio-migration-lint` | `POST /api/studio/migration-lint` | `studio.migration.lint` |
| `studio-rpc-lint` | `POST /api/studio/rpc-lint` | `studio.rpc.plan` |
| `studio-migration-plan` | `POST /api/studio/migration-plan` | `studio.migration.plan` |
| `studio-release-gate` | `POST /api/studio/release-gate` | `studio.release.gate` |
### Graph & Mapping
| CLI Command | HTTP Route | Description |
|---|---|---|
| `studio-intent-patch` | `POST /api/studio/intent-graph/entity` | Mutate entity managed-status |
| `studio-endpoint-map` | `POST /api/studio/endpoint-map` | Derive PostgREST endpoints from intent graph |
| `studio-greenfield-init` | `POST /api/studio/greenfield-init` | Init empty intent graph for new project |
## Workflow Catalog (4 workflows)
Workflows chain multiple tools with optional human checkpoints.
| Workflow ID | Steps | Use Case |
|---|---|---|
| `adopt-backend` | introspect → sql-parse → intent-sync → intent-init | Brownfield project adoption (2 checkpoints) |
| `release-check` | migration-plan → rls-check → rpc-lint → release-gate | Pre-release validation |
| `create-table` | create-table → sql-parse | Table + immediate AST update |
| `add-rls-policy` | add-rls-policy → rls-check | Policy + immediate coverage check |
Run the brownfield adoption workflow:
```bash
sbt studio-adopt
```
Browse all workflows: `GET /api/studio/catalog?type=workflows`
## Intent Graph
The intent graph (`studio.intent.graph`) is the central artifact. It assigns every DB entity a `managedStatus`:
| Status | Meaning |
|---|---|
| `managed` | Full confidence — schema matches SQL, safe to modify |
| `assisted` | Partial match — LLM/human should review before modifying |
| `opaque` | Unknown origin — do not modify without explicit human sign-off |
| `excluded` | Intentionally excluded from tracking |
Read the current graph: `GET /api/studio/intent-graph`
Mutate an entity's status: `POST /api/studio/intent-graph/entity`
## Release Gate
The release gate (`studio-release-gate`) aggregates evidence from all validation tools into a single `{ status: 'pass' | 'fail', reasons: [] }` signal. `POST /api/apply` respects the gate — migrations are blocked if the gate has failed.
This is the recommended final step before any migration apply, especially for LLM-driven pipelines.
## Migration Studio UI
The plugin also provides a **CodeMirror 6 SQL editor** UI accessible at `http://localhost:3335` (or via the dashboard at `/studio`). Features:
* Syntax highlighting, autocomplete (tables/columns from DB schema)
* SQL analysis and dry-run validation
* Save/apply migration files
* Schema sidebar and migration list
## HTTP API Reference
| Route | Description |
|---|---|
| `GET /api/health` | Health check |
| `GET /api/events` | SSE — live cache invalidation events |
| `GET /api/schema` | Live DB schema (tables, columns, policies, functions) |
| `GET /api/templates` | Migration template list |
| `GET /api/migrations` | Migration file list |
| `POST /api/analyze` | SQL analysis (parse + classify operations) |
| `POST /api/validate` | SQL dry-run against live schema |
| `POST /api/save` | Save SQL to a migration file |
| `POST /api/apply` | Apply pending migrations (enforces release gate) |
| `GET /api/studio/llm-context` | Full project orientation for AI agents |
| `GET /api/studio/intent-graph` | Current intent graph or null |
| `GET /api/studio/catalog` | Filterable tool/workflow catalog |
| `GET /api/studio/adopt/status` | Current adoption workflow run state |
| `POST /api/studio/adopt/start` | Start adoption workflow |
| `POST /api/studio/adopt/resume` | Resume from checkpoint |
| `POST /api/studio/` | Run any discovered tool (21 total) |
## Artifacts Produced
| Artifact | Description |
|---|---|
| `studio.schema.snapshot` | Live DB schema as typed nodes |
| `studio.sql.ast` | SQL AST from migration files |
| `studio.intent.sync-report` | Confidence scores per entity (DB vs SQL) |
| `studio.intent.graph` | Typed entity graph with managed/assisted/opaque status |
| `studio.rls.plan` | Suggested RLS policies for uncovered entities |
| `studio.rls.report` | RLS coverage analysis and gaps |
| `studio.migration.lint` | Risk flags, naming violations, lock-safety |
| `studio.rpc.plan` | Function security audit results |
| `studio.migration.plan` | Ordered change plan with change-class annotations |
| `studio.release.gate` | Aggregated pass/fail gate with blocking reasons |
| `studio.apply.log` | Apply history with timestamps and output |
| `studio.workflow.run` | Current workflow run state (for resuming) |
## See Also
* [Platform Architecture →](./plugin-migration-studio-platform) — 5-layer design and contributing guide
* [CLI Reference →](../cli-reference) — Full command listing with flags
---
---
url: /supabase-tools/plugins/plugin-scaffold.md
description: >-
Scaffold new supabase-tools plugins with consistent boilerplate and SDK
integration.
---
# @sbtools/plugin-scaffold
[](https://www.npmjs.com/package/@sbtools/plugin-scaffold)
Plugin that scaffolds new supabase-tools plugins with consistent boilerplate.
## Quick Start
```bash
npm install @sbtools/plugin-scaffold
```
Add to config: `{ "path": "@sbtools/plugin-scaffold" }`
```bash
# Internal plugin (packages/plugin-/)
npx sbt scaffold-plugin analytics
# External plugin (sibling directory)
npx sbt scaffold-plugin my-feature --external
# With Atlas hooks
npx sbt scaffold-plugin dashboard --hooks
```
## Commands
| Command | Description |
|---------|-------------|
| `scaffold-plugin ` | Create internal plugin |
| `scaffold-plugin --external` | Create external plugin |
| `scaffold-plugin --hooks` | Include Atlas hook stubs |
```
$ npx sbt scaffold-plugin analytics
Scaffolding plugin: analytics
✓ packages/plugin-analytics/package.json
✓ packages/plugin-analytics/tsconfig.json
✓ packages/plugin-analytics/src/index.ts
✓ packages/plugin-analytics/README.md
Done — run `npm install` to link the new package.
```
## Configuration
No config required.
---
---
url: /supabase-tools/plugins/plugin-typegen.md
description: >-
Generate TypeScript types from the running Supabase instance using the
PostgREST types endpoint.
---
# @sbtools/plugin-typegen
[](https://www.npmjs.com/package/@sbtools/plugin-typegen)
Plugin that generates TypeScript types from the running Supabase instance using the PostgREST types endpoint.
## Quick Start
```bash
npm install @sbtools/plugin-typegen
```
Add to config: `{ "path": "@sbtools/plugin-typegen" }`
```bash
# Ensure database is running
npx sbt start
npx sbt generate-types
# Output: src/integrations/supabase/types.ts
```
## Commands
| Command | Description |
|---------|-------------|
| `generate-types` | Fetch types from PostgREST and write to file |
```
$ npx sbt generate-types
Fetching types from http://localhost:54321/rest/v1/?apikey=...
✓ Written to src/integrations/supabase/types.ts (248 tables, 12 views, 34 enums)
```
## Configuration
Plugin config goes in `plugins[].config`:
```json
{
"plugins": [{
"path": "@sbtools/plugin-typegen",
"config": { "typesOutput": "src/types/supabase.ts" }
}]
}
```
| Key | Default | Description |
|-----|---------|-------------|
| `typesOutput` | `src/integrations/supabase/types.ts` | Output file path |
Environment: `SUPABASE_TYPES_SCHEMAS` to limit schemas (comma-separated).
---
---
url: /supabase-tools/ui-web.md
description: >-
@sbtools/ui-web — Shared React UI package: SSR renderers for standalone HTML
reports and the Vite React dashboard SPA.
---
# @sbtools/ui-web
[](https://www.npmjs.com/package/@sbtools/ui-web)
Shared UI package for supabase-tools. Provides two main things:
1. **SSR renderers** — Node.js functions that generate standalone HTML files for plugin CLI commands
2. **React dashboard SPA** — Vite-built single-page app served by `sbt dashboard` (port 3400)
The dashboard is bundled into `@sbtools/core` at build time — end users do not need to install this package directly. It is primarily a dependency for plugins that generate standalone HTML pages.
## Installation
```bash
npm install @sbtools/ui-web
```
## SSR Renderers
Server-side page renderers used by plugin CLI commands to produce standalone HTML reports:
| Export | Used by |
|--------|---------|
| `renderDepgraphPage` | `sbt depgraph --html` |
| `renderFrontendUsagePage` | `sbt frontend-usage` |
| `renderMigrationAuditPage` | `sbt migration-audit --html` |
| `renderMigrationDetailPage` | Per-migration detail pages from `migration-audit` |
| `renderLogsViewerPage` | `sbt logs viewer` |
| `renderMigrationStudioPage` | `sbt migration-studio` (legacy standalone page) |
| `renderRawDocument` | Base HTML document shell — used by all above |
### Usage
```ts
import { renderDepgraphPage, renderRawDocument } from "@sbtools/ui-web";
```
All renderers accept typed data objects and return an HTML string. Write it to a file with `writeFileInDir` from `@sbtools/sdk`.
### Shared Tokens
CSS design tokens are exported for use in SSR pages and plugin renderers:
```ts
import { SHARED_TOKENS_CSS, SHARED_TOKENS_DARK } from "@sbtools/ui-web";
```
These provide the same light/dark mode CSS custom properties used by the dashboard SPA, ensuring visual consistency between standalone HTML reports and the dashboard.
## React Dashboard SPA
The dashboard SPA at `sbt dashboard` (`http://localhost:3400`) is a Vite-built React application. It includes:

*Overview — entity stats, mini charts, and the Entity Explorer table*
### Pages
| Page | Route | Description |
|------|-------|-------------|
| Overview | `/` | Entity stats, mini charts, clickable filter tabs |
| Details | `/details/:section/:id` | Node detail view with metadata grid, edge tables |
| Migrations | `/migrations` | Migration list, audit status, embedded/pop-out Studio |
| Migration Studio | `/migration-studio` | React dashboard page for Migration Studio (connects to `sbt migration-studio` server) |
| Dependency Graph | `/depgraph` | Interactive graph with focus depth, palette, filters |
| ERD | `/erd` | Mermaid ERD diagrams per table with search and raw toggle |
| Frontend Usage | `/frontend-usage` | Filter-driven SDK usage views: hot components, component map, resource impact |
| Logs | `/logs` | Live Docker log stream with service filters and inline search |
| Commands | `/commands` | Run any `sbt` command from the browser with live streaming output |
| Not Found | `*` | 404 fallback |
### Shared Components
* `StatCard` — Clickable stat cards with tone, used on Overview
* `Badge` — Status/type badges with tone map support
* `DataTable` / `AppDataTable` — Sortable, paginated tables with column resize
* `CardGrid` / `GenericSection` — Plugin-driven section renderers
* `SearchInput` — Global search with Ctrl+K hotkey, arrow navigation
* `CodeBlock` — Syntax-highlighted code viewer
* `ValueRenderer` — Collapsible JSON tree, SQL highlighting, auto-detection
* `EmptyState` — Unified empty state
* `Dropdown` — Multi-action button menus
* `MiniBarChart` / `MiniDonutChart` — Inline charts (Recharts)
* `MermaidRenderer` — Renders Mermaid diagrams as SVG
### Design System
All colors, spacing, and typography use CSS custom properties from `tokens.css`. Light/dark mode is supported via `[data-theme="dark"]`. Fonts are Geist + Geist Mono (loaded from Fontsource).
### Dashboard API routes (served by `sbt dashboard`)
| Route | Returns |
|-------|---------|
| `GET /api/atlas-data` | `backend-atlas-data.json` |
| `GET /api/dashboard-config` | Plugin-contributed section definitions |
| `GET /api/commands` | All registered commands with category |
| `GET /api/run/stream?command=...` | SSE: stream `sbt ` output |
| `GET /api/logs/services` | Docker service statuses |
| `GET /api/logs/stream?services=...` | Live SSE Docker log stream |
| `GET /api/fs/list?scope=...&path=...` | Safe file listing |
| `GET /api/fs/file?scope=...&path=...` | Safe file content |
## Development
To run the dashboard SPA with Vite HMR during development:
```bash
# 1. Start the backend (serves API on port 3400)
sbt dashboard
# 2. Generate atlas data (required for /api/atlas-data)
sbt generate-atlas
# 3. Start Vite dev server (proxies /api/* to port 3400)
npm run dev # from packages/ui-web/
# or
npm run dashboard:dev # from repo root
```
The UI runs at `http://localhost:5173`. Set `DASHBOARD_API_PORT` if the backend uses a different port.
## Dependencies
| Dependency | Purpose |
|------------|---------|
| `react`, `react-dom` | SSR (`renderToStaticMarkup`) and dashboard SPA |
| `mermaid` | ERD diagram rendering |
| `recharts` | Mini bar/donut charts |
| `@codemirror/*` | SQL editor in Migration Studio page |
| `lucide-react` | Icon set |
| `vite`, `@vitejs/plugin-react` | Dashboard SPA build (devDependencies) |
---
---
url: /supabase-tools/architecture.md
---
# Architecture
Documentation for supabase-tools architecture decisions and cross-package contracts.
## Package Dependencies
* [Package & Artifact Dependencies](./package-dependencies.md) — NPM deps, artifact produce/consume, command flows, real-time update requirements
## Versioned Artifacts
Versioned artifacts are the contract layer for cross-plugin collaboration. New integrations should use artifact-based contracts instead of implicit file conventions or hook-time object sharing.
* [Artifact ID Registry](./artifact-registry.md) — Official registry of artifact IDs and ownership
* [Artifact Contract Guide](./artifact-contract-guide.md) — How to produce and consume artifacts
* [Artifact Compatibility Policy](./artifact-compatibility-policy.md) — Semver behavior and contributor checklist
* [Implicit File Contracts](./implicit-file-contracts.md) — Documented output paths and merge semantics (legacy; prefer artifacts)
---
---
url: /supabase-tools/architecture/artifact-compatibility-policy.md
---
# Artifact Compatibility Policy
This policy defines how artifact schemas evolve and how producers and consumers must behave for backward compatibility.
## Semver behavior
| Bump | Meaning | Consumer impact |
|------|---------|-----------------|
| **MAJOR** | Breaking data schema changes (field removed, type changed, structure changed) | Consumers must be updated to handle the new schema |
| **MINOR** | Additive compatible fields (new optional fields, new categories) | Consumers may ignore unknown fields; safe to upgrade |
| **PATCH** | Docs, bugfix semantics, no structural break | No consumer impact |
## Producer rules
1. **Validate output** against schema before write. Use `validateArtifactEnvelope` before `writeArtifact` in strict mode.
2. **Include freshness inputs** so consumers can detect staleness (e.g. `sourceHash`, `snapshotHash`).
3. **Document confidence limits** where relevant (e.g. "DB unreachable — disk-only analysis").
4. **Never remove or change types** of existing fields in a PATCH or MINOR. Use a new MAJOR for breaking changes.
## Consumer rules
1. **Read exact compatible major** when possible. If you need `migration.analysis` 1.x, accept any 1.y.z.
2. **Tolerate unknown fields** — additive minor changes must not break consumers.
3. **Degrade gracefully** when artifact is missing, invalid, or stale:
* Show a warning (e.g. "Run migration-audit to refresh")
* Provide a fallback path (e.g. live computation) when feasible
* Do not crash or block the user without a clear recovery path
4. **Prefer strict major matching** — do not assume 2.x is compatible with 1.x.
## Deprecation process
1. **Announce** deprecation in release notes and schema docs.
2. **Publish** new major artifact schema with migration notes.
3. **Block** incompatible consumers in CI/integration tests.
4. **Remove** deprecated major after documented cutover release (e.g. 2 releases later).
5. **Update** the [artifact registry](./artifact-registry.md) with deprecation status.
## Contributor checklist
When adding or modifying artifacts:
* \[ ] Schema changes follow semver (MAJOR for breaking, MINOR for additive).
* \[ ] Producer validates output before write.
* \[ ] Consumer degrades gracefully when artifact missing/invalid/stale.
* \[ ] Artifact ID is registered in the registry.
* \[ ] Contract tests exist for producer and consumer.
* \[ ] Migration notes documented for any breaking change.
---
---
url: /supabase-tools/architecture/artifact-contract-guide.md
---
# Artifact Contract Authoring Guide
This guide explains how to produce and consume versioned artifacts in supabase-tools plugins.
## What is a versioned artifact?
A versioned artifact is a **persisted, typed, semantically-versioned envelope** produced by one package and consumed by one or more others. It replaces implicit file conventions and hook-time object sharing with explicit contracts.
## Envelope structure
Every artifact follows the canonical envelope schema:
```json
{
"id": "migration.analysis",
"version": "1.0.0",
"producer": "@sbtools/plugin-migration-audit",
"generatedAt": "2026-02-15T00:00:00.000Z",
"schemaRef": "https://sbtools.dev/contracts/migration.analysis/1.0.0",
"inputs": {
"projectRoot": "/workspace",
"sourceHash": "sha256:...",
"snapshotHash": "sha256:..."
},
"meta": {
"toolVersion": "0.3.0",
"buildId": "..."
},
"data": {}
}
```
* **id**: Stable identifier (see [artifact registry](./artifact-registry.md)). Never include version in the ID.
* **version**: Full semver (MAJOR.MINOR.PATCH) for schema compatibility.
* **producer**: Package name that produced the artifact.
* **generatedAt**: ISO 8601 timestamp.
* **schemaRef**: Optional URL to schema documentation.
* **inputs**: Fingerprints for freshness/staleness (e.g. source hashes).
* **meta**: Tool/build metadata.
* **data**: The actual payload (schema varies per artifact).
## Storage convention
Default path: `.sbt/artifacts///latest.json`
Example: `migration.analysis` at `1.0.0` → `.sbt/artifacts/migration.analysis/1.0.0/latest.json`
Optional immutable snapshots: `.sbt/artifacts///.json`
## Producer checklist
1. **Validate output** against your schema before write.
2. **Include freshness inputs** (e.g. source hash, snapshot hash) so consumers can detect staleness.
3. **Use the SDK helpers** (`writeArtifact`, `ArtifactEnvelope`) for consistency.
4. **Document confidence limits** where relevant (e.g. "disk-only analysis when DB unreachable").
5. **Register the artifact** in the [artifact registry](./artifact-registry.md).
## Consumer checklist
1. **Read exact compatible major** when possible.
2. **Tolerate unknown fields** (additive minor changes).
3. **Degrade gracefully** when artifact is missing, invalid, or stale — show a warning or fallback, do not crash.
4. **Prefer `readArtifact`** from the SDK for path resolution and validation.
## SDK usage
```typescript
import { writeArtifact, readArtifact, type ArtifactEnvelope } from "@sbtools/sdk";
// Producer
const envelope: ArtifactEnvelope = {
id: "migration.analysis",
version: "1.0.0",
producer: "@sbtools/plugin-migration-audit",
generatedAt: new Date().toISOString(),
inputs: { projectRoot: ctx.projectRoot, sourceHash: "..." },
meta: { toolVersion: "0.4.0" },
data: myAuditResult,
};
writeArtifact(ctx, envelope);
// Consumer
const envelope = readArtifact(ctx, "migration.analysis", "1.0.0");
if (!envelope) {
ui.warn("Migration analysis artifact not found. Run migration-audit first.");
return;
}
// envelope.data is typed as MyData
```
## Plugin capability declaration
Plugins can declare artifact capabilities in their `SbtPlugin` definition:
```typescript
const plugin: SbtPlugin = {
name: "@sbtools/plugin-migration-audit",
version: "0.4.0",
artifactCapabilities: {
produces: ["migration.analysis"],
},
// ...
};
```
This enables tooling to validate artifact availability and surface warnings.
---
---
url: /supabase-tools/architecture/artifact-registry.md
---
# Artifact ID Registry
This document is the **single source of truth** for official artifact IDs in supabase-tools. All new artifact IDs must be registered here and follow the [artifact contract guide](./artifact-contract-guide.md).
## Naming rules
* `id` is stable and **never** includes version suffixes (e.g. `migration.analysis`, not `migration.analysis.v1`).
* Use dot-separated lowercase: `.` or `..`.
* Avoid duplicate semantics under different IDs.
## Status definitions
| Status | Meaning |
|--------|---------|
| **Active** | Producer and consumer both exist and work end-to-end |
| **Producing** | Producer writes the artifact; no consumer reads it yet |
| **Planned** | Defined in the plan but no implementation yet |
| **Convention** | Naming convention for a family of artifacts |
| **Optional** | Low-priority; implement only if ROI is justified |
## Official registry
| Artifact ID | Owner Package | Schema Version | Status | Description |
|-------------|---------------|----------------|--------|-------------|
| `atlas.data` | core | — | Planned | Optional wrapper for backend atlas data contract |
| `docs.route-manifest` | core | — | Planned | Plugin-generated page routes and labels |
| `openapi.partial.deno-functions` | plugin-deno-functions | 1.0.0 | Active | Deno functions partial OpenAPI spec (consumed by core docs) |
| `openapi.partial.` | (producing plugin) | — | Convention | Plugin partial OpenAPI specs; merged deterministically |
| `migration.analysis` | plugin-migration-audit | 1.0.0 | Active | Migration audit result; per-migration sqlAnalysis; consumed by migration-studio |
| `migration.lineage` | plugin-migration-audit | — | Planned | Migration dependency/lineage graph |
| `migration.staleness` | plugin-migration-audit | — | Planned | Staleness and drift metrics |
| `migration.studio.draft` | plugin-migration-studio | — | Planned | Studio-owned draft migration metadata |
| `studio.schema.snapshot` | plugin-migration-studio | 1.0.0 | Active | Live DB state — tables, columns, constraints, indexes, policies, functions, views, triggers, extensions |
| `studio.sql.ast` | plugin-migration-studio | 1.0.0 | Active | Migration file parse results — per-file AST, extracted intent nodes, aggregated entity/policy/function arrays |
| `studio.intent.sync-report` | plugin-migration-studio | 1.0.0 | Active | Confidence-scored match between DB snapshot and SQL AST; matched, unmatchedDb, unmatchedIntent lists |
| `studio.intent.graph` | plugin-migration-studio | 1.0.0 | Active | Final intent graph — managed/assisted/opaque entity nodes, opaque blocks, managed scope declaration |
| `studio.rls.plan` | plugin-migration-studio | 1.0.0 | Active | RLS policy plan for managed entities — proposed policies, coverage gaps |
| `studio.rls.report` | plugin-migration-studio | 1.0.0 | Active | RLS coverage report — per-entity gap analysis, SECURITY DEFINER warnings |
| `studio.rpc.plan` | plugin-migration-studio | 1.0.0 | Active | RPC/function security audit — DEFINER\_NO\_SEARCH\_PATH, public exposure, empty body |
| `studio.migration.plan` | plugin-migration-studio | 1.0.0 | Active | Ordered SQL change plan with change-class annotations; includes `snapshotHash` |
| `studio.migration.lint` | plugin-migration-studio | 1.0.0 | Active | Migration lint results — destructive ops, missing transactions, naming violations |
| `studio.release.gate` | plugin-migration-studio | 1.0.0 | Active | Release gate decision — pass/fail with blocking reasons; read by `POST /api/apply` |
| `studio.workflow.run` | plugin-migration-studio | 1.0.0 | Active | Workflow run state — step results, status, timestamps, current step pointer |
| `studio.apply.log` | plugin-migration-studio | 1.0.0 | Active | Apply audit record — `appliedAt`, truncated `output`, `success`; written after every successful apply |
| `typescript.schema-types` | plugin-typegen | — | Optional | Typegen output metadata (path, hash, timestamp) |
| `depgraph.graph` | plugin-depgraph | 1.0.0 | Producing | Dependency graph |
| `frontend.usage` | plugin-frontend-usage | 1.0.0 | Producing | Frontend usage scan results |
| `runtime.service-health` | plugin-logs | — | Optional | Runtime service health snapshots |
| `runtime.query-stats` | plugin-logs | — | Optional | Query statistics snapshots |
## Adding a new artifact
1. Propose the ID and schema in a PR.
2. Add a row to this registry with owner, schema version, status, and description.
3. Add a schema file and examples per the [contract guide](./artifact-contract-guide.md).
4. Ensure contract tests for producer and consumer.
## Deprecation
When deprecating an artifact:
1. Publish a new major artifact schema with migration notes.
2. Block incompatible consumers in CI/integration tests.
3. Remove the deprecated major after the documented cutover release.
4. Update this registry with deprecation status and removal date.
---
---
url: /supabase-tools/cli-reference.md
description: >-
Complete command reference for sbt — core commands, plugin commands, flags,
and environment variables.
---
# CLI Reference
All commands: `npx sbt [options]`
Run `npx sbt help` to list available commands (including installed plugins).
## Core Commands
### Docker
| Command | Description |
|---------|-------------|
| `start` | Start Supabase Docker stack |
| `stop` | Stop all services |
| `restart` | Restart all services |
| `status` | Show service URLs, keys, and connection info |
### Database
| Command | Description |
|---------|-------------|
| `migrate` | Apply SQL migrations from `supabase/migrations/` |
| `snapshot [schema...] [all]` | Export DB objects (functions, views, triggers, policies, types, enums) to filesystem |
| `watch [--scope migration]` | Watch DB/files and keep migration artifacts fresh (`migration-audit --no-open`) |
| `dashboard [--port N]` | Start unified dashboard UI (React) with APIs for atlas data, live logs, and file browsing |
`migrate` env vars:
* `MIGRATION_BASELINE=1` — record all migrations as applied without running them
* `MIGRATION_REAPPLY=1` — force reapply even if DB has existing tables
`watch` options:
* `--scope migration` — phase-1 scope (default)
* `--debounce-ms N` — debounce bursty events (default: `1500`)
* `--no-db-hooks` — skip DB trigger/event-trigger helper install
* `--verbose` — print event payloads
### Generation
| Command | Description |
|---------|-------------|
| `generate-atlas` | Generate Backend Atlas data (`.sbt/docs/backend-atlas-data.json` by default) |
| `init` | Generate `supabase-tools.config.json` with defaults |
### Other
| Command | Description |
|---------|-------------|
| `help` / `-h` / `--help` | Show all available commands |
`dashboard` options:
* `--port N` — listen on custom port (default: 3400)
`dashboard` API routes:
* `GET /api/atlas-data` — Backend Atlas JSON
* `GET /api/dashboard-config` — Combined dashboard section definitions (core + plugins)
* `GET /api/commands` — All registered commands (core + plugin) with category metadata
* `GET /api/run/stream?command=...` — SSE: spawn `sbt ` and stream stdout/stderr
* `GET /api/logs/services` — Current Docker service statuses
* `GET /api/logs/stream?services=...` — Live SSE log stream from Docker
* `GET /api/fs/list?scope=...&path=...` — Safe file listing (`snapshot`, `migrations`, `docs`, `project`)
* `GET /api/fs/file?scope=...&path=...` — Safe file content view in browser
## Plugin Commands
### plugin-db-test
| Command | Description |
|---------|-------------|
| `test` | Run pgTAP database tests against live DB |
| `test --mem` | Run tests in-memory using PGlite |
Config: `testsDir`, `migrationsDir`
### plugin-deno-functions
| Command | Description |
|---------|-------------|
| `edge-functions` | List discovered edge functions |
| `edge-functions --brief` | Summary table only |
| `edge-functions --json` | Raw JSON output |
| `edge-functions --openapi` | Generate OpenAPI spec at `docs/edge-functions-openapi.json` |
Config: `baseUrl`, `configTomlPath`
### plugin-depgraph
| Command | Description |
|---------|-------------|
| `depgraph` | Generate HTML + Mermaid dependency graph |
| `depgraph --html` | HTML only |
| `depgraph --mermaid` | Mermaid only |
| `depgraph --json` | Raw JSON to stdout |
| `depgraph --no-open` | Skip opening in browser |
Requires `generate-atlas` first. Config: `typesFilePath`
### docs (core)
| Command | Description |
|---------|-------------|
| `docs` / `docs all` | Start all doc services |
| `docs swagger` | Swagger UI (port 8081) |
| `docs redoc` | ReDoc (port 8082) |
| `docs schemaspy` | SchemaSpy (port 8083/schemaspy/) |
| `docs stop` | Stop all docs containers |
### plugin-erd
| Command | Description |
|---------|-------------|
| `generate-erd` | Generate Mermaid ERD per public table |
Config: `erdOutput`, `displayColumns`
### plugin-frontend-usage
| Command | Description |
|---------|-------------|
| `frontend-usage` | Scan frontend for Supabase SDK usage, generate HTML report |
| `frontend-usage --json` | Raw JSON output |
| `frontend-usage --no-open` | Skip opening in browser |
Config: `scanPaths`
### plugin-migration-audit
| Command | Description |
|---------|-------------|
| `migration-audit` | Compare disk migrations vs DB; CLI summary + HTML report + detail pages |
| `migration-audit --json` | Output raw audit JSON |
| `migration-audit --html` | Generate HTML only |
| `migration-audit --no-open` | Skip opening browser |
Produces `migration.analysis` artifact. Detail pages at `{docsOutput}/migration-audit/.html`.
### plugin-migration-studio
| Command | Description |
|---------|-------------|
| `migration-studio` | Start schema-aware migration authoring UI at `http://localhost:3335` |
| `migration-studio --port N` | Use custom port |
| `migration-studio --restart` | Kill existing process on port, then start (auto-retry on port conflict) |
Requires DB for schema introspection (falls back to atlas-data/artifact when unreachable).
#### Brownfield Adoption
| Command | Description |
|---------|-------------|
| `studio-introspect` | Query live DB → `studio.schema.snapshot` artifact |
| `studio-sql-parse` | Parse migration files → `studio.sql.ast` artifact |
| `studio-adopt` | Full adoption workflow (introspect → sql-parse → review → intent-sync → approve → intent-init) |
| `studio-catalog [--audience ] [--mode ] [--type ]` | List discovered tools/workflows from catalog with persona/control-mode filters |
| `studio-intent-patch --entity --action [--status ]` | Mutate a single entity's managed-status in the intent graph |
| `studio-endpoint-map` | Derive PostgREST `EndpointNode` declarations for all managed entities/functions |
#### Scaffold Tools (Generate Layer)
| Command | Description |
|---------|-------------|
| `studio-create-table --schema --name [--columns ] [--no-rls]` | Generate `CREATE TABLE` migration |
| `studio-add-column --entity --name --type [--nullable] [--default ]` | Generate `ALTER TABLE ... ADD COLUMN` migration (requires intent graph) |
| `studio-add-rls-policy --entity --name --command