agents
Use when designing, deploying, or debugging a Butterbase Agent (declarative LLM/tool graph), registering an MCP server for tool use, or wiring access controls…
Use when designing database schemas, creating or modifying tables, choosing column types, adding indexes, or working with the Butterbase declarative schema DSL
$ npx -y skills add butterbase-ai/butterbase-skills --skill schema-design --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/schema-designContext preview
The summary Claude sees to decide when to auto-load this skill.
Use when designing database schemas, creating or modifying tables, choosing column types, adding indexes, or working with the Butterbase declarative schema DSL
name: schema-design description: Use when designing database schemas, creating or modifying tables, choosing column types, adding indexes, or working with the Butterbase declarative schema DSL
Reference guide for Butterbase's declarative schema DSL. Covers column types, constraints, indexes, and common data modeling patterns.
---
Butterbase uses a **declarative schema DSL** — you describe the desired end state of your database, and the platform computes and applies the diff. You never write raw `ALTER TABLE` or `CREATE TABLE` SQL. Instead, call `manage_schema` with `action: "apply"` and a JSON payload describing your tables, columns, and indexes.
The single `manage_schema` tool exposes four actions:
| Action | Purpose | |--------|---------| | `"get"` | Read the current schema | | `"dry_run"` | Preview SQL that `apply` would execute, without running it | | `"apply"` | Apply a declarative schema (diffs against current, runs safe DDL) | | `"list_migrations"` | List applied migrations, most recent first |
Key principles:
---
| Type | PostgreSQL | Use case | |------|-----------|----------| | `uuid` | UUID | Primary keys, foreign keys | | `text` | TEXT | Strings of any length | | `integer` | INTEGER | Whole numbers (-2B to 2B) | | `bigint` | BIGINT | Large whole numbers | | `boolean` | BOOLEAN | True/false flags | | `timestamptz` | TIMESTAMPTZ | Dates with timezone | | `jsonb` | JSONB | Structured/semi-structured data | | `real` | REAL | 32-bit floating point | | `double precision` | DOUBLE PRECISION | 64-bit floating point | | `vector(N)` | VECTOR(N) | Embeddings (pgvector); e.g. `vector(1536)` for OpenAI |
> **Always use `timestamptz` instead of `timestamp`.** `timestamp` silently drops timezone info and causes subtle bugs with users in different time zones.
---
Each column is an object with the following properties:
| Property | Type | Required | Default | Description | |----------|------|----------|---------|-------------| | `type` | string | ✅ yes | — | Column data type (see §2) | | `primaryKey` | boolean | no | false | Mark as primary key | | `nullable` | boolean | no | true | Allow NULL values | | `default` | string | no | — | SQL expression for default value | | `unique` | boolean | no | false | Add unique constraint | | `references` | string \| object | no | — | Foreign key target (see below) |
Short form (just the target):
"author_id": { "type": "uuid", "nullable": false, "references": "users.id" }Long form (with cascade behavior):
"author_id": {
"type": "uuid",
"nullable": false,
"references": {
"table": "users",
"column": "id",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION"
}
}`onDelete` / `onUpdate` accept `CASCADE | SET NULL | SET DEFAULT | RESTRICT | NO ACTION` (default `NO ACTION`).
Pass SQL expressions as strings:
"default": "gen_random_uuid()" // UUID primary keys "default": "now()" // Timestamps "default": "false" // Booleans "default": "0" // Integers "default": "'draft'" // String literals (single-quoted)
---
Every table should include these base columns:
{
"id": { "type": "uuid", "primaryKey": true, "default": "gen_random_uuid()" },
"created_at": { "type": "timestamptz", "nullable": false, "default": "now()" },
"updated_at": { "type": "timestamptz", "nullable": false, "default": "now()" }
}If your app uses Row-Level Security (RLS), also add:
"user_id": { "type": "uuid", "nullable": false, "references": "users.id" }> Tables without `user_id` cannot have per-user RLS policies applied later without a migration.
---
| `method` | Use case | Example opclass | |----------|----------|----------------| | `btree` | Default, range queries, sorting | — | | `hash` | Exact-match lookups | — | | `gin` | Full-text search on JSONB, arrays | `jsonb_path_ops` | | `gist` | Geometric/spatial data | — | | `hnsw` | Vector similarity (pgvector) | `vector_cosine_ops` | | `ivfflat` | Vector similarity (large datasets) | `vector_cosine_ops` |
Indexes are defined per-table under the `indexes` key:
{
"indexes": {
"idx_posts_author": {
"columns": ["author_id"],
"method": "btree"
},
"idx_posts_embedding": {
"columns": ["embedding"],
"method": "hnsw",
"opclass": "vector_cosine_ops"
},
"idx_posts_content_search": {
"columns": ["content"],
"method": "gin"
}
}
}Index naming convention: `idx_{table}_{column(s)}` — e.g. `idx_orders_user_id`.
"idx_members_workspace_user": {
"columns": ["workspace_id", "user_id"],
"method": "btree",
"unique": true
}---
All schema operations go through one tool with an `action` parameter:
manage_schema({ app_id, action: "get" })
manage_schema({ app_id, action: "dry_run", schema })
manage_schema({ app_id, action: "apply", schema, name }) // name is optional
manage_schema({ app_id, action: "list_migrations" })Include the table definition in your `schema` payload and call `action: "apply"`. The platform creates the table if it doesn't exist.
Add the new column(s) to the ex
Claude Code plugin for Butterbase — the AI-Native Backend-as-a-Service. This plugin gives Claude deep knowledge of Butterbase's 42+ MCP tools, guides you through common workflows, and auto-configures the MCP server connection.
Repo: butterbase-ai/butterbase-skills
Use when designing, deploying, or debugging a Butterbase Agent (declarative LLM/tool graph), registering an MCP server for tool use, or wiring access controls…
Use when calling the app's AI gateway from agent tools — chat completions, embeddings, listing models, configuring defaults or BYOK, reading token/cost usage
Use when configuring OAuth providers (Google/GitHub/Apple/X/etc.), setting up post-login auth hooks, tuning JWT lifetimes, or generating service API keys
Use when building a new Butterbase app from scratch, creating a full-stack application, or when the user asks to set up a complete backend with database, auth,…
Use when contributing to the Butterbase codebase, adding new MCP tools, creating API routes, writing migrations, or understanding the monorepo architecture
Use when users report access denied errors, see wrong data, RLS policies are not working, or when troubleshooting Row-Level Security issues in Butterbase