init wrote src/supabase.ts with process.env for this repo (it is detected as plain Node), which broke npm run typecheck. The repo now carries its own src/supabase.ts built from the Worker env, so init leaves it alone. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
3.4 KiB
cloudflare-worker-scribase-starter
A Cloudflare Worker that reads and writes a Postgres table on Scribase over REST: no ORM and no connection pool at the edge. A coding agent can set up the whole backend by itself; you get a claim link at the end.
Run it
git clone https://rithub.dev/scribase/cloudflare-worker-scribase-starter.git
cd cloudflare-worker-scribase-starter
npm install
npx scribase init --temp # live backend, keys written to .env
npx scribase sql --file supabase/setup.sql # the notes table, row level security on
grep '^SUPABASE_' .env > .dev.vars # wrangler reads .dev.vars for local dev
npm run dev
curl -X POST http://localhost:8787/notes -H 'content-type: application/json' -d '{"body":"hello from the edge"}'
curl http://localhost:8787/notes
For coding agents
AGENTS.md is the whole job in four steps. Point Claude Code,
Codex, Cursor or Windsurf at this repo and say "set this up". The agent runs:
npx scribase init --temp --yes --json
It gets a live backend in about a minute with no sign-up, sees the first
request answered in the same JSON (first_request: 2 rows read from a sample
table over REST with the public key), creates the notes table and hands you
one link.
Claim the project
The backend the agent made is a temporary project: free, real, and deleted
after 72 hours unless someone keeps it. The link the agent gives you (also the
second line of .env) is the claim link.
- Open it. Use the whole link, including the part after
#. - Sign up. Free for 14 days, no card. One project stays free after that.
- The project moves into your account. The URL and keys do not change, so the
app keeps running and
.envstays as it is.
Not claimed in 72 hours: the project and its data are deleted. Nothing else happens and nobody is billed.
The approver gate
A claimed project is where your agent keeps working, so decide what it may do alone. In the console: Project > Settings > Policies > Production approver. Type one email address and save.
From then on:
- The agent's token reads, writes and adds tables as before.
- A destructive change to production from that token (
DROP,TRUNCATE, aDELETEorUPDATEwithoutWHERE, a restore) does not run. The agent gets202 approval_requiredand waits. - The approver gets an email with Approve and Deny. Approve runs the stored request once, exactly as it was sent. Deny, or no answer, runs nothing.
- The agent cannot name the approver or approve its own request.
- Row level security is required on every public table.
supabase/setup.sqlhere already has it; a table without it is refused.
A run of this gate against the live API, with the transcript: approval-gate-demo. Docs: production approver.
Deploy
npx wrangler secret put SUPABASE_URL
npx wrangler secret put SUPABASE_ANON_KEY
npm run deploy
Only those two values go to the Worker. SCRIBASE_ACCESS_TOKEN stays on your
machine.
Files
AGENTS.md: the steps a coding agent followssupabase/setup.sql: the publicnotestable and its policiessrc/index.ts: the Worker,GET /notesandPOST /notessrc/supabase.ts: the client, built from the Worker'senvwrangler.toml: Worker config