caelum0x 43875e1bb1 feat: SCR-DIR AGENTS.md for coding agents, claim flow and approver gate in README
AGENTS.md gives any coding agent the four steps: npm install,
npx scribase init --temp --yes --json, confirm first_request, create the
notes table from supabase/setup.sql, hand the human the claim link.
README gains the claim flow and the production approver gate.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-30 21:07:07 +03:00

105 lines
4.1 KiB
Markdown

# nextjs-scribase-starter
Next.js 14 App Router starter on [Scribase](https://scribase.com?ref=nextjs-scribase-starter):
email and password sign-in, a per-user Postgres table behind row level
security, and a welcome email on sign-up. A coding agent can set up the whole
backend by itself; you get a claim link at the end.
## Run it
```bash
git clone https://rithub.dev/scribase/nextjs-scribase-starter.git
cd nextjs-scribase-starter
npm install
npx scribase init --temp # live backend, keys written to .env.local
npx scribase sql --file supabase/setup.sql # the notes table, row level security on
npm run dev
```
Open `http://localhost:3000`, sign up with any email and add a note. No
dashboard, no sign-up form, no keys to copy.
## For coding agents
[`AGENTS.md`](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:
```bash
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.local`) is the claim link.
1. Open it. Use the whole link, including the part after `#`.
2. Sign up. Free for 14 days, no card. One project stays free after that.
3. The project moves into your account. The URL and keys do not change, so the
app keeps running and `.env.local` stays 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`, a
`DELETE` or `UPDATE` without `WHERE`, a restore) does not run. The agent gets
`202 approval_required` and 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.sql`
here already has it; a table without it is refused.
A run of this gate against the live API, with the transcript:
[approval-gate-demo](https://rithub.dev/caelum0x/approval-gate-demo). Docs:
[production approver](https://docs.scribase.com/docs/agents/prod-approver).
## Email
Sign-up also sends a welcome email through [Scribase Mail](https://mail.scribase.com).
It is optional: without `SCRIBASE_MAIL_API_KEY` the app logs why it skipped
and keeps working. A free `sk_test_...` key from mail.scribase.com simulates
sends with no domain to verify.
```bash
echo 'SCRIBASE_MAIL_API_KEY=sk_test_...' >> .env.local
```
## What `scribase init` wrote to `.env.local`
```
NEXT_PUBLIC_SUPABASE_URL=... # this project's REST and auth endpoint
NEXT_PUBLIC_SUPABASE_ANON_KEY=... # public key; rows are protected by row level security
SCRIBASE_ACCESS_TOKEN=... # used by `npx scribase sql`; never commit or ship it
```
Scribase speaks the Supabase API, so the app uses `@supabase/ssr` and
`@supabase/supabase-js` unchanged. `SUPABASE_URL` / `SUPABASE_ANON_KEY` are
read too if your host sets those names instead.
## Files
- `AGENTS.md`: the steps a coding agent follows
- `supabase/setup.sql`: the `notes` table and its policy
- `app/page.tsx`, `app/auth-form.tsx`: sign up and sign in (Server Actions)
- `app/notes/page.tsx`, `app/notes/note-form.tsx`: the per-user notes list
- `app/actions.ts`: `signUp`, `signIn`, `signOut`, `addNote`
- `lib/supabase-server.ts`: the server-side client
- `lib/mail.ts`: the welcome email call
- `middleware.ts`: refreshes the session cookie on every request