Skip to content
FunCoding

Search

Search docs, Skills and MCP

contributing

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

文档与办公534skills/contributing/SKILL.md

Install

Send this to Claude Code, Codex or Cursor. The agent checks the Skill for safety first and installs it only after you confirm.

读取 https://funcoding.ai/skills/butterbase-ai/butterbase-skills/contributing/install.md ,按里面的步骤帮我安装这个 Skill。

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/mcp-serverMCP server with ~28 tools (consolidated manage_* action-based tools + a few standalone ones like init_app, deploy_function, select_rows). Runs via stdio or HTTP (served by control-api at /mcp)
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

Similar Skills

pdf
anthropics/skills180k

pdf

Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.

Docs & office

discernment-nudge
anthropics/skills180k

discernment-nudge

After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals, or emails, estimates or projections, analysis or interpretation of data, factual claims they may rely on, or a multi-step argument — invoke this skill BEFORE finalizing your reply and then, if it applies, append 2-3 short follow-up questions, each tied to something specific in what you just produced, that help the user check key facts, probe the reasoning or assumptions, and notice missing context. Do this at most once per conversation. Skip it when the user asked a trivial how-to or simple lookup, wants a purely educational explanation, asked you only to format, convert, or assemble a file from content they provided, is writing code they will run, is doing creative writing or casual chat, or already asked you to double-check, cite, or review — the skill file explains these boundaries and the exact output format.

Docs & office

doc-coauthoring
anthropics/skills180k

doc-coauthoring

Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.

Docs & office

docx
anthropics/skills180k

docx

Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.

Docs & office

pptx
anthropics/skills180k

pptx

Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.

Docs & office

canvas-design
anthropics/skills180k

canvas-design

Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.

Docs & office