agentleFS
butterbase-aibutterbase-ai/butterbase-skills/skills/contributing/SKILL.md

contributing

Skill535 starsChanged 5 months agoMITView on GitHub

Use when contributing to the Butterbase codebase, adding new MCP tools, creating API routes, writing migrations, or understanding the monorepo architecture

  • Reads credentials

We split this skill into the rules it gives an agent

4 rules. 0 are common, 0 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 19 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Add tool to the relevant section's table in the SECTIONS object

    line 96
  2. Very specific:

    IMPORTANT: Use scripts/migrate.ts or scripts/backfill-migrations.ts, NEVER raw psql

    line 102
  3. Very specific:

    Run tests per workspace: cd services/control-api && npm test

    line 144
  4. Very specific:

    Test files: __tests__/ directory or co-located *.test.ts

    line 145

“Common” is measured: kept by at least 6 in 10 of the 19 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

1. Overview

Contributor guide for the Butterbase monorepo. Covers architecture, how to add MCP tools, API routes, database migrations, and coding conventions.


2. Monorepo Map

DirectoryPackagePurpose
packages/cli@butterbase/cli (v0.1.3)Published CLI tool (Commander.js). Commands: init, apps, schema, functions, storage, deploy, data, env, keys, realtime, status, open
packages/sdk@butterbase/sdk (v1.2.1)Published TypeScript SDK. Modules: auth, storage, functions, AI, billing, realtime, admin
packages/shared@butterbase/sharedInternal shared types, constants, schema DSL, error types
packages/plugin@butterbase/pluginClaude Code plugin (this package — skills for AI agents)
services/control-api@butterbase/control-apiFastify API server — the brain. Routes, plugins, services. Port 4000
services/mcp-server@butterbase/mcpMCP server with capability-dependent tools (consolidated manage_* action-based tools + standalone ones like init_app, deploy_function, select_rows). Runs via stdio or HTTP (served by control-api at /mcp); hosted cloud may also register manage_office
services/deno-runtime—Serverless function executor. Deno-based worker isolation. Port 7133
services/cron-scheduler@butterbase/cron-schedulerCron job runner using node-cron + cron-parser
services/dashboard—React management UI (Vite + Radix UI)
services/dashboard-api—Dashboard backend proxy. Port 4100
services/docs@butterbase/docsAstro/Starlight documentation site
services/storage-indexer—Cloudflare Worker for S3 event indexing
db/control-plane—SQL migrations (sequential numbering, 001_ upward). Control plane database schema
db/data-plane—Per-app database initialization scripts

3. Adding a New MCP Tool (4 Steps)

Step 1: Create tool file at services/mcp-server/src/tools/my-new-tool.ts

Decide whether the new capability is a standalone tool (single, self-contained operation like init_app) or another action on an existing umbrella tool (manage_schema, manage_function, etc). Most new operations should be added as actions on an existing manage_* tool — this keeps the surface area small for AI agents.

For a brand-new standalone tool, follow the pattern from init-app.ts:

import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { z } from 'zod';
import { apiPost } from '../api-client.js';

interface MyResponse {
  // response shape
}

export function registerMyNewTool(server: McpServer) {
  server.tool(
    'my_new_tool',      // snake_case name
    `Tool description.   // Multi-line description with examples

Example:
  Input: { ... }
  Output: { ... }

Common errors:
  - ERROR_CODE: Description`,
    {
      // Zod schema for parameters
      app_id: z.string().describe('The app ID'),
      param: z.string().describe('Parameter description'),
    },
    async ({ app_id, param }) => {
      const result = await apiPost<MyResponse>(`/v1/${app_id}/my-endpoint`, { param });
      return {
        content: [{
          type: 'text' as const,
          text: JSON.stringify(result, null, 2),
        }],
      };
    }
  );
}

API client functions available: apiGet, apiPost, apiPatch, apiDelete (from ../api-client.js).

Step 2: Register in services/mcp-server/src/create-server.ts

import { registerMyNewTool } from './tools/my-new-tool.js';
// ...
registerMyNewTool(server);

Step 3: Create the backing API route in services/control-api/src/routes/

  • Fastify route handler matching the endpoint your tool calls
  • Register in services/control-api/src/index.ts

Step 4: Update documentation in services/mcp-server/src/docs/user-documentation.ts

  • Add tool to the relevant section's table in the SECTIONS object

4. Adding a Database Migration

  • IMPORTANT: Use scripts/migrate.ts or scripts/backfill-migrations.ts, NEVER raw psql
  • Migration files: db/control-plane/NNN_description.sql (sequential numbering, starting at 001_initial_schema.sql)
  • Pick the next free three-digit prefix; never edit a committed migration
  • Run migrations: npx tsx scripts/migrate.ts

5. Coding Conventions

ConventionExample
MCP tool namessnake_case. Two flavours: standalone (init_app, deploy_function, select_rows) and manage_* umbrella tools that take an action enum (manage_schema, manage_rls, manage_function, manage_frontend, etc.)
App IDsapp_ prefix: app_abc123
Service keysbb_sk_ prefix: bb_sk_a1b2c3...
Environment variablesBUTTERBASE_ prefix: BUTTERBASE_API_KEY
Response metadata_meta.next_actions (suggested next tool calls), _meta.resource_info (quota/state)
Error codesUPPERCASE_WITH_UNDERSCORES: AUTH_RLS_POLICY_VIOLATION, QUOTA_TABLE_LIMIT
Domainbutterbase.ai (never "nira")

6. Running Locally

docker-compose -f docker-compose.local.yml up
ServicePortURL
Control API4000http://localhost:4000
Dashboard API4100http://localhost:4100
Deno Runtime7133http://localhost:7133
Control Plane DB5433postgres://localhost:5433
Data Plane DB5435postgres://localhost:5435
PgBouncer6432postgres://localhost:6432
LocalStack (S3)4566http://localhost:4566

7. Testing

  • Framework: Vitest
  • Run tests per workspace: cd services/control-api && npm test
  • Test files: __tests__/ directory or co-located *.test.ts
  • Build all workspaces: npm run build (from repo root)
  • Type check: npx tsc --noEmit in each workspace

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.