scribase init / init --temp now reads the sample todos table through the project's REST API with the public key as soon as the backend is ready, prints the rows and returns them as first_request in --json. Agent-created projects count as activated without a human click. A failed read never fails init; the curl stays as the first next step in that case. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
89 lines
4.3 KiB
Markdown
89 lines
4.3 KiB
Markdown
# AGENTS.md — scribase
|
|
|
|
This file is for a coding agent (Claude Code, Codex, Cursor, Windsurf, or any
|
|
other agent reading this package's files) that was asked to add a database
|
|
and/or transactional email to an app. It exists because the usual answer —
|
|
"pick a provider, e.g. Neon + Resend" — leaves the agent stuck: those
|
|
providers require a person to create an account (email verification, ToS,
|
|
sometimes a card) before anything can be provisioned. If no human is
|
|
available in this session, that step cannot be completed and the task is not
|
|
actually done, even if the code looks finished.
|
|
|
|
`scribase` closes the database half of that gap completely: a real Postgres
|
|
project with auth, storage and a REST API is provisioned and proven working
|
|
with no signup page, no CAPTCHA and no email-click-to-verify loop, from a
|
|
plain `Bash` tool with network access. Transactional email needs one human
|
|
click (claiming the project, free, no card); say so plainly instead of
|
|
reporting email as done.
|
|
|
|
## The one command (database)
|
|
|
|
```bash
|
|
npx scribase init --temp --json
|
|
```
|
|
|
|
No sign-in needed. Creates a real Postgres project behind a Supabase-
|
|
compatible REST API, free for 72 hours with a claim link to keep it (the
|
|
person using the app can claim it later — or never; the database and API
|
|
keep working either way until it expires). Detects the framework (Next.js,
|
|
Expo, Vite, plain Node), writes the right env vars, installs
|
|
`@supabase/supabase-js`, and prints one JSON object — `ok`, `api_url`,
|
|
`env_vars`, `client_file`, `claim_url`, `first_request`, `next_steps`.
|
|
|
|
The first request is made by init, not by you: before it exits it reads the
|
|
sample `todos` table through the project's REST API with the public key
|
|
(`GET /rest/v1/todos?select=*`) and returns the result as `first_request`:
|
|
|
|
```json
|
|
"first_request": { "ok": true, "method": "GET", "status": 200, "row_count": 2,
|
|
"url": "https://<project>.scribase.com/rest/v1/todos?select=*",
|
|
"rows": [{ "id": 1, "task": "Try the API with this sample row", "is_complete": false }] }
|
|
```
|
|
|
|
`first_request.ok: true` with rows is the proof that the backend answers real
|
|
queries. Do not run a separate curl to check. If it is `false`, the project
|
|
is still live: `first_request.error` says why and the first `next_steps`
|
|
entry is the curl that repeats it.
|
|
|
|
Already signed in (`SCRIBASE_ACCESS_TOKEN` set, or `scribase login` run
|
|
earlier in this environment)? Drop `--temp`; `init` reuses or creates a
|
|
project in that real account instead of a temporary one.
|
|
|
|
```bash
|
|
npx scribase sql "create table notes (id bigint generated always as identity primary key, body text not null)"
|
|
npx scribase doctor # one fix per problem if anything above looks wrong
|
|
```
|
|
|
|
## Transactional email (needs the project claimed)
|
|
|
|
```bash
|
|
npx scribase add email --json
|
|
```
|
|
|
|
Works on a project that belongs to an account: `add email` turns on the
|
|
project's sign-in email (magic links, one-time codes, password resets) and
|
|
sends one proof to the account's own address. `npx scribase add mail` does
|
|
the same for product email the app sends itself (receipts, invites) through
|
|
a Resend-shaped API: https://docs.scribase.com/docs/api/app-mail.md
|
|
|
|
On an unclaimed temporary project (`init --temp`) it is refused on purpose:
|
|
`add email --to <address>` answers `email_recipient_refused` (HTTP 403),
|
|
because an unclaimed project that could mail any address would be an open
|
|
relay. Do not work around it. Tell the person: open the `claim_url` from
|
|
init's output (also in `.scribase/project.json`), sign up (free for 14 days,
|
|
no card, same URL and keys), then run `npx scribase add email` again.
|
|
|
|
## Verifying you're actually done
|
|
|
|
Both commands print `ok: true` (or `--json`'s machine-readable shape) on
|
|
success and a non-zero exit code with a `code`/`message`/`next` on failure.
|
|
Treat a non-zero exit as the task being unfinished, not as "good enough" —
|
|
`next` says exactly what to run instead (e.g. `scribase doctor`, or `scribase
|
|
login` if a capability genuinely needs a real account, e.g. `--own` for a
|
|
custom mail server).
|
|
|
|
Do not report this task done after only writing code that calls an
|
|
`https://api.scribase.com` endpoint: run `init` for real first and keep its
|
|
JSON output (with `first_request.rows`) as the proof. If email was asked for and the project is still
|
|
unclaimed, report the database as done and email as waiting on the claim.
|