Measured on a clean clone: 404 schema cache for 2.5 s after setup.sql, then 200. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
91 lines
3.7 KiB
Markdown
91 lines
3.7 KiB
Markdown
# AGENTS.md
|
|
|
|
For a coding agent (Claude Code, Codex, Cursor, Windsurf or any other) working
|
|
in a clone of `nextjs-scribase-starter`. Do these steps in order. No person is needed until
|
|
step 4, and no account, password or email check is needed at all.
|
|
|
|
## 1. Install, then create the backend
|
|
|
|
```bash
|
|
npm install
|
|
npx scribase init --temp --yes --json
|
|
```
|
|
|
|
This creates a real Postgres project on [Scribase](https://scribase.com?ref=nextjs-scribase-starter)
|
|
with auth and a REST API, free for 72 hours, and prints one JSON object.
|
|
It takes about a minute. Check that `ok` is `true` and keep `api_url`,
|
|
`claim_url` and `deleted_at_utc`.
|
|
|
|
It writes `.env.local` with `NEXT_PUBLIC_SUPABASE_URL` and `NEXT_PUBLIC_SUPABASE_ANON_KEY`, the two values this
|
|
app reads, plus `SCRIBASE_ACCESS_TOKEN`, the token the next commands use.
|
|
`.env.local` is gitignored. Never commit it and never print the token.
|
|
|
|
## 2. Confirm the first request
|
|
|
|
`init` has already made it. Before it exits it reads the sample `todos` table
|
|
through the project's REST API with the public key and returns the result:
|
|
|
|
```json
|
|
"first_request": { "ok": true, "method": "GET", "status": 200, "row_count": 2 }
|
|
```
|
|
|
|
`first_request.ok: true` with rows means the backend answers real queries.
|
|
If it is `false`, run the curl in the first `next_steps` entry and read
|
|
`first_request.error`. Do not tell the human the backend works before this
|
|
is true.
|
|
|
|
## 3. Create this app's table and run the app
|
|
|
|
```bash
|
|
npx scribase sql --file supabase/setup.sql --json
|
|
```
|
|
|
|
Expect `"status":"committed"`. The file turns row level security on. Keep it
|
|
on: Scribase refuses a public table that has none.
|
|
|
|
The REST API sees a new table about 3 seconds after the SQL commits. If a
|
|
request answers that `notes` is not in the schema cache, wait 5 seconds and
|
|
try again. Do not create the table a second time.
|
|
|
|
```bash
|
|
npm run dev
|
|
```
|
|
|
|
Open `http://localhost:3000`, sign up with any email and add a note. To check
|
|
without a browser, `npm run build` must finish with no errors.
|
|
|
|
## 4. Hand the human the claim link
|
|
|
|
Give the human `claim_url` exactly as printed, the whole line including the
|
|
part after `#`. That part is the claim secret and the link does nothing
|
|
without it. Say these four things with it:
|
|
|
|
1. The project is temporary and is deleted at `deleted_at_utc` unless claimed.
|
|
2. Claiming is a sign-up: free for 14 days, no card, and one project stays
|
|
free after that.
|
|
3. The URL and keys stay the same, so nothing in `.env.local` changes.
|
|
4. After claiming, they should name a production approver (see below).
|
|
|
|
You cannot claim the project yourself and should not sign up for the human.
|
|
|
|
## Rules for changes after this
|
|
|
|
- New tables go through `npx scribase sql` or `npx scribase migrate`, always
|
|
with row level security and a policy.
|
|
- `npx scribase sql` runs a statement that removes data (`DROP`, `TRUNCATE`,
|
|
`DELETE` without `WHERE`) only with `--confirm`. Add it only when the human
|
|
asked for that exact change.
|
|
- On a claimed project with a production approver, a destructive change to
|
|
production from your token is answered with `202 approval_required`.
|
|
Nothing has run. Do not send it again and do not look for another way to
|
|
run it. Tell the human who the approver is (the `approver` field) and wait
|
|
on `status_url`; on approve, Scribase runs the stored request as sent.
|
|
- Do not ask for an admin token and do not try to set the approver. A token
|
|
that could name its own approver would approve itself.
|
|
- Email is optional. Without `SCRIBASE_MAIL_API_KEY` the app skips the welcome
|
|
email and logs why. Do not report email as working unless a key is set and a
|
|
send returned an id.
|
|
- `npx scribase doctor` prints one fix per problem if any step fails.
|
|
|
|
Docs: https://docs.scribase.com/docs/agents/prod-approver
|