A backend Claude Code can set up by itself
Claude Code writes a good frontend and then stalls at "now create a database, add sign-in and paste the keys here". Scribase removes that step: one command gives the agent a live Postgres backend with sign-in, storage and realtime, writes the env file and installs the client. Everything on this page was run on 2026-11-16; the output shown is what came back.
Last checked November 16, 2026.
Step 1: one command, no account
Tell Claude Code to run this in your project folder. It detects Next.js, Expo, SvelteKit, Vite or plain Node, creates a temporary project, writes the env file and a client module, and installs @supabase/supabase-js. The project is free for 72 hours and the output includes a link to keep it.
npx scribase init --temp --yes --json$ npx scribase init --temp --yes --json
Backend ready in 25.1 s: https://tmp-….scribase.com (keys written to .env)
Installing @supabase/supabase-js with npm (your backend is already live)...
{
"ok": true,
"framework": "node",
"temporary": true,
"env_file": ".env",
"env_vars": ["SUPABASE_URL", "SUPABASE_ANON_KEY", "SCRIBASE_API_URL", "SCRIBASE_ORG",
"SCRIBASE_PROJECT", "SCRIBASE_ENV", "SCRIBASE_ACCESS_TOKEN"],
"client_file": "supabase.mjs",
"live_in_seconds": 25.1
}Step 2: the first table, with row level security
The database starts empty. The agent creates tables with SQL; new tables are visible to the REST API right away. Row level security is on for every new table, so nothing is readable through the API until a policy says so; the grant on the last line is the Supabase default and is kept only to be explicit.
npx scribase sql "
create table notes (
id bigint generated always as identity primary key,
user_id uuid not null default auth.uid(),
body text not null
);
alter table notes enable row level security;
create policy notes_own on notes for all to authenticated
using (user_id = auth.uid()) with check (user_id = auth.uid());
grant select, insert, update, delete on notes to authenticated;
"import { supabase } from './supabase.mjs';
await supabase.auth.signUp({ email, password });
await supabase.from('notes').insert({ body: 'hello' });
const { data } = await supabase.from('notes').select();Step 3: the guardrail an agent needs
Agents forget row level security. Tracked migrations refuse to apply when a public table would be left open, and nothing in the batch is applied until it is fixed. This is the real answer to a migration that created a table with no policy:
$ npx scribase migrate
1 migration(s) blocked:
20261116120303_open_table (not applied)
[BLOCK] missing_rls: table public.open_notes has neither RLS enabled nor any policy.
Nothing applied: a BLOCK finding above stops every pending migration until it is fixed.Step 4: connect the MCP server
For work beyond the first run, connect Claude Code to the hosted MCP server. The first connection opens a consent page in your browser, so there is no key to paste. On 2026-11-16 the server answered 98 tools, including projects_create, keys_get, migrations_apply, sql_execute, tables_describe, types_generate, storage_buckets_create and logs_get.
claude mcp add --transport http scribase https://api.scribase.com/mcpStep 5: tell Claude Code the rules
Add this to CLAUDE.md so every session follows the same flow. Each command in it is a real CLI command.
## Backend (Scribase)
- The backend is Scribase. Use the supabase-js client in ./supabase.mjs; never hardcode keys.
- Schema changes go through migrations: `npx scribase migrate new <name>`, edit the file,
`npx scribase migrate --dry-run`, then `npx scribase migrate`.
- Every new table needs at least one row level security policy (RLS itself is turned
on automatically). Grants to the API roles are there by default, as on Supabase.
- Only SUPABASE_URL and SUPABASE_ANON_KEY may appear in client code. Secret keys and
third-party keys stay in server-only variables or project secrets.
- Run `npx scribase doctor` after changing env files.Server-side secrets
The key the agent writes into your app is the publishable one: it can only do what your policies allow. Two kinds of secret stay on the server. The project secret key is for your own server code; third-party keys go into project secrets that only your functions can read.
// app/api/admin/invite/route.ts (runs on the server only)
import { createClient } from '@supabase/supabase-js';
// No NEXT_PUBLIC_ prefix: this key never reaches the browser bundle.
const admin = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_SECRET_KEY!, {
auth: { persistSession: false, autoRefreshToken: false },
});
export async function POST(request: Request) {
const { email } = await request.json();
// Admin calls are refused (403) with the publishable key.
const { data, error } = await admin.auth.admin.createUser({ email, email_confirm: true });
if (error) return Response.json({ error: error.message }, { status: 400 });
return Response.json({ id: data.user.id });
}# Store a third-party key as a project secret. It is encrypted at rest;
# the list route returns names and versions, never values.
curl -X PUT "$SCRIBASE_API_URL/v1/organizations/$SCRIBASE_ORG/projects/$SCRIBASE_PROJECT/environments/$SCRIBASE_ENV/secrets/PAYMENT_API_KEY" \
-H "Authorization: Bearer $SCRIBASE_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"value\": \"$PAYMENT_API_KEY\"}"
# {"name":"PAYMENT_API_KEY","version":1,"functions_refreshed":true}// supabase/functions/charge/index.ts (Deno, runs on Scribase)
Deno.serve(async (request) => {
const key = Deno.env.get('PAYMENT_API_KEY');
if (!key) return Response.json({ error: 'PAYMENT_API_KEY is not set' }, { status: 500 });
const { amount } = await request.json();
const charge = await fetch('https://api.payments.example/v1/charges', {
method: 'POST',
headers: { Authorization: `Bearer ${key}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ amount }),
});
// Only the result goes back to the app. The key stays on the server.
return Response.json({ ok: charge.ok }, { status: charge.ok ? 200 : 502 });
});What a temporary project cannot do
- Deploy functions. A temporary project answers 403 temporary_functions_disabled until it is claimed. Database, sign-in, storage and realtime all work.
- Live past 72 hours. It is deleted unless you keep it.
- Be kept for free. Keeping an agent-made project takes a sign-up and a card: it becomes a Hobby project at $5 a month, with the same data and keys. If you would rather start free, sign up first: one project stays free with no card, and the agent can use it through the MCP server.
Which supabase-js calls work
The code Claude Code writes against supabase-js runs unchanged. These are the calls we run ourselves:
| Area | Client calls | What is checked | Status |
|---|---|---|---|
| Auth | auth.signUp, signInWithPassword, getUser, updateUser, refreshSession, signOut | Email and password sessions end to end; a wrong password answers invalid_credentials. | Run live |
| Auth | auth.admin.createUser, listUsers, deleteUser, generateLink; auth.verifyOtp | Admin calls work with the secret key only; the publishable key is refused (403). Magic links sign in through verifyOtp. | Run live |
| Auth | auth.signInWithOAuth, signInWithIdToken, signInAnonymously, getClaims | OAuth redirects from the project host once a provider is enabled; native Apple and Google id-token sign-in; anonymous sign-in once enabled. | In the suite |
| Database | from().select, insert, update, delete, with eq, order, limit, count, single | CRUD and filters with the same error codes (single() on no rows is PGRST116). | Run live |
| Database | Row level security with auth.uid(); rpc() | Another user sees no rows, a forged user_id is refused with 42501, and rpc() runs as the caller. | Run live |
| Database | schema() for a non-public schema; embedded selects | A second schema is served once it is listed for the project; aliased and table-name embeds filter as documented. | In the suite |
| Storage | storage.from().upload, list, download, remove, createSignedUrl | Per-user folder policies hold, another user is refused, and a signed URL downloads with no key. | Run live |
| Storage | storage.createBucket, listBuckets, getPublicUrl, createSignedUploadUrl, resumable (TUS) uploads | Bucket management with the secret key, public bucket URLs, signed uploads and an upload that survives a dropped connection. | In the suite |
| Realtime | channel().on("broadcast").subscribe, send | A broadcast sent by one client reaches another. | Run live |
| Realtime | channel().on("presence"), on("postgres_changes") | Presence sync sees a tracked peer; INSERT, UPDATE and DELETE on a row-level-security table reach only the row owner. | In the suite |
| Edge Functions | functions.invoke | A deployed Deno function sees the caller role and body; a call with no key gets 401. Needs a claimed project: temporary projects refuse function deploys. | In the suite |
Questions people ask
What is the best backend for Claude Code?
One the agent can create and change without you pasting keys or clicking through a dashboard. With Scribase, Claude Code runs npx scribase init --temp and gets Postgres, sign-in, storage and realtime in one step (25.1 seconds in our run on 2026-11-16), then makes schema changes through migrations that are blocked when a table would be left without row level security.
Does Claude Code need an account or an API key to start?
No. A temporary project needs no account and lasts 72 hours. The command writes a project-scoped token into the env file for the agent's own use.
scribase sql says "access is denied (HTTP 403)". Why?
Most often your shell already exports SCRIBASE_ACCESS_TOKEN from another project, and it wins over the env file init wrote. Unset it, or run the command with the values from this folder’s env file. We hit this ourselves while testing this page.
Is it safe to let an agent change my database?
Schema changes through npx scribase migrate are planned and linted first, and a public table with no row level security policy blocks the whole run. Statements that remove data (DROP, TRUNCATE, DELETE without WHERE) only run through npx scribase sql with --confirm.
What does it cost after the trial project?
One project per account is free with no time limit (0.5 GB database, 1 GB files, no card). More projects are Hobby at $5 or Pro at $25 per project a month.