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

# CLI

> The prysm command — scaffold a BRAIN.md, preview routing, generate and review code, run cost-bounded agents, verify PrysmProof receipts offline, and chat from your terminal.

The `prysm` command ships with the [Python SDK](/sdks/python). Install it once and you
have BRAIN.md scaffolding, connectivity checks, routing previews, the model catalog,
BRAIN.md validation, usage stats, one-shot chat,
[multi-model orchestration](/concepts/orchestration),
[self-correcting code generation](/concepts/code-mode), multi-model code review,
cost-bounded [agent runs](/concepts/agentguard), offline [PrysmProof](/concepts/prysmproof)
verification, and [compliance previews](/concepts/compliance) from the terminal.

```bash theme={null}
pip install prysm1
```

Configure it with the standard environment variables:

```bash theme={null}
export PRYSM_API_KEY="prysm_sk_your_key"
# Optional:
export PRYSM_BASE_URL="https://api.prysm1.com/v1"
```

## Commands

| Command                               | What it does                                                                                                 |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `prysm init`                          | Scaffold a starter `BRAIN.md` in the current directory.                                                      |
| `prysm connect`                       | Verify your API key and test connectivity to the PRYSM backend.                                              |
| `prysm connect cursor`                | Wire your PRYSM key into Cursor's settings in one command.                                                   |
| `prysm connect claude`                | Register PRYSM as an MCP server in Claude Desktop.                                                           |
| `prysm route "<prompt>"`              | Preview routing + estimated cost (no model call).                                                            |
| `prysm models`                        | List the full model catalog with pricing, sorted by input price.                                             |
| `prysm brain validate [path]`         | Validate a BRAIN.md (defaults to `./BRAIN.md`).                                                              |
| `prysm usage`                         | Usage stats for your key.                                                                                    |
| `prysm chat "<prompt>"`               | One-shot completion (routed) — prints the answer.                                                            |
| `prysm orchestrate "<prompt>"`        | Multi-model orchestration (v2) — prints the answer + which models ran.                                       |
| `prysm code "<task>"`                 | Code Mode (v2) — self-correcting code generation; prints the files.                                          |
| `prysm review <file>...`              | Multi-model review of existing files — cross-provider critic + static scan; CI-friendly exit code.           |
| `prysm agent "<goal>"`                | Run a cost-bounded, proof-bound agent; prints a one-line receipt.                                            |
| `prysm verify <file>`                 | Re-verify a saved receipt/trajectory locally — offline, no key, no trust.                                    |
| `prysm compliance preview "<prompt>"` | Dry-run the [compliance gate](/concepts/compliance) — classes, allowed/excluded models, CCP (no model call). |
| `prysm --version`                     | Print the installed version.                                                                                 |

### `prysm init`

Scaffold a starter [BRAIN.md](/concepts/brain-md) in your project root — the fastest
way to start customising routing without reading the full spec.

```bash theme={null}
$ prysm init
Created /your/project/BRAIN.md
Edit it to customise routing, then run `prysm brain validate` to check it.
```

The generated file includes a cost cap, two sample routing rules (code → DeepSeek,
write → Claude), a blocked-model example, and a fallback chain. Customise then
validate:

```bash theme={null}
prysm brain validate   # confirms the file is valid before you ship
```

Add `--force` to overwrite an existing `BRAIN.md`:

```bash theme={null}
prysm init --force
```

***

### `prysm connect`

Verify that your API key is valid and that the PRYSM backend is reachable — useful
when setting up a new machine or debugging an unexpected 401.

```bash theme={null}
$ prysm connect
connected  https://api.prysm1.com/v1
user:      usr_abc123
plan:      pro
requests:  847
```

Exits `0` on success and `1` with a diagnostic message on any connection or auth
error — so it works as a boot check in startup scripts or CI environment validation.

#### `prysm connect cursor`

Wire your PRYSM key into Cursor in one command — no settings tab hunting required.

```bash theme={null}
$ prysm connect cursor
Cursor connected.
  Settings: ~/Library/Application Support/Cursor/User/settings.json
  OpenAI key: prysm_sk_••••••••
  Base URL:   https://api.prysm1.com/v1
```

Writes `cursor.general.openAIKey` and `cursor.general.openAIBaseUrl` directly into
Cursor's `settings.json`. After running it, set `model: "auto"` in any Cursor rule
file and Cursor will route through PRYSM automatically.

#### `prysm connect claude`

Register PRYSM as an MCP server inside Claude Desktop.

```bash theme={null}
$ prysm connect claude
Claude Desktop connected.
  Config: ~/Library/Application Support/Claude/claude_desktop_config.json
  MCP entry: prysm  (command: npx @prysmai/mcp)
```

Adds a `prysm` entry under `mcpServers` in Claude Desktop's config, then prints a
reminder to restart Claude Desktop. From that point, Claude can call PRYSM tools
(routing preview, usage, BRAIN.md validation) directly from within the conversation.

***

### `prysm route`

Preview which model PRYSM would pick — and what it would cost — without spending
anything. Add `--mode` to force `quality`, `balanced`, or `agility`.

```bash theme={null}
$ prysm route "write a python function to sort a list"
model:    deepseek-v4-flash  (DeepSeek V4 Flash)
mode:     balanced    tier: budget
why:      Code: 95% cheaper than GPT-5.2
est cost: $0.000350 / 1K tokens  (in 0.14 / out 0.28 per MTok)
signals:  code
```

```bash theme={null}
prysm route "summarize this 30-page report in depth" --mode quality
```

### `prysm models`

```bash theme={null}
$ prysm models
MODEL                    TIER       IN $/MTok  OUT $/MTok
mistral-nemo             budget          0.02        0.02
gpt-5-nano               budget          0.05         0.4
gemini-2.5-flash-lite    budget           0.1         0.4
...
27 models
```

### `prysm brain validate`

Validates `./BRAIN.md` by default, or a path you pass. Exits non-zero when the config is
invalid — handy in CI.

```bash theme={null}
$ prysm brain validate
VALID  (BRAIN.md)

$ prysm brain validate config/BRAIN.md
INVALID  (config/BRAIN.md)
  error:   unknown model in rule: ghost-model
```

<Tip>
  Wire it into a pre-commit hook or CI step so a broken `BRAIN.md` never ships:

  ```bash theme={null}
  prysm brain validate || exit 1
  ```
</Tip>

### `prysm usage`

```bash theme={null}
$ prysm usage
user:     usr_demo   plan: free
requests: 128
tokens:   512340
cost:     $0.214500
```

### `prysm chat`

A one-shot routed completion. The answer prints to stdout; the routing summary prints to
stderr, so you can pipe the answer cleanly.

```bash theme={null}
$ prysm chat "explain a bloom filter in two sentences"
A Bloom filter is a space-efficient probabilistic data structure...
[routed to DeepSeek V4 Flash · $0.000029]
```

```bash theme={null}
# Pipe just the answer (routing note goes to stderr):
prysm chat "name three uses for a heap" > answer.txt
```

### `prysm orchestrate`

Run a prompt across **several** models and synthesize one answer — then see which models
contributed and how strongly they agreed. Pick the objective with `--policy`; force an
execution shape with `--strategy`. See [How orchestration works](/concepts/orchestration).

```bash theme={null}
$ prysm orchestrate "Compare three database designs for a 40-person team" --policy depth
Across the three designs, the trade-offs cluster around consistency vs. operational cost...

policy:   depth    strategy: ensemble_moa
models:   claude-sonnet-4.5, gpt-5.2, gemini-3.1-pro
agree:    0.81    confidence: 0.88
cost:     $0.004812 (est)    proof: sha256:a1b2c3d4e5f60718
```

| Flag         | What it does                                                                                                    |
| ------------ | --------------------------------------------------------------------------------------------------------------- |
| `--policy`   | `efficiency`, `balanced` (default), or `depth`.                                                                 |
| `--strategy` | Force `single`, `cascade`, `ensemble_moa`, `rank_fuse`, `decompose_and_route`, `self_consistency`, or `debate`. |
| `--k`        | Ensemble / sample width.                                                                                        |
| `--max-cost` | Soft budget hint, in USD.                                                                                       |

### `prysm code`

Generate code with a self-correcting, multi-model loop: a coder writes it, a **separate**
critic reviews it, and the coder repairs against the feedback. The files print to stdout;
the run summary (verdict, models, cost, proof) prints to stderr, so you can pipe the code
cleanly. See [How Code Mode works](/concepts/code-mode).

```bash theme={null}
$ prysm code "Write a Python function to add two numbers" --policy balanced
===== main.py  (python) =====
def add(a, b):
    """Return the sum of two numbers."""
    return a + b

[PASS] policy: balanced    language: python    iterations: 1
coders: qwen-2.5-72b    reviewer: deepseek-v4-pro
cost: $0.000412 (est)    proof: sha256:7f3a9c2b1e4d8a06
```

Write the files to disk instead of stdout, force the models, or skip the critic loop:

```bash theme={null}
# Write generated files into ./out (creates directories as needed):
prysm code "Implement a CLI todo app in Python" --policy depth --out ./out

# Single shot, no critic loop:
prysm code "Write a Python hello world" --no-review
```

| Flag                    | What it does                                          |
| ----------------------- | ----------------------------------------------------- |
| `--policy`              | `efficiency`, `balanced` (default), or `depth`.       |
| `--language` / `--lang` | Force the target language (auto-detected if omitted). |
| `--coder-model`         | Force the model that writes the code.                 |
| `--reviewer-model`      | Force the critic model.                               |
| `--max-iters`           | Generate + up to `max-iters - 1` repairs.             |
| `--no-review`           | Single shot — skip the critic loop.                   |
| `--max-cost`            | Soft budget hint, in USD (stops the repair loop).     |
| `--out`                 | Write files to this directory instead of stdout.      |

<Note>
  `prysm code` exits `0` when the review passes and `1` when it fails (or on error), so it
  drops cleanly into CI and scripts.
</Note>

### `prysm review`

Review **existing** files instead of generating new ones: a cross-provider critic plus a
deterministic static scan (CodeGuard) produce structured findings. The server never executes
your code. Findings print grouped by severity with a rule id, `file:line`, message, and any
suggested fix.

```bash theme={null}
$ prysm review src/auth.py src/handlers.py
reviewed 2 file(s) - 1 finding(s) - score 0.86
  [HIGH  ] src/auth.py:42  py-eval-exec
           Use of eval()/exec() can execute arbitrary code; avoid or sandbox.
FAIL (a finding is at/above 'high')
```

```bash theme={null}
# Cross-provider second opinion + a SHA-256 receipt you can re-verify offline later:
prysm review app.py --verify --receipt

# Only fail the build on medium-or-worse; machine-readable output:
prysm review app.py --fail-on medium --json
```

| Flag        | What it does                                                                          |
| ----------- | ------------------------------------------------------------------------------------- |
| `--policy`  | `efficiency`, `balanced` (default), or `depth`.                                       |
| `--verify`  | Add a cross-provider second opinion + consensus score.                                |
| `--receipt` | Attach a SHA-256 receipt, re-verifiable offline with `prysm verify`.                  |
| `--fail-on` | Exit `1` if any finding is at/above this severity: `high` (default), `medium`, `low`. |
| `--json`    | Machine-readable output.                                                              |

<Note>
  Exits `1` when a finding is at/above `--fail-on`, else `0` — drop it straight into a CI step.
</Note>

### `prysm agent`

Run a PRYSM-Agentic goal from the terminal. The run **can never spend more than its cap**
([AgentGuard](/concepts/agentguard)), and it returns a verifiable trajectory proof even if it
stops early on the budget or step ceiling.

```bash theme={null}
$ prysm agent "Summarize this repo's architecture and grade its risk" --max-cost 0.50
Summarize this repo's architecture and grade its risk - 3 step(s), $0.0412 of $0.50 cap, complete, proof sha256:9d2f…, verify at /v1/agent/verify

run_id: agt_8b1c2d…
```

| Flag           | What it does                                                    |
| -------------- | --------------------------------------------------------------- |
| `--max-cost`   | Hard spend cap in USD (defaults to the plan's per-run ceiling). |
| `--max-steps`  | Cap the number of steps.                                        |
| `--policy`     | `efficiency`, `balanced`, or `depth`.                           |
| `--show-steps` | Print the per-step trajectory summary.                          |
| `--json`       | Machine-readable output (the full run state).                   |

<Note>
  Exits `0` only when the run completes; a budget / step / risk stop exits `1`.
</Note>

### `prysm verify`

Re-verify a saved PRYSM artifact **locally — no network, no API key, no trust in the server.**
Point it at a saved [Code receipt](/concepts/code-mode) or agent trajectory (or pipe one on
stdin); it recomputes the [PrysmProof](/concepts/prysmproof) and tells you whether the artifact
is intact.

```bash theme={null}
# Save a reviewed receipt, then verify it independently — even months later, offline:
prysm review app.py --receipt --json > review.json
prysm verify review.json
# PASS  code_receipt
#   signature:  b881bdc8…def502
#   bound:      the full response (code + review + proof + models + cost)
```

| Flag     | What it does                                         |
| -------- | ---------------------------------------------------- |
| `--kind` | Force `code` or `trajectory` (default: auto-detect). |
| `--json` | Machine-readable output.                             |

<Note>
  Exits `0` when the artifact verifies, `1` when it doesn't (tampered/altered), `2` on malformed
  input. The recipe is byte-identical across the backend, the Python SDK, and the Node SDK.
</Note>

### `prysm compliance preview`

Dry-run the [Policy-as-Code compliance gate](/concepts/compliance) against a prompt — **no
model is called**. It reports which sensitive data classes the text triggers, which models
the policy allows vs excludes, and the Compliance Cost Premium. Build the policy from flags
(and/or a JSON `--policy-file`; flags override the file).

```bash theme={null}
$ prysm compliance preview "wire payment to DE89370400440532013000" \
    --jurisdiction EU --frameworks GDPR --data-residency EU
classes:  FINANCIAL
status:   OK
allowed:  2 — mistral-nemo, mistral-medium-3
excluded: 17
CCP:      +$0.000000/MTok (0.0%)  [mistral-nemo vs unrestricted mistral-nemo]
attest:   sha256:a1b2c3d4e5f60718
```

Block a data class outright — a leaked secret with `SECRETS` blocked is a hard stop:

```bash theme={null}
$ prysm compliance preview "deploy key AKIAIOSFODNN7EXAMPLE" --block-classes SECRETS
classes:  SECRETS
status:   BLOCKED — no approved model can serve this request
allowed:  0 — (none)
excluded: 19
```

| Flag               | What it does                                                  |
| ------------------ | ------------------------------------------------------------- |
| `--allow`          | Comma-separated provider allowlist (e.g. `anthropic,openai`). |
| `--deny`           | Comma-separated provider denylist.                            |
| `--jurisdiction`   | Allowed jurisdictions (e.g. `US,EU`).                         |
| `--frameworks`     | Required frameworks (e.g. `GDPR,CCPA`).                       |
| `--certifications` | Required certifications (e.g. `SOC2,HIPAA`).                  |
| `--data-residency` | Required data regions (e.g. `EU`).                            |
| `--block-classes`  | Data classes to block: `PII,PHI,FINANCIAL,SECRETS`.           |
| `--zero-retention` | Require a zero-retention provider mode.                       |
| `--policy-file`    | JSON Policy-as-Code spec; inline flags override it.           |

<Note>
  `prysm compliance preview` exits `0` when at least one approved model can serve the
  request and `1` when the policy blocks every model — so it gates CI cleanly.
</Note>

## Exit codes

| Code | Meaning                                                   |
| ---- | --------------------------------------------------------- |
| `0`  | Success (and, for `brain validate`, the config is valid). |
| `1`  | A runtime error, or an invalid BRAIN.md.                  |
| `2`  | A file couldn't be read (e.g. missing BRAIN.md path).     |

Errors print a clean one-line message to stderr — never a stack trace.
