# Using Rezin Core with an AI coding assistant

Two separate things help an assistant write correct code for Rezin Core: giving it these docs, and (optionally) connecting it to your project.

## 1. Give it the docs

Everything in this documentation is available as plain Markdown, with no page chrome.

| Address | What it is |
|---|---|
| `https://rezincore.com/llms.txt` | An index of every page with a one-line description and a link to its Markdown |
| `https://rezincore.com/llms-full.txt` | The whole documentation in one file |
| `https://rezincore.com/docs/<page>.md` | Any single page as Markdown: the page's address with `.md` on the end |

For a short task, point the assistant at the one page it needs, for example `https://rezincore.com/docs/database/data-api.md`. For a larger one, give it `llms-full.txt`.

A line to put in your project's instructions for the assistant:

```
This project's backend is Rezin Core. Before writing code that calls it, read
https://rezincore.com/llms.txt and the pages it lists that apply. Use only what
those pages document; where a page says "being built" or "not built", do not
write code against it.
```

## 2. Connect it to your project (optional)

With the [connector](https://rezincore.com/docs/tools/connector.md) an assistant can look at your real tables, run SQL and apply migrations, instead of guessing your schema.

1. Make a [personal access token](https://rezincore.com/docs/tools/access-tokens.md): one project, look only, 7 days.
2. Add the connector to your assistant with that token.
3. Ask it to call `list_tables` before it writes anything.

Allow changes only for a session that must change something, and disconnect or revoke afterwards. Most assistants can [connect by signing in](https://rezincore.com/docs/tools/connector.md#connect-by-signing-in), where you choose the projects, the parts and whether it may deploy functions; nothing needs to be pasted.

> **Important.** A connected assistant is an outside service: what it reads goes to whoever runs it. Do not connect one to a project that holds health information or any other data you may not share with that provider. Use a development project with made-up data.

## Rules worth giving an assistant

These are the mistakes that come up most. Paste them in.

```
Rezin Core rules:
- The API is https://api.rezincore.com. Every request sends the project key in the
  "apikey" header. A signed-in user's token goes in "Authorization: Bearer <token>".
- Never put a secret key (rzc_sec_...) in browser or mobile code. Use the
  publishable key (rzc_pub_...) there.
- There is no client library. Call the HTTPS API directly.
- Rows are scoped by organization. Tables that belong to a tenant have an
  organization_id column; policies compare it with core.app_org(), and the user
  with core.app_user().
- A new table is closed: row-level security is on with no policy. After creating a
  table, add a policy and allow the application to use the table, or the API
  returns no rows.
- PATCH and DELETE on /v1/data/<table> require a filter such as ?id=eq.<id>.
- Filters are column=operator.value (eq, neq, gt, gte, lt, lte, like, ilike, in, is).
  There are no joins or aggregates in the data API.
- Tokens end after 15 idle minutes or 12 hours. There is no refresh token: on
  401 signed_out, send the user to sign in again.
- Sign-in can answer 401 code_required. Ask for the authenticator code and send
  the same request again with it.
- Schema changes go in numbered migration files applied with "rezin migrations push".
- Server-side code is a Rezin Core function: one JavaScript module doing
  "export default async (request, context) => new Response(...)". No packages.
  It reaches data only with fetch to context.apiUrl and a key from context.secrets.
- Not built yet: password reset or change through the API, a client library,
  direct Postgres connections. Do not invent them.
```

## What an assistant can check for itself

- `list_tables` shows, for each table, whether row-level security is on and how many rules it has. A table with it on and zero rules is closed.
- `get_logs` shows what its own actions did, and any refusals.
- `run_sql` without `write` cannot change anything, so it is safe for exploring.

## What is recorded

Everything the assistant does through the connector is on the project's **Activity → Record** page under your name, marked as coming through the connector.
