# CLI Commands

Reference for every ferrite CLI command, subcommand, flag, exit code, and environment variable.

This page is the lookup reference for every command, subcommand, and flag the `ferrite` CLI accepts. Run `ferrite <command> --help` for the exact flags on your installed build, and `ferrite --version` for the release and bundled SDK twin. For the local development workflow these commands form, see [Ferrite CLI](/developers/cli/).

Three conventions apply across the CLI. Commands that operate on a project accept `--dir <path>` and default to the current directory. Commands that support `--json` write machine-readable JSON to stdout and keep diagnostics on stderr. Errors outside a check or deploy verdict (such as a missing credential, an unreadable file, or an unknown flag) exit with status `2`.

## Create and compose

### `ferrite new <template> <name>`

Scaffolds a project directory named `<name>` from one of three templates and vendors a local copy of the `ferrite-app` SDK under `vendor/` so `ferrite check` and `ferrite dev` work offline. Project names must start with a letter, use only lowercase letters, digits, `-`, or `_`, and be at most 64 characters.

| Template | What it creates |
| --- | --- |
| `alloy` | A server-rendered web app on the Alloy framework with routing, documents, and form actions, with the framework vendored under `src/alloy/`. Recommended by `ferrite new --help` for anything that serves HTML. |
| `webapp` | A static page on a content route, a counter API that applies each increment once per `idempotency-key`, and a live SSE feed. |
| `hello` | A request/reply API with a single `/api/` route and no content route. |

| Flag | Effect |
| --- | --- |
| `--dir <path>` | Parent directory to create the project in. |
| `--with-tests` | Vendor the test SDK and local runtime as well, and write a sample test under `tests/`. |
| `--target <upstream\|fork>` | Target Core for the generated manifest. `upstream` (the default) writes a manifest without fork-era managed auth, dynamic streaming, or a route rate limit whose enforcement is not established (see [App Manifest](/developers/app-manifest/#routes)). `fork` writes the manifest shape of the archived fork and has no use on Ferrite Core. `FERRITE_TARGET` sets the same value. |

### `ferrite add <package>`

Vendors a source package and every package it depends on into your app's `src/` tree with `@generated by ferrite-pkg` provenance headers, and records the mounts in `ferrite-packages.json`. Deployable apps may declare only `ferrite-app` as a Cargo dependency, so shared code arrives as vendored source.

| Flag | Effect |
| --- | --- |
| `--registry <url>` | Registry index URL to read. Without it, the CLI derives `https://packages.<base>/registry.json` from the configured MCP endpoint and assumes no other default. |
| `--path <dir>` | Install from a local package checkout (a directory holding `packages/registry.json`) instead of a URL. No signature check applies. |
| `--force` | Overwrite existing files that differ from the package copy. Without it, any modified file halts the install, lists the conflicting files, and writes nothing. |
| `--allow-unsigned-registry` | Install from a URL registry whose index cannot be verified because it publishes no signature or has no trusted key. Refused once a key is trusted for the registry, which `https://packages.ferrite.cloud` always has. A signature that fails verification is never accepted. |
| `--dir <path>` | App directory. |

Before installing from a URL, the CLI verifies the index's detached signature (`registry.json.sig`). The Ferrite Cloud registry key is built into the CLI. For any other registry, set `FERRITE_REGISTRY_KEYS` to its public key or pass `--allow-unsigned-registry`; without either, the install is refused and nothing is written. The CLI caches the fetched index and its signature beside the credential file (`registry-cache.json`) and verifies them again on every use, so an offline `add` can still resolve cached packages. The recorded index serial sets a floor that later fetches cannot fall below.

`ferrite add auth` vendors sign-in (the OAuth code flow with PKCE, store-backed sessions, and CSRF protection); see [Authentication](/developers/authentication/).

### `ferrite rsx`

Scaffolds and compiles Rsx applications, turning `app/` directory conventions into a typed route table, generated templates, and a synthesized manifest.

| Command | Flags | Effect |
| --- | --- | --- |
| `ferrite rsx new <name>` | `--dir <path>`, `--with-tests` | Scaffold a new Rsx application. |
| `ferrite rsx sync` | `--dir <path>`, `--json` | Compile `app/` into the generated tree, manifest, source map, and lock file. |
| `ferrite rsx check` | `--dir <path>`, `--json` | Verify that the generated tree still matches its sources. |

## Verify

### `ferrite check`

Runs the admission gate, static manifest checks, and `cargo check` locally. Exits `0` when clean and `1` when any issue is reported. Local verdicts are advisory; the platform gate is the authority.

`ferrite check`, `ferrite test`, and `ferrite dev` compile your app locally and require a Rust toolchain. When `cargo` is missing from `PATH`, they stop with `cargo did not start: Rust is not installed` and print the rustup command (`curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`). `ferrite deploy` needs no local Rust toolchain because the platform runs the checks and builds remotely. Pass `--no-cargo` to run the local gate and manifest checks without Rust.

With `--remote`, a `HOT_SET_UNDERSIZED` warning on a service declared with `hot_set_gib: 0` is advisory and does not block a deploy. Upstream Core's rule reads `0` as a zero-GiB cache, while `0` selects the platform default cache size that small stores should keep. The CLI prints a note stating this.

| Flag | Effect |
| --- | --- |
| `--dir <path>` | App directory. |
| `--remote` | Also send your source to the platform's `code_gate` and your manifest to `validate_spec` (neither is charged), and report both verdicts. Requires a configured endpoint. |
| `--no-cargo` | Skip `cargo check` and run the gate and manifest checks only. |
| `--json` | Print the report as JSON. |
| `--target <upstream\|fork>` | Check the project against a stated Core. With `upstream`, the report lists every manifest key upstream refuses (with what to use instead), every SDK symbol the app uses that upstream `ferrite-app` lacks, and the projection `ferrite deploy` would submit. Without this flag, `--remote` infers the target from the platform's tool list and an offline check makes no claim about it. `FERRITE_TARGET` sets the same value. |
| `--drop-auth` | Judge the projection as `ferrite deploy --drop-auth` would submit it. |
| `--drop-stream-mode` | Judge the projection as `ferrite deploy --drop-stream-mode` would submit it. |

### `ferrite validate`

Checks manifest statics only, without compiling.

| Flag | Effect |
| --- | --- |
| `--spec <path>` | Manifest path (default `./ferrite.json`). |
| `--json` | Print the report as JSON. |

### `ferrite explain <code>`

Prints the cause and canonical fix for a gate or manifest code (such as `CODE_AMBIENT_AUTHORITY`) from the catalogue built into the CLI. A code missing from the local catalogue exits `1` and points to the platform's `explain_gate` tool.

### `ferrite twin`

Reports the vendored SDK twin carried by the CLI and compares it against the twin recorded in the project's `ferrite-twin.json`. A mismatch produces a warning because the twin affects only the local development loop. Flags: `--dir <path>`, `--json`.

## Run locally

### `ferrite dev`

Runs your app against local Store, Queue, Stream, Transaction, and Object Storage planes behind a gateway on `127.0.0.1`. It rebuilds and restarts on source changes, syncs content directories without rebuilding, and persists plane state in `.ferrite/state` across restarts. Only one session can run per project directory; a second `ferrite dev` in the same directory is refused.

| Flag | Effect |
| --- | --- |
| `--dir <path>` | App directory. |
| `--port <port>` | Gateway port. Without it, the gateway binds `8787` or the next free port and prints which port it chose. A port passed here or set as `[dev] port` in `ferrite.local.toml` is used as given and fails if already bound. The bound port is recorded in `.ferrite/dev.json`. |
| `--egress <deny\|allow>` | `deny` (the default) blocks outbound HTTP; `allow` permits requests to destinations declared in the manifest and no others. Overrides `[dev] egress` in `ferrite.local.toml`. |
| `--fresh` | Discard `.ferrite/state` before starting. |
| `--clock-ms <epoch-ms>` | Start the local plane clock at this timestamp; advance it deterministically through `/__forge/clock`. |
| `--no-reload` | Do not inject the live-reload snippet into HTML content. |
| `--chaos <secs>` | Kill the app with `SIGKILL` roughly every `secs` seconds to exercise lease redelivery (`0` by default turns it off; maximum `3600`). |
| `--instances <n>` | Run `n` app processes (1 to 32) against one shared set of planes as competing consumers. |
| `--dev-loopback-egress-port <PORT>` | Permit app egress to reach a local process bound to `127.0.0.1` or `[::1]` on this port, such as a local AI gateway. Repeat the flag for additional ports. The destination must still appear in `ferrite.json` and `--egress` must be `allow`. Has no `ferrite.local.toml` equivalent; `ferrite check`, `ferrite deploy`, and the platform still refuse loopback destinations. |
| `--json` | Emit one JSON object per lifecycle event (`starting`, `dev_started`, `build_started`, `build_ok`, `build_failed`, `app_started`, `app_exited`, `content_synced`, `spec_reloaded`, `chaos_kill`, `app_log`, `managed_auth_not_enforced` when the manifest declares an `auth` block that the local gateway does not enforce, `ready` once the app answers a request, and `shutdown`) instead of human output. |

### `ferrite test`

Runs `cargo test` locally and prints a one-line tally across all test targets. The exit status matches cargo's, except that a local run in which none of the app's own tests executed exits `1`: tests inside packages vendored by `ferrite add` and `#[ignore]`d tests do not count.

| Flag | Effect |
| --- | --- |
| `--dir <path>` | App directory. |
| `--remote` | Commit source to the app's hosted repository with `rcs_commit`, start the platform's test build with `test_ref`, and poll `build_status` for `tested` or `test_failed`. |
| `--allow-no-tests` | Accept a local run in which none of the app's own tests ran. |

## Account

### `ferrite login`

Writes an endpoint and credential to `~/.config/ferrite/credentials.toml` (owner-only, mode `0600`), or to the path set in `FERRITE_CONFIG`.

| Flag | Effect |
| --- | --- |
| `--endpoint <url>` | MCP endpoint URL, such as `https://mcp.ferrite.cloud/mcp`. Changing it replaces the stored login. |
| `--credentials-file <path>` | Import endpoint, account, and token from an owner-only (mode `0600`) TOML file so the token never appears on the command line. |
| `--credentials-stdin` | Import the same TOML document from stdin. |
| `--sign-in` | Sign in through the browser to an account you already own: continue with Google or GitHub, pick the account and click **Allow**. The CLI saves a named login for this computer (`Ferrite CLI on <host>`), which the Dashboard lists and can revoke on its own, and prints the account. Without a browser it prints the address to open. It signs in to Ferrite Cloud (`https://mcp.ferrite.cloud/mcp`) unless `--endpoint`, `FERRITE_ENDPOINT` or the stored login names another installation. A computer whose stored login still works for another account keeps it: the CLI asks at a terminal, and otherwise exits with `LOGIN_SIGN_IN_REPLACE_REQUIRED`. |
| `--replace` | With `--sign-in`: replace a working stored login without asking. The old login is kept as a backup file. |
| `--id <account>` | Provision a durable account with this ID via the platform's `provision` tool. |
| `--ephemeral` | Provision a trial account via `provision_ephemeral`. A trial account lasts 48 hours, starts with $5 of credit, enough to run an app or a few, and runs one instance per application with 256 MiB of memory and half a CPU. Login queries the platform's tool list first and states how deployment works from that account on that platform. It then hands the trial to the installation's Dashboard, so that when the person keeps it or moves it into their account there, this computer's login follows (see [`ferrite claim`](#ferrite-claim)). The JSON reply says `trialAdopted: true`; a Dashboard that cannot be found or refuses gives `trialAdopted: false` and a `warning`, and the login itself still succeeds. On Ferrite Cloud the output ends with one line naming the [Terms of Service](https://ferrite.cloud/terms) and [Privacy Policy](https://ferrite.cloud/privacy) that apply to the trial (`terms` in the JSON), and `ferrite claim --link` adds the same line under the claim link. |
| `--json` | Print metadata only; the bearer token is never printed. |

### `ferrite account`

Inspects the account selected by your stored credential. Before you sign in, it exits `0` and prints `account: not logged in`, or under `--json` prints an object whose `kind` is `AccountUnconfigured`. An unusable stored login exits `2`, or `3` with `--json`. For a canonical HTTPS login created with `ferrite login --id`, `--ephemeral`, or `--credentials-file`, `ferrite account --json` exits `0` and reports `accountId`, `endpoint`, `campaignReady: true`, `accountIdentity`, and `accountIdentitySha256`. For non-campaign logins such as plain-HTTP or loopback endpoints, it still exits `0` and reports `campaignReady: false` with `campaignCode: CAMPAIGN_CREDENTIAL_PROFILE_REQUIRED`. Those fields describe the credential profile and are not an error. On a trial account (an id starting with `eph-`) the JSON also carries `trial: true` and a `next` array holding `ferrite claim --link`, and the plain form adds a `trial:` line, because a trial is kept through its claim link rather than by creating a second account. Before you sign in, the `next` array lists `ferrite login --endpoint <url> --ephemeral`, `ferrite login --sign-in` (an account you already have, through the browser), `ferrite login --credentials-file <path>` and `ferrite login --endpoint <url> --id <account>`.

When the platform rejects the stored credential with HTTP 401 `invalid_token`, that login is unknown to the installation. `ferrite account --json` exits `3` with `code` set to `ACCOUNT_SELECTION_UNAVAILABLE`, `reason` set to `LOGIN_UNKNOWN_TO_PLATFORM`, `credentialKept: true`, and a `next` array holding `ferrite login --endpoint <endpoint> --ephemeral --json` (provision a fresh trial account) and `ferrite login --credentials-file <file>` (import a Dashboard API token). Every other command that receives the same 401 response prints the same guidance. The CLI never deletes your stored credential. Running `ferrite login --ephemeral` or `ferrite login --credentials-file` replaces it, sends the provisioning call without the refused bearer token, and keeps the previous file beside the new one as `credentials.toml.replaced-<seconds>` (mode `0600`; the JSON reply names it in `previousLoginBackup`). `ferrite mcp-serve` returns the same `code` and `next` fields on its `remote_*` tools.

When the refused login is a trial's (its account id starts with `eph-`), the trial may have been kept or moved into another account on the Dashboard, which ends the trial login. The CLI then asks the Dashboard once where it went. If it was kept or moved, the Dashboard issues this computer a login for the new account, which the CLI verifies and saves the way `--credentials-file` does (the trial login is kept as `credentials.toml.replaced-<seconds>`). `ferrite account` then answers for the new account and adds a `trialFollow` object with `trialAccountId`, `state` (`kept` or `moved`), `accountId` and `switched: true`; any other command prints the account it now uses and asks you to run it again; `ferrite mcp-serve` answers the refused call with `code: TRIAL_LOGIN_FOLLOWED` and `accountId`, and its next call uses the new login. That login is issued once: when another computer took it, `trialFollow` has `switched: false` and `next` is `ferrite login --sign-in`. A trial that expired is reported with `state: ended`.

### `ferrite cost`

Reads your project's `ferrite.json`, applies the standard upstream projection, and asks the platform for an estimate using your stored account credential. `ferrite cost` (MCP: `estimate_cost`) reports your account balance, the deploy fee, each application's projected monthly cost at current rates, each application's hourly compute cost, and any validation violations. It charges nothing and deploys nothing. Monthly figures are projections from current rates and the requested footprint; actual metered usage can differ.

An estimate does not cap spending. Your real ceilings are your prepaid balance and any spending limit set in the [Dashboard](/developers/dashboard/#read-credit-and-usage). When a durable account's balance reaches zero, its applications stop, remain retained for 30 days, and are then deleted permanently with their data. A trial account's applications suspend when its credit runs out; to buy more, sign in through the trial's claim link to keep the account. See [Understand usage and credits](/kb/guide/usage-and-credits/) for the low-balance warnings the platform records and [Before you deploy: what it will cost](/developers/deployments/#before-you-deploy-what-it-will-cost) for when to read and how to use an estimate.

| Flag | Effect |
| --- | --- |
| `--dir <path>` | Project directory containing `ferrite.json`. |
| `--instances <count>` | Number of application instances to estimate; defaults to `1` and must be positive. |
| `--json` | Print the complete platform estimate, including `spec_valid`, notes, and violations. |

An invalid specification exits `2`; check the verdict before treating an estimate as valid. `ferrite cost` enforces the same projection holds as `ferrite deploy`: a manifest carrying an application `auth` block, a route `stream_mode`, or `rate_limit_per_min` on an endpoint not qualified for route budgets is refused with `cost estimate held` and the reason for each hold. See [`ferrite deploy`](#ferrite-deploy) for how to handle a held `rate_limit_per_min`.

### `ferrite statement`

Reads your authenticated account's balance, total charges, funding, and recent billing entries explaining how the balance reached its current value. A trial account starts with $5 of credit and lasts 48 hours, after which its applications go offline unless someone signs in to keep it. Before then, open the link [`ferrite claim --link`](#ferrite-claim) prints to keep the trial as your own account or move its applications into one you already own; after signing in you can buy more credit in the Dashboard. Pass `--json` for the complete platform statement. This command reads billing records and makes no payment.

### `ferrite claim`

Keeps a trial's work past its 48 hours. For a person, the way is `ferrite claim --link` (below): it prints the trial's private link, where they keep the trial as their own account or move it into one they already own. Without `--link`, the command moves a trial account's applications into a durable account before the trial ends, then prints the private link to take ownership of that durable account in the Dashboard; use it where no person can open a link. Run it from the profile that created the trial. Two distinct operations share the name claim: the transfer moves your applications into a durable account so they survive past 48 hours, and the link assigns human ownership of an account in the Dashboard. Taking Dashboard ownership of a trial account does not extend its 48-hour clock, so applications remain only if transferred before the trial expires.

Without `--into`, the CLI creates a new durable account and transfers the trial's applications into it. With `--into`, it transfers them into the durable account in the credential file you pass; a trial account is refused as a destination. Either way, the CLI saves the durable account as your active login and prints its claim link if no human owns it yet. If the destination has no credit and there are applications to move, nothing transfers: fund that account and run the same command again from the same profile. The CLI keeps a private record of the handoff. If a run is interrupted, keep both credential files and re-run the same command; the rerun checks the first transfer and never submits a second one.

Run from a durable account's profile, `ferrite claim` moves nothing. If no human owns the account yet, it requests a `claim_url` and prints the private Dashboard claim link.

`ferrite claim --link` transfers nothing and prints the account's private, single-use claim link. On a trial, the person opens it, signs in with Google or GitHub, and chooses **Keep this as my account**, which moves the trial's apps, URLs and data into a new durable account of their own, or **Move it into** an account they already own. Either way the trial's account id changes and its login ends.

`ferrite claim --link --wait` prints the same link and then waits, asking the Dashboard every three seconds, for up to 10 minutes. When the person keeps or moves the trial, the CLI saves a login for the account it went to (verified as `--credentials-file` verifies one, the trial login kept as a backup file) and prints that account; it exits `0`. It exits `3` when the wait ends with the trial unchanged (the link stays valid; run the command again), and `2` when the trial ended or its new login was already issued elsewhere (then `ferrite login --sign-in`). With `--json` it prints two JSON lines: the claim link's, then one with `status` (`kept`, `moved`, `ended` or `waiting`), `trialAccountId`, `accountId`, `switched` and `previousLoginBackup`. Before printing the link it hands the trial to the Dashboard again, for a trial whose adoption at `ferrite login --ephemeral` did not succeed.

| Flag | Effect |
| --- | --- |
| `--link` | Print the account's claim link and transfer nothing. Cannot be combined with `--into`. |
| `--wait` | With `--link` on a trial: wait for the person to keep or move it, then switch this computer's login to the account it went to. |
| `--into <path>` | Owner-only credential file of an existing durable account on the same installation to receive the applications. |
| `--dashboard-origin <origin>` | Dashboard origin for a custom or loopback endpoint; inferred from `mcp.<domain>` on Ferrite Cloud, or taken from `FERRITE_DASHBOARD_URL`. |
| `--json` | Print the verified account, application IDs, and claim link as JSON. |

Share the claim link privately with the intended owner only, and keep credential files out of support logs. After the transfer, retain the fully qualified application ID from the result for later updates, because a short name can resolve to a different app under the destination account, and open the original URL to confirm your data survived. A client without this CLI command can follow the [hosted MCP procedure](/developers/mcp-only-operations/#keep-a-trial-app-past-its-48-hours).

Durable accounts have no 48-hour limit.

## Deploy

### `ferrite deploy`

Submits your project to the configured endpoint and follows the build until the application is running. The CLI reads the endpoint's `tools/list` first; on Ferrite Core, recognized by `deploy_source` together with `build_status`, it projects `ferrite.json` and `Cargo.toml` for upstream, submits once via `deploy_source`, follows `build_status`, and polls `status` until running instances reach the desired count on the new generation. Each attempt is recorded in `.ferrite/deployments/`. Exit status is `0` when ready, `1` when the attempt ends in a verdict, and `3` when the outcome is unknown and must be reconciled with `ferrite deploy resume`. See [Deployments](/developers/deployments/) for the projection and journal details.

A completed deploy is charged the installation's deploy fee, which `ferrite cost` reports beforehand alongside the projected monthly cost. Refusals, failed builds, and unchanged projects that submit nothing are not charged. Every charge draws from your prepaid balance; if the balance cannot cover the fee, the deploy is refused with `INSUFFICIENT_CREDIT`.

| Flag | Effect |
| --- | --- |
| `--dir <path>` | App directory. Also accepted by the subcommands. |
| `--instances <n>` | Desired instance count. |
| `--detach` | Return once the submission has been sent without following the build. |
| `--skip-remote-gate` | Submit without first calling `code_gate` and `validate_spec`. The attested build still produces the verdict. |
| `--force` | Build and deploy even when nothing changed since the ready attempt currently served. Without it, an unchanged project submits nothing and is not charged. A secret changed with `ferrite secrets` since the last deploy already counts as a change; `--force` is needed only when a secret changed another way, such as the MCP `set_secret` tool. |
| `--target <upstream\|fork>` | Target Core for the deploy. Defaults to `FERRITE_TARGET`, otherwise inferred from the platform's tool list. |
| `--drop-auth` | Allow the upstream projection to remove an application `auth` block, publishing the app without that sign-in gate. |
| `--drop-stream-mode` | Allow the upstream projection to remove a route's `stream_mode`, so the route answers as a plain API route. |
| `--allow-missing-secrets` | Submit even when the platform is missing secrets declared in `ferrite.json` `required_secrets` (`DEPLOY_REQUIRED_SECRETS_MISSING`) or secrets read by the `auth` package (`DEPLOY_AUTH_SECRETS_MISSING`). Without this flag, the deploy is refused before submission with the commands to set each missing secret; sign-in answers `503` until those secrets are set and the app is redeployed. |
| `--json` | Print exactly one JSON result to stdout. Also accepted by the subcommands. |

Without `--drop-auth` or `--drop-stream-mode`, a manifest carrying those keys is refused before submission because stripping them changes caller-facing behavior.

Enforcement of `rate_limit_per_min` is not established on Ferrite Cloud, so `ferrite deploy` and `ferrite cost` hold any manifest that declares the key and explain why. Keep the key if you declared it, and do not submit through raw `deploy_source` to bypass the hold. See [Rate limits](/developers/rate-limits/) for details on the hold and how to bound a route with the `http-route-budget` package. No flag overrides this hold.

| Subcommand | Effect |
| --- | --- |
| `ferrite deploy status --attempt <id>` | Read one bounded status observation for a journaled attempt. |
| `ferrite deploy wait --attempt <id>` | Wait for that attempt to become ready or reach a terminal state. |
| `ferrite deploy resume [--attempt <id>]` | Reconcile an interrupted attempt by reading only; never submits source again. An attempt journaled locally but never sent is submitted for the first time, and `resume` refuses it if project files changed since. Without `--attempt`, selects the latest unfinished attempt in the project. |

### `ferrite preview`

Commits your project's current source and deploys it to its own temporary host. A preview passes the same build and admission checks as a deploy, is not held for a test verdict, is not charged, and is not a release. The platform removes previews two hours after creation.

The CLI commits with `rcs_commit` and starts the preview with `preview_ref`. The platform answers `BuildStarted` with a `build_id` immediately; the CLI prints it and exits. Follow that `build_id` with `build_status` until it returns `PreviewDeployed`, which includes the preview's `host` and `preview_app`. Flag: `--dir <path>`.

### `ferrite fork <copy>`

Copies a deployed app, including its code and all of its data, into a new app named `<copy>` at its own host through the platform's `fork` tool. The copy is cut at one instant and stays isolated from the original. The CLI follows `build_status` until the copy deploys (for up to two minutes, after which it prints the build ID and exits `3`), waits briefly for an instance to start, and prints the copy's host. `<copy>` follows the `ferrite new` naming rule and cannot match an existing deployed app. To change the copy's code without losing its data, deploy a working copy whose `ferrite.json` names `<copy>`.

| Flag | Effect |
| --- | --- |
| `--app <app>` | Source app to copy, using the same naming rules as `ferrite status`. Defaults to the app in `./ferrite.json`. |
| `--as-of <TIME>` | Copy the app as it existed at this instant within the platform retention window (14 days on Ferrite Cloud): an RFC 3339 timestamp with a timezone (such as `YYYY-MM-DDTHH:MM:SSZ`) or Unix microseconds. |
| `--dir <path>` | Project directory whose deploy journal and spec name the app. |
| `--json` | Print one JSON result to stdout. |

## Operate

| Command | Effect |
| --- | --- |
| `ferrite status [app]` | Read the platform's `status` for the app: desired and running instances. |
| `ferrite logs [app]` | Read the platform's `logs` for the app: recent stdout and stderr. |
| `ferrite usage [app]` | Read the platform's `usage` for the app: requests, errors, bytes served, average and peak latency, request charges, and observation window. |
| `ferrite withdraw <app>` | Call the platform's `withdraw`: ends any in-flight deploy on that name, unpublishes its routes, tears the app down, and reads `status` to confirm no deployment remains. |

All four commands accept `--dir <path>`. `app` may be the qualified `app` from a deploy receipt (`<account>/<name>` on Ferrite Core) or the project name, which the CLI resolves through the project's deploy journal or the account's deployments. Without it, `status`, `logs`, and `usage` target the application in `./ferrite.json`; `withdraw` always requires an explicit `<app>`.

`ferrite usage` without an app outside a project directory, or with `--all`, prints one line per application listed on your account. `--json` outputs `{ok, apps: [{app, ok, usage | error}]}`, where `usage` is the raw MCP tool response. It exits `2` when the platform refuses any read. Counts are aggregated from per-response gateway events and lag requests slightly.

`ferrite withdraw` cannot be undone: the app's routes, secrets, and data are removed permanently, and serving it again requires a new `ferrite deploy`. Its hosted source repository and any bound domains stay in place and are managed with the MCP `delete_repository` and domain tools. In an interactive terminal, the CLI asks you to retype the app name (the segment after `/` is enough). Pass `--yes` to confirm without prompting; `--yes` is required when there is no terminal or when using `--json`, which outputs `{ok, app, withdrawn, status_confirms}`. The CLI sends the request once, and because platform `withdraw` is idempotent, re-running after an unknown outcome is safe.

The CLI has no commands for scaling, releases, environments, or rollback. Use Ferrite MCP tools for those operations; see [MCP-only operations](/developers/mcp-only-operations/#operate).

### `ferrite host`

Prints your app's host and origin before its first deploy. Ferrite Core derives the host from the app ID (`<account>/<name>`) and the installation's app domain, resolved in order from the endpoint (`https://mcp.<domain>/mcp`), `FERRITE_APP_DOMAIN`, or a host already assigned to the project or account. For apps that vendor the `auth` package, it also prints the OAuth callback URLs to register with your identity provider. The host is labelled `derived` until the platform confirms it and `confirmed` afterward. Flags: `--app <owner/name or name>` (default: the app in `./ferrite.json`), `--dir <path>`, `--json`.

### `ferrite secrets`

Sets, lists, and deletes a deployed app's secrets through the platform's `set_secret`, `list_secrets`, and `delete_secret` tools. Every subcommand accepts `--app` (resolved like `ferrite status`, defaulting to `./ferrite.json`, and usable before the first deploy), `--dir <path>`, and `--json` (which never prints values).

| Command | Effect |
| --- | --- |
| `ferrite secrets set <name> [--value-file <path>]` | Set one secret. Reads the value from stdin (an interactive terminal prompts without echo) or from `--value-file`, never from command-line arguments, and strips one trailing line ending. Names match `[A-Za-z0-9_.-]` and are at most 64 characters. |
| `ferrite secrets list` | List secret names; values are never returned. |
| `ferrite secrets delete <name>` | Delete one secret. The running app keeps its prior value until the next deploy. |

Secret updates reach running instances on the next `ferrite deploy`, which counts a secret change as a deployable change even when source files are unchanged.

Secrets are write-only and never returned on read. The running application receives their values and can call out only to destinations declared in its manifest. Because application code holds the value in memory, it can still log it, return it in a response, or store it, and nothing binds a specific secret to a specific destination. See [Secrets & Egress](/developers/secrets-egress/#what-this-does-not-stop) for the implications.

### `ferrite domains`

Binds an application to a custom hostname (such as `shop.example.com`) or a free platform name (such as `shop.ferrite.run`). Calls the platform's `claim_domain`, `verify_domain`, `bind_domain`, and `list_domains` tools and prints the DNS records to publish. Every subcommand accepts `--dir <path>` and `--json`.

| Command | Effect |
| --- | --- |
| `ferrite domains add <hostname> [--app <app>]` | Claim the hostname for your account, verify the claim, bind it to the app (default: `./ferrite.json`), and print the required DNS records. Already-completed steps are skipped, so reruns are safe. |
| `ferrite domains check <hostname>` | Read the hostname's records from public DNS, report missing or incorrect records, and request `https://<hostname>/`. Exits `0` when the hostname serves and `1` otherwise. |
| `ferrite domains list` | List the account's domains, whether each is verified, and the app each is bound to. |

`add` saves the claim token in an owner-only file beside your CLI credentials until verification completes, because the platform issues the token once. Free names and hostnames in the installation's own zone require no DNS records; see [Domains](/developers/domains/) for each record type. `check` reads DNS records through Cloudflare's public DNS-over-HTTPS resolver because system resolvers cannot query CNAME and TXT records.

### `ferrite tasks`

Runs a hosted MCP tool as an MCP Task with an account-bound receipt so long-running calls can be polled and recovered without resubmitting. Each receipt is an owner-only file bound to your login's endpoint and account. See [MCP Tasks](/developers/mcp-tasks/) for the protocol details.

| Command | Effect |
| --- | --- |
| `ferrite tasks call <tool> --arguments <file> --receipt <file> [--allow-form-input]` | Send the tool call once with arguments read from a JSON object file. The receipt path must not already exist; it is reserved before submission so re-running the command cannot submit twice. `--allow-form-input` lets the task request form answers via `tasks input`. |
| `ferrite tasks get <receipt>` | Read the task's current status and result when available. |
| `ferrite tasks wait <receipt> [--timeout-seconds <n>]` | Poll until the task finishes or asks for input, for up to `n` seconds (default `420`). Stopping the command leaves the task running. |
| `ferrite tasks input <receipt> --responses <file>` | Answer pending task requests with a JSON object of results. |
| `ferrite tasks cancel <receipt>` | Request cancellation; inspect the outcome with `get` or `wait`. |

## Hosted source: `ferrite rcs`

`ferrite rcs` keeps a local working tree synchronized with an app's hosted repository using Git's subcommand names. Every subcommand accepts `--dir <path>` and `--json`, whose output carries stable `op`, `kind`, and `ok` keys.

| Command | Flags | Effect |
| --- | --- | --- |
| `ferrite rcs clone <app> [target]` | `--reference <ref>`, `--force` | Materialize a hosted revision (`main` head by default) into a new directory. `--force` writes into a non-empty directory. |
| `ferrite rcs pull` | `--reference <ref>`, `--force` | Re-materialize the working tree at the tracked branch's head. `--force` discards local changes and pending commits. |
| `ferrite rcs checkout <ref>` | `--force` | Re-materialize the working tree at a branch or commit. `--force` discards local changes and pending commits. |
| `ferrite rcs status` | | Show local modifications and commits waiting to be pushed. |
| `ferrite rcs commit` | `-m, --message <text>` (required), `--branch <name>`, `--allow-unsupported` | Record changes as a local pending commit. `--allow-unsupported` commits text files and lists binary files, symlinks, and special files that hosted source cannot carry. |
| `ferrite rcs push` | `--allow-orphans` | Push pending commits in order. Commits that delete files are refused unless you pass `--allow-orphans`, because `rcs_commit` cannot delete files; removed files remain hosted. |
| `ferrite rcs log` | `--limit <n>`, `--branch <name>` | Read hosted commit history. |
| `ferrite rcs branch <name>` | `--from <ref>` | Create a hosted branch (from the `main` head by default). |
| `ferrite rcs branches` | | List hosted branches and their tips. |
| `ferrite rcs merge` | `--from <branch>` (required), `--into <branch>` (default `main`) | Run a three-way merge on the platform. Conflicts make no commit. |
| `ferrite rcs land` | `--from <branch>` (required), `--into <branch>` (default `main`) | Land a branch onto a protected trunk through the merge-result gate. |
| `ferrite rcs remote` | | Print the app's Git remote URL (`https://git.<base>/<app>.git`, derived from the endpoint) and its fidelity limits. |

A Rust checkout includes the CLI's packaged public SDK under `vendor/` and binds the app's SDK dependencies to that directory so `ferrite check`, `ferrite test`, and `ferrite dev` work without another repository. The hosted revision remains the source baseline; this local SDK adaptation does not show up as an edit in `ferrite rcs status`. `pull` and `checkout` apply the same adaptation.

Remote checks and tests also include UTF-8 files named by literal `include_str!` references inside your application, so referenced frontend text is uploaded without the rest of the frontend dependency tree. References outside the application directory, local configuration files, and build directories are refused.

## Agents: `ferrite mcp-serve`

`ferrite mcp-serve` exposes the local development loop as an MCP server over stdio so an MCP client can scaffold, check, run, and test over one connection. `--dir <path>` sets the default directory its tools operate on. The `local_*` and `rsx_*` tools run on your machine and are advisory; the `remote_*` tools call the platform, whose verdicts are authoritative.

| Tool | Effect |
| --- | --- |
| `local_new` | Scaffold from the `alloy`, `webapp`, or `hello` template for upstream. |
| `local_add` | Run `ferrite add` for a package and return its integration steps. |
| `local_check` | Run the admission gate, manifest checks, and `cargo check`. |
| `local_validate` | Check manifest statics. |
| `local_explain` | Explain a `CODE_*` or `APP_*` code. |
| `local_test` | Run `cargo test`. |
| `local_dev_start`, `local_dev_status`, `local_dev_stop` | Start, inspect, and stop a `ferrite dev` process. |
| `local_clock_advance` | Advance the running dev clock by a number of milliseconds. |
| `local_state_dump` | Show the served app, its plane groups, and the local clock. |
| `local_notifications` | List notifications emitted by the app during this dev session. |
| `rsx_routes`, `rsx_sync`, `rsx_check`, `rsx_explain`, `rsx_render` | Read the Rsx route table, compile `app/`, check for drift, explain an `RSX_*` code, and render one route through the running dev server. |
| `remote_account` | Read the authenticated account and its credit. |
| `remote_estimate_cost` | Estimate deployment and monthly running cost from an InfraSpec JSON string without deploying; inspect `spec_valid` and violations. |
| `remote_account_statement` | Read account balance, funding, charges, and recent billing entries. |
| `remote_test_ref` | Commit source and start `test_ref`; returns a `build_id`. |
| `remote_preview` | Commit source and start a preview with `preview_ref`; returns `BuildStarted` to follow with `remote_build_status`. |
| `remote_fork` | Copy a deployed app with its data into a new app (`fork_app`, with optional `app`, `as_of`, and `dir`), matching `ferrite fork`; returns a `build_id` to follow with `remote_build_status`. |
| `remote_build_status` | Poll a build to its verdict. |
| `remote_status`, `remote_logs` | Read a deployed app's instances or recent output. |
| `remote_list_apps`, `remote_describe`, `remote_usage` | List your account's apps with their hosts, describe one app, or read its request and error counts, latency, and spend. |
| `remote_releases`, `remote_deploy_history` | List an app's releases, or read one environment's deploy history (`env` is required). |
| `remote_owner_status`, `remote_claim_url`, `remote_list_domains` | Check whether a human owner has claimed the account, mint the single-use claim URL to share privately, or list the account's custom domains. |
| `remote_rollback`, `remote_rollback_release`, `remote_scale`, `remote_withdraw` | Change a live app: roll back to the previous artifact or to a named release, set its instance count, or withdraw it. Each requires `confirm: true`, passed only after user approval; without it nothing is sent. |
| `remote_secret_set`, `remote_secret_list` | Set one secret on the deployed app or list its secret names. Values are never returned and take effect on the next `ferrite deploy`. |
| `remote_deploy` | Always refuses. Deployment requires the CLI's local deploy journal, so run `ferrite deploy` in the project directory. |

## Retired and fork-only commands

`ferrite auth` accepts any arguments, prints that sign-in is now provided by the `auth` package (`ferrite add auth`, then `src/auth/SETUP.md`), and exits `2`.

`ferrite agent connect` and `ferrite agent recover` attached the CLI to an existing Dashboard account via browser approval on the archived fork. Ferrite Core serves neither tool: `connect` exits `2` with `AGENT_SETUP_UNSUPPORTED_PLATFORM` and saves nothing, and `recover` exits `2` with `AGENT_SETUP_TRANSACTION_MISSING` unless a stored login still works. On Ferrite Core, an agent creates its own account with `ferrite login --ephemeral` or `ferrite login --id <account>`, and its owner claims it using the link returned by `ferrite claim` or the MCP `claim_url` tool; see [Claim an account your agent created](/kb/guide/claim-an-agent-created-account/). To use an existing account from another machine, run `ferrite login --sign-in`; see [Connect any agent to your Ferrite account](/developers/connect-any-agent/).

| Command | Flags |
| --- | --- |
| `ferrite agent connect` | `--account <id>`, `--endpoint <url>`, `--dashboard <https-origin>`, and `--client <name>` (all required); `--restart` to discard an expired or mismatched pending request; `--replace` to let the new credential replace a stored login for a different account or endpoint; `--json`. |
| `ferrite agent recover` | `--json`. Exits `3` while approval is pending and `4` when the request expired or was revoked. |

## Environment variables

| Variable | Effect |
| --- | --- |
| `FERRITE_CONFIG` | Path to the credential document and all CLI state stored beside it. |
| `FERRITE_ENDPOINT` | Override the stored endpoint. A stored login issued by a different endpoint is ignored. `ferrite account`, `deploy`, `cost`, `statement`, `claim`, and `tasks` read only the credential file and ignore `FERRITE_ENDPOINT` and `FERRITE_TOKEN`. |
| `FERRITE_TOKEN` | Bearer token, used only when `FERRITE_ENDPOINT` is exported beside it. |
| `FERRITE_DASHBOARD_URL` | Dashboard origin for a custom or loopback installation, used by `login --sign-in`, `login --ephemeral`, `claim` and the trial follow when no `--dashboard-origin` is given. It must be `https://dashboard.<domain>` for an endpoint `https://mcp.<domain>/mcp`, or loopback beside a loopback endpoint. |
| `FERRITE_TARGET` | Target Core for `new`, `check`, and `deploy` when `--target` is omitted: `upstream` or `fork`. |
| `FERRITE_APP_DOMAIN` | Base domain apps are served under, used by `ferrite host` when the endpoint does not name it (such as a local fleet). |
| `FERRITE_REGISTRY_KEYS` | Registry public keys `ferrite add` trusts across all registries, formatted as `ed25519:<base64>[,ed25519:<base64>...]`. |
| `FERRITE_PREVIEW_TOKEN` | Sent as the `X-Ferrite-Preview` header on unauthenticated requests to installations whose edge enforces an operator allowlist gate. Ferrite Cloud has no such gate, so you do not need it there. |
| `FERRITE_EXTRA_CA_FILE` | PEM bundle of extra trust roots appended to built-in roots for every HTTPS request, for a local fleet with its own CA. Refused for production endpoints unless `FERRITE_EXTRA_CA_PRODUCTION=1`; `FERRITE_PRODUCTION_BASE_DOMAIN` adds a base domain treated as production. |
| `FERRITE_DEPLOY_NO_AUTO_CLAIM` | Set to `1` to refuse rather than claim a trial account on platforms running the archived fork's durable source lifecycle. Has no effect on Ferrite Core, where the CLI never claims automatically. |

Continue with [Ferrite CLI](/developers/cli/) for the local development loop or [Deployments](/developers/deployments/) for what a deploy submits and how to reconcile one.
