agents
Use when designing, deploying, or debugging a Butterbase Agent (declarative LLM/tool graph), registering an MCP server for tool…
Use when developing, deploying, or debugging Butterbase serverless functions, or when the user needs to add backend logic like webhooks, scheduled jobs, or custom API endpoints
Claude Code
$ npx -y skills add butterbase-ai/butterbase-skills --skill function-dev --agent claude-code
Codex
$ npx skills add butterbase-ai/butterbase-skills --skill function-dev -a codex -y
Cursor
$ npx skills add butterbase-ai/butterbase-skills --skill function-dev -a cursor -y
Gemini CLI
$ npx skills add butterbase-ai/butterbase-skills --skill function-dev -a gemini-cli -y
GitHub Copilot
$ npx skills add butterbase-ai/butterbase-skills --skill function-dev -a github-copilot -y
OpenCode
$ npx skills add butterbase-ai/butterbase-skills --skill function-dev -a opencode -y
Windsurf
$ npx skills add butterbase-ai/butterbase-skills --skill function-dev -a windsurf -y
name: function-dev description: Use when developing, deploying, or debugging Butterbase serverless functions, or when the user needs to add backend logic like webhooks, scheduled jobs, or custom API endpoints
Guide for developing and deploying serverless functions on Butterbase's Deno runtime. Covers handler signatures, trigger types, database access, environment variables, and testing.
---
Every function exports a single `handler` function with this signature:
export async function handler(
request: Request,
context: {
db: PostgresClient, // RLS-aware DB client
env: Record<string, string>, // env vars set on the function
user: { id: string } | null, // present for HTTP+auth:required; null for cron
waitUntil: (p: Promise<unknown>) => void, // background work after Response (≤30s)
idempotency: {
claim: (key: string, opts?: { scope?: string; ttlSeconds?: number }) => Promise<boolean>
} // atomic dedup for webhook retries
}
): Promise<Response>**CRITICAL**: The handler MUST return `new Response()` (Web API standard). Do NOT return plain objects.
**Correct:**
return new Response(JSON.stringify({ message: "ok" }), {
status: 200,
headers: { "Content-Type": "application/json" }
});**Wrong (will fail):**
return { status: 200, body: "ok" }; // NOT a Response object!---
Invoke the function via an HTTP request.
{
"trigger": {
"type": "http",
"config": { "method": "POST", "path": "/my-endpoint", "auth": "required" }
}
}**Auth options:**
---
Execute the function on a schedule.
{
"trigger": {
"type": "cron",
"config": { "schedule": "0 9 * * *", "timezone": "UTC" }
}
}Uses standard 5-field cron expressions:
Cron functions run as `butterbase_service` (RLS bypassed). `ctx.user` is always `null`.
---
Fire when a connected client sends a matching event over the realtime WebSocket.
{
"trigger": {
"type": "websocket",
"config": { "event": "chat-message" }
}
}Fires when client sends matching event via realtime WebSocket connection. The `request` body contains the event payload sent by the client.
---
{
"trigger": {
"type": "s3_upload",
"config": { "prefix": "uploads/", "contentTypes": ["image/*"] }
}
}---
Use `ctx.db.query(sql, params)` for all database queries. Always use parameterized queries to prevent SQL injection — NEVER use string interpolation.
// Always use $1, $2 placeholders — never string interpolation
const { rows } = await ctx.db.query(
'SELECT * FROM posts WHERE author_id = $1',
[ctx.user.id] // params array
);const { rows } = await ctx.db.query(
'SELECT * FROM posts WHERE author_id = $1 AND published = true',
[ctx.user.id]
);await ctx.db.query( 'INSERT INTO logs (event, user_id) VALUES ($1, $2)', ['page_view', ctx.user.id] );
await ctx.db.query( 'UPDATE posts SET title = $1, updated_at = now() WHERE id = $2 AND author_id = $3', [newTitle, postId, ctx.user.id] );
| Invocation | Role | RLS | |------------|------|-----| | End-user JWT | `butterbase_user` | Enforced — `ctx.db` queries filtered by policies | | API key (`bb_sk_`) | `butterbase_service` | Bypassed — sees all data | | Cron trigger | `butterbase_service` | Bypassed — sees all data |
---
Common uses: API keys, webhook secrets, external service URLs.
const apiKey = ctx.env.OPENAI_API_KEY; const webhookSecret = ctx.env.WEBHOOK_SECRET; const serviceUrl = ctx.env.EXTERNAL_SERVICE_URL;
---
Returns the authenticated user's posts.
export async function handler(req, ctx) {
const { rows } = await ctx.db.query(
'SELECT id, title, created_at FROM posts WHERE author_id = $1 ORDER BY created_at DESC',
[ctx.user.id]
);
return new Response(JSON.stringify(rows), {
headers: { "Content-Type": "application/json" }
});
}Deploy:
deploy_function(
app_id,
name: "my-posts",
code: ...,
trigger: {
type: "http",
config: { method: "GET", path: "/my-posts", auth: "required" }
}
)---
Accepts an incoming webhook, validates the signature, and stores the event.
export async function handler(req, ctx) {
const body = await req.json();
const signature = req.headers.get("x-webhook-signature");
// Validate signature against ctx.env.WEBHOOK_SECRET
await ctx.db.query(
'INSERT INTO webhook_events (event_type, payload) VALUES ($1, $2)',
[body.type, JSON.stringify(body)]
);
return new Response("ok", { status: 200 });
}Deploy with: `trigger: { type: "http", config: { method: "POST", path: "/webhook", auth:
Claude Code plugin for Butterbase — the AI-Native Backend-as-a-Service. This plugin gives Claude deep knowledge of Butterbase's nearly 40 MCP tools, guides you through common workflows, and auto-configures the MCP server connection.
Use when designing, deploying, or debugging a Butterbase Agent (declarative LLM/tool graph), registering an MCP server for tool…
Use when calling the app's AI gateway from agent tools — chat completions, embeddings, listing models, configuring defaults or…
Use when configuring OAuth providers (Google/GitHub/Apple/X/etc.), setting up post-login auth hooks, tuning JWT lifetimes, or…
Use when building a new Butterbase app from scratch, creating a full-stack application, or when the user asks to set up a…
Use when contributing to the Butterbase codebase, adding new MCP tools, creating API routes, writing migrations, or understanding…
Use when users report access denied errors, see wrong data, RLS policies are not working, or when troubleshooting Row-Level…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.