> ## Documentation Index
> Fetch the complete documentation index at: https://docs.result.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI overview

> npx @resultdev/cli - setup and admin operations for your backend.

```bash theme={"dark"}
npx @resultdev/cli init
```

The CLI handles everything that needs the admin key: tables, migrations,
buckets, realtime channels, functions, secrets and payment keys. App code
never does these - it uses the [SDK](/sdk/database) with the publishable key.

## Credentials

The CLI reads `.env.local` (then `.env`) in the current directory:

```bash theme={"dark"}
NEXT_PUBLIC_BACKEND_URL=...   # backend base URL
BACKEND_ADMIN_KEY=...         # admin key - server/terminal only
```

Both are on your app's page in the Result dashboard. To override them, pass
the global flags **before** the command:
`result --url <url> --key <key> <command>`.

## `result init`

Run this once per project, first. It:

1. Verifies the credentials against the live backend.
2. Writes the backend rules into `AGENTS.md` (creating or updating a marked
   section - safe to re-run).
3. Creates `CLAUDE.md` pointing at `AGENTS.md` if you don't have one.

That persistence step is what keeps AI coding agents working correctly in
future sessions - a fresh chat thread reads `AGENTS.md` and knows the SDK,
the CLI, and the rules without being told.

## Errors

Every failure prints the backend's own fix hint:

```
Error 400 (INVALID_INPUT): <what went wrong>
  → <what to do instead>
```

Full command list: [CLI reference](/cli/reference).
