Skip to content
2090-labsPublic

About

The Supabase alternative for AI agents. Postgres, auth, REST, storage, realtime, jobs and MCP in one binary. Every agent run gets its own fork of your data, merged by policy, undoable row by row.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

8 stars

Watchers

0 watching

Forks

Repository files navigation

Forkbase: the backend for products that run themselves. Agents act on real data; every change lands on its own fork, merges by policy, and can be undone row by row.

Latest release Docker image npm PyPI Licence FSL-1.1-ALv2

Forkbase on Product Hunt

Website · Docs · Quickstart · Guardrails · Changelog · Example app


Forkbase is the backend for products that run themselves. Agents act on real data, on their own, and nothing breaks. It gives you what Supabase gives you (Postgres, auth, an auto REST API, storage, realtime, functions) and adds the part autonomous agents need:

  • Every agent run works on its own fork of your data. A copy-on-write world, reached with any Postgres driver. Your app and your users never see it.
  • A merge policy decides what reaches the real data. A small TOML file in your repo: row limits, tables a person must see, deletes, rates.
  • A person reviews the rest. Held runs show the exact rows they would change, in the dashboard, Slack or email.
  • Anything merged can be undone, row by row.
  • Guardrails watch what agents say and do. Personal data, keys and prompt injection in model and tool calls; tool limits, budgets, and SQL checks before a merge.

One binary. It runs over a Postgres you already have, or on the bundled Chronos engine. supabase-js works against it unchanged.

If Forkbase looks useful, a ⭐ helps other people building with agents find it.

How it works

An agent opens a run, works in its own fork, guardrails watch its model and tool calls, and its merge policy judges the diff: merged, held for a person, conflict, or undone later.

An agent never writes to your data directly. It opens a run, gets its own world (a fork of the data), does its work there with plain SQL, and proposes. The run's policy reads the rows it changed and answers:

Outcome HTTP What happened
merged 200 Within the rules. The rows are on main now, and can be undone later.
held 202 Something needs a person (reasons says what). Nothing touched main. Approve or reject it.
conflict 409 main changed the same rows meanwhile. Nothing landed; start a new run.

Quickstart

1. Install (macOS and Linux; checksums checked, signatures available):

curl -fsSL https://forkbase.tech/install.sh | FORKBASE_ENGINE=1 sh

2. Start it, on the bundled engine or over your own Postgres 16+:

forkbase init --db chronos            # or: forkbase init --db postgres --database-url postgres://...
forkbase start                        # http://127.0.0.1:8000, the dashboard at /dashboard
forkbase keys                         # anon (browsers) and service_role (your servers only)

3. Open the dashboard at http://127.0.0.1:8000/dashboard and sign in with the service_role key.

Or with Docker
docker run -d --name forkbase --restart unless-stopped \
  -p 127.0.0.1:8000:8000 -e FORKBASE_DB=chronos -v forkbase-data:/data \
  ghcr.io/2090-labs/forkbase:latest

docker exec forkbase forkbase keys

The image holds forkbase, the Chronos engine and Node 22, for linux/amd64 and linux/arm64. Compose files for both database modes, backups and upgrades: docs/docker.md.

Or let your coding agent do it

Paste this into Claude Code, Codex or Cursor. It asks one question at a time.

Read https://forkbase.tech/setup.md and set up Forkbase for me.

To teach any coding agent the whole manual, install the skills from your server:

curl -fsSL http://127.0.0.1:8000/skills/install.sh | sh     # into .claude/skills

Your first agent

An agent is a name, a merge policy and a token. Write the policy as a file beside forkbase.toml:

# policies/careful.toml
max_rows = 50          # more rows than this: a person reviews it
max_deletes = 0        # any delete: a person reviews it

Then make the agent and let it work:

# the service key makes an agent; its fba_ token opens runs
curl -X POST $URL/agents/v1/agents -H "apikey: $SERVICE" -H "authorization: Bearer $SERVICE" \
  -d '{"name": "cleanup", "policy": "careful"}'

# a run: its own world, a fbr_ token, and a database_url any Postgres driver connects to
curl -X POST $URL/agents/v1/runs -H "authorization: Bearer $AGENT" -d '{"intent": "delete closed tickets"}'
psql "$DATABASE_URL" -c "delete from tickets where status = 'closed'"     # in the world only

curl $URL/agents/v1/runs/$RUN/changes -H "authorization: Bearer $RUN_TOKEN"            # row by row
curl -X POST $URL/agents/v1/runs/$RUN/propose -H "authorization: Bearer $RUN_TOKEN"
# 202 {"status": "held", "reasons": ...}    the policy allows 0 deletes: it waits in Approvals

The same from TypeScript or Python:

import { createClient } from "@chronosdb/forkbase";

const fb = createClient("http://127.0.0.1:8000", process.env.FORKBASE_AGENT_TOKEN!);
const { outcome } = await fb.agents.withRun("delete closed tickets", (run) =>
  run.sql("delete from tickets where status = $1", ["closed"]),
);
// outcome.status: "merged" | "held" | "conflict"; a block that throws discards its world
from forkbase import create_client

fb = create_client("http://127.0.0.1:8000", agent_token)
with fb.agents.with_run("delete closed tickets") as run:
    run.sql("delete from tickets where status = $1", ["closed"])

Full walkthrough: Getting started.

What's inside

One binary: auth, REST, realtime, storage, vectors, jobs, agent runs, guardrails, gateway, declared agents, evals, ledger, chat, dashboard and MCP, over your Postgres or the Chronos engine.

What you get Docs
Auth Sign-up, passwords, emailed links and codes, Google and GitHub, PKCE, rotating refresh tokens, EdDSA JWTs checkable offline auth
Database and REST /rest/v1 in the PostgREST dialect, filters, embedding, upserts, row-level security with auth.uid() rest
Migrations and types SQL files applied in order; TypeScript types for supabase-js migrations
Realtime Table changes (filtered by each viewer's own policies) and broadcast, in the supabase-js protocol realtime
Storage Buckets on disk or S3, policies on storage.objects, signed URLs, public buckets storage
Vectors Collections of embedded items, searched by nearness: agents' memory and retrieval vectors
Jobs TypeScript and Python functions with retries, durable steps and sleeps, cron, table and event triggers jobs
Agent runs Worlds, merge policies as code, approvals by link, Slack and email, webhooks, undo agents
Guardrails Personal data, keys and injection checks on model and tool calls; tool argument limits; SQL checks before merge; call, token and cost limits guardrails
Gateway Sealed connections; Anthropic, OpenAI and compatible model calls metered on the run; Slack, email and HTTP actions sent only after the merge gateway
Declared agents An agent as one Markdown file: model, tables, tools, triggers, limits, prompt. Forkbase runs the loop agents
Dry runs, evals, replay Try an agent without merging, test it against suites, replay a past run evals
Chat Your app's people chat with a declared agent; each turn runs as that person, held to their rows chat
Observability Every run's ledger (each statement, tool call, decision, approval), OpenTelemetry traces under the GenAI conventions, Prometheus metrics observability
MCP A Model Context Protocol server with OAuth 2.1: Claude, Cursor and any MCP client work as one agent, under its policy mcp
Dashboard A full studio built into the binary: tables, SQL, auth, storage, realtime, agents, jobs, logs, team dashboard

The dashboard

Built into the binary at /dashboard. Sign in with the service_role key, or invite your team with viewer, operator and admin roles.

The approvals inbox: a held run from the claims_senior agent, with the one row it would change shown before and after, and Approve and merge.

Overview: requests, error rate, latency, runs merged, model spend and database size, with runs needing attention. Guardrails: each policy's guardrails in words, a tester for text, and findings. Table editor: the claims table with filters, sorting and inline editing.
Overview: traffic, runs, spend Guardrails: rules, tester, findings Table editor

Also: the SQL editor, a schema diagram, backups and restore to a point in time, row-level security policies from templates, users and auth settings, API docs for every table, storage, realtime inspector, runs with their ledgers, worlds and undo, merge policies edited and tried against a past run before saving, evals, connections, jobs with live logs, request logs with a live tail, and an audit log. ⌘ K searches it all.

Agents, safely

Policies as code. One file per policy, in your repo, reviewed like code. Applied at every start.

# policies/support.toml
tables        = ["tickets", "refunds"]
max_rows      = 50
max_deletes   = 0
review_tables = ["refunds"]       # always a person
rows_per_hour = 500
check_reads   = true              # conflict if what it read changed

Guardrails. Judged by Forkbase on every model and tool call; nothing to change in the agent.

[forkbase.guardrails]
pii       = { input = "redact", output = "hold" }
secrets   = "block"
injection = "hold"
checks    = [{ name = "no_big_refunds",
               sql = "select id from refunds where amount > 500" }]
max_model_calls = 40

Agents as files. Model, tables, tools, triggers and limits in front matter; the prompt below.

---
name: triage
model: claude-haiku-5-5
policy: small_claims
tools:
  - sql: { read: [policies], write: [claims] }
  - action: [email.send]        # sent after the merge
triggers:
  - table: claims
    on: [insert]
limits: { max_steps: 8, max_cost_usd: 0.50 }
---
You triage new insurance claims. ...

Side effects wait for the merge. A Slack post, an email or an HTTP call an agent asks for is sent by Forkbase only once its run merges, with a sealed credential, retries, and the result on the run. A held run sends nothing until a person approves; a rejected one, never.

Models through the gateway. Agents call Anthropic, OpenAI or any OpenAI-compatible server with their run's token. The provider key stays sealed in Forkbase; the policy's models, token and cost limits apply; each call's cost lands on the run.

Every step on the record. GET /agents/v1/runs/{id}/ledger, or one OpenTelemetry trace per run.

More: Agents · Guardrails · Gateway · Concepts

Bring your Supabase code

Tables, auth, storage and realtime speak Supabase's protocols, so supabase-js and supabase-py point at Forkbase and work:

import { createClient } from "@supabase/supabase-js";

const supabase = createClient("http://127.0.0.1:8000", ANON_KEY);
await supabase.auth.signInWithPassword({ email, password });
const { data } = await supabase.from("notes").select("id, body, tags(name)").order("created_at", { ascending: false });
supabase.channel("notes").on("postgres_changes", { event: "*", schema: "public", table: "notes" }, console.log).subscribe();

The Forkbase SDKs add what Supabase's clients don't cover (agent runs and jobs) and hand back a Supabase client for the rest: fb.supabase().

Jobs

// index.ts: deploy with `forkbase deploy ./welcome --name welcome --entry index.ts`
import { step, sleep } from "@chronosdb/forkbase";

export default async function (payload: { email: string }) {
  await step("welcome", () => send(payload.email, "welcome"));   // done once, even when a later step fails
  await sleep("a-day", 86_400);                                   // frees the worker, comes back tomorrow
  await step("tips", () => send(payload.email, "tips"));
}
forkbase deploy ./nightly.py --cron "0 3 * * *"                     # schedules
forkbase invoke welcome --payload '{"email": "[email protected]"}' --wait 30

Deploy a function with agent set and every job is a run of that agent: its DATABASE_URL is its own world, and when it ends well the run is proposed under the agent's policy. Jobs

MCP

claude mcp add --transport http forkbase https://api.example.com/mcp

The client signs in with OAuth 2.1, you pick which agent it works as on the consent page, and every change it makes goes through a run and that agent's policy. Nothing over MCP approves, rejects or undoes. MCP

Two database modes

postgres chronos
Holds the data your Postgres, 16 or later the bundled Chronos engine
Agent worlds (fork, merge, undo) the bundled engine, attached to your Postgres native
Apps connect with your Postgres URL postgres://…@127.0.0.1:54329/main
Good for adding agents to an existing app new apps, the most agent features

Self-hosting

Platforms Linux and macOS, x86_64 and arm64; the image for linux/amd64 and linux/arm64
Smallest 1 core, 1 GB memory, 2 GB disk. Recommended: 2 cores, 2 GB, 20 GB SSD
Ports 8000 HTTP (put TLS in front); 54329 the engine, local only
Releases Signed with cosign; checksums checked by the installer; pin with FORKBASE_VERSION=vX.Y.Z
Upgrades Replace the binary or the image; migrations run at start

Guides: Install · Docker · Self-hosting (TLS proxy, systemd, several servers, backups, monitoring) · Requirements · Troubleshooting

Configuration: forkbase.toml and the variables that override it

forkbase init writes forkbase.toml; any setting can be overridden by a variable. Every setting, with defaults: docs/configuration.md.

Variable Setting
FORKBASE_CONFIG the file (default forkbase.toml)
FORKBASE_DATA the data folder: secrets, the engine's database, logs (default .forkbase)
FORKBASE_LISTEN server.listen (default 127.0.0.1:8000)
FORKBASE_DB database.mode: postgres or chronos
FORKBASE_DATABASE_URL, FORKBASE_DATABASE_URL_FILE database.url (postgres mode)
FORKBASE_POOL_SIZE database.pool_size (default 16)
FORKBASE_CHRONOS_BIN chronos.bin
FORKBASE_CHRONOS_PG_LISTEN chronos.pg_listen (default 127.0.0.1:54329)
FORKBASE_LOG log filter (default info)
FORKBASE_EXTERNAL_URL auth.external_url: where this server is reached (tokens name it)
FORKBASE_SITE_URL auth.site_url: your app, where people return after links and social sign-in
FORKBASE_REDIRECT_URLS, FORKBASE_ORIGINS auth.redirect_urls, auth.origins (comma-separated)
FORKBASE_SIGNUPS, FORKBASE_PASSWORDS, FORKBASE_MAGIC_LINKS, FORKBASE_REQUIRE_VERIFIED auth.* switches
FORKBASE_ACCESS_TTL_S, FORKBASE_SESSION_TTL_S, FORKBASE_INACTIVITY_TTL_S token and session lifetimes
FORKBASE_MAIL, FORKBASE_MAIL_FROM, FORKBASE_SMTP_* auth.email.*: log (default), smtp, file, off
FORKBASE_GOOGLE_CLIENT_ID, FORKBASE_GOOGLE_CLIENT_SECRET, FORKBASE_GITHUB_CLIENT_ID, FORKBASE_GITHUB_CLIENT_SECRET social sign-in
FORKBASE_REST_SCHEMAS, FORKBASE_MAX_ROWS the schemas REST serves (default public), the most rows one read returns (1000)
FORKBASE_REALTIME_TABLES tables that send their changes (schema.table, comma-separated)
FORKBASE_STORAGE_BACKEND, FORKBASE_STORAGE_PATH, FORKBASE_FILE_SIZE_LIMIT, FORKBASE_S3_* storage: local or s3
FORKBASE_OTLP_ENDPOINT send each run's trace and metrics to an OpenTelemetry collector

Auth settings can also be changed live from the dashboard (Authentication, Configuration); they win over the file.

HTTP routes

Every route, who may call it and the error shapes: docs/http-reference.md.

Route
GET / name, version, mode
GET /health, GET /metrics 200 when the database answers; Prometheus text
/dashboard/ the dashboard
/auth/v1/... sign-in for your app's people
/rest/v1/... your tables, as the caller, under row-level security
/realtime/v1/... changes and broadcasts over WebSocket
/storage/v1/... files in buckets
/agents/v1/... agents, runs, worlds, policies, guardrails, approvals, undo, webhooks
/jobs/v1/... functions, jobs, schedules, triggers
/gateway/v1/... connections and the actions sent after a merge
/llm/v1/... model calls (Anthropic Messages, OpenAI Chat Completions) with a run's token
POST /mcp, /oauth/... the MCP server and its OAuth 2.1
/platform/v1/... what the dashboard calls (service key or team members)
GET /skills/install.sh, /skill/SKILL.md, /skill/setup.md the skills for coding agents
GET /llms.txt, /llms-full.txt the docs for language models

Example: a claims desk

examples/claims is an insurance app on Forkbase. Claims under $1,000 are decided by one agent and land on their own; larger ones are decided by another and wait for an adjuster; mold is excluded and denied. The dashboard screenshots above are this app. docker compose up in that folder, then node test.mjs.

Docs

Start Build Run
Getting started Auth · REST · Migrations Configuration
Concepts Realtime · Storage · Vectors CLI
Set up with an AI agent Agents · Guardrails · Chat Install · Docker
Docs home Jobs · Evals · Gateway Self-hosting
Roadmap MCP · Observability · SDKs HTTP reference
Dashboard · Skills Troubleshooting

For language models: llms.txt and docs/llms-full.txt, also served by every server at /llms.txt and /llms-full.txt. Online at forkbase.tech/docs.

Build from source

Rust (stable), Node 20+ for the dashboard.

cd dashboard && npm ci && npm run build && cd ..     # the dashboard, embedded at build time
cargo build --release                                # target/release/forkbase

The end-to-end tests need a Postgres (FORKBASE_TEST_PG, else the one on port 5416) and the chronos engine (FORKBASE_CHRONOS_BIN); without them they say SKIPPED, unless FORKBASE_E2E_REQUIRED=1. A binary built without the dashboard serves a page saying so.

Licence

FSL-1.1-ALv2: free to use, change and self-host, for anything but a competing hosted service. Each version becomes Apache-2.0 two years after its release.

About

The Supabase alternative for AI agents. Postgres, auth, REST, storage, realtime, jobs and MCP in one binary. Every agent run gets its own fork of your data, merged by policy, undoable row by row.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

8 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages