caelum0x 99be4ae12d docs: SCR-DIR AGENTS.md says a new table reaches the REST API about 3 s after the SQL commits
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>
2026-11-30 21:11:59 +03:00

92 lines
3.8 KiB
Markdown

# AGENTS.md
For a coding agent (Claude Code, Codex, Cursor, Windsurf or any other) working
in a clone of `expo-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=expo-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` with `EXPO_PUBLIC_SUPABASE_URL` and `EXPO_PUBLIC_SUPABASE_ANON_KEY`, the two values this
app reads, plus `SCRIBASE_ACCESS_TOKEN`, the token the next commands use.
`.env` 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
npx expo start
```
The human scans the QR code with Expo Go, or presses `i` / `a` for a
simulator, signs up with any email and adds a note. With no device or
simulator in your session, run `npm run typecheck` (must print no errors) and
say plainly that the app was not opened on a device.
## 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` 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.
- Only `EXPO_PUBLIC_` variables reach the app bundle. Never add
`SCRIBASE_ACCESS_TOKEN` or a service-role key under that prefix.
- `npx scribase doctor` prints one fix per problem if any step fails.
Docs: https://docs.scribase.com/docs/agents/prod-approver