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

# secrets

# `fased secrets`

Use `fased secrets` to migrate credentials out of plaintext config, apply
SecretRefs safely, and keep the active secrets runtime healthy.

Command roles:

* `reload`: gateway RPC (`secrets.reload`) that re-resolves refs and swaps the
  runtime snapshot only on full success. It does not write config.
* `audit`: read-only scan of config, auth stores, and legacy residues (`.env`,
  `auth.json`) for plaintext, unresolved refs, and precedence drift.
* `configure`: interactive planner for provider setup + target mapping + preflight (TTY required).
* `apply`: execute a saved plan (`--dry-run` for validation only), then scrub migrated plaintext residues.

Recommended operator loop:

```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
fased secrets audit --check
fased secrets configure
fased secrets apply --from /tmp/fased-secrets-plan.json --dry-run
fased secrets apply --from /tmp/fased-secrets-plan.json
fased secrets audit --check
fased secrets reload
```

Exit code note for CI/gates:

* `audit --check` returns `1` on findings, `2` when refs are unresolved.

Related:

* Secrets guide: [Secrets Management](/gateway/secrets)
* Security guide: [Security](/gateway/security)

## Reload runtime snapshot

Re-resolve secret refs and atomically swap runtime snapshot.

```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
fased secrets reload
fased secrets reload --json
```

Notes:

* Uses gateway RPC method `secrets.reload`.
* If resolution fails, gateway keeps last-known-good snapshot and returns an error (no partial activation).
* JSON response includes `warningCount`.

## Audit

Scan Fased state for:

* plaintext secret storage
* unresolved refs
* precedence drift (`auth-profiles` shadowing config refs)
* legacy residues (`auth.json`, OAuth out-of-scope notes)

```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
fased secrets audit
fased secrets audit --check
fased secrets audit --json
```

Exit behavior:

* `--check` exits non-zero on findings.
* unresolved refs exit with a higher-priority non-zero code.

Report shape highlights:

* `status`: `clean | findings | unresolved`
* `summary`: `plaintextCount`, `unresolvedRefCount`, `shadowedRefCount`, `legacyResidueCount`
* finding codes:
  * `PLAINTEXT_FOUND`
  * `REF_UNRESOLVED`
  * `REF_SHADOWED`
  * `LEGACY_RESIDUE`

## Configure (interactive helper)

Build provider + SecretRef changes interactively, run preflight, and optionally apply:

```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
fased secrets configure
fased secrets configure --plan-out /tmp/fased-secrets-plan.json
fased secrets configure --apply --yes
fased secrets configure --providers-only
fased secrets configure --skip-provider-setup
fased secrets configure --json
```

Flow:

* Provider setup first (`add/edit/remove` for `secrets.providers` aliases).
* Credential mapping second (select fields and assign `{source, provider, id}` refs).
* Preflight and optional apply last.

Flags:

* `--providers-only`: configure `secrets.providers` only, skip credential mapping.
* `--skip-provider-setup`: skip provider setup and map credentials to existing providers.

Notes:

* Requires an interactive TTY.
* You cannot combine `--providers-only` with `--skip-provider-setup`.
* `configure` targets secret-bearing fields in `fased.json`.
* Include all secret-bearing fields you intend to migrate, for example both
  `models.providers.*.apiKey` and `skills.entries.*.apiKey`, so audit can reach
  a clean state.
* It performs preflight resolution before apply.
* Generated plans default to scrub options (`scrubEnv`, `scrubAuthProfilesForProviderTargets`, `scrubLegacyAuthJson` all enabled).
* Apply path is one-way for migrated plaintext values.
* Without `--apply`, CLI still prompts `Apply this plan now?` after preflight.
* With `--apply` (and no `--yes`), CLI prompts an extra irreversible-migration confirmation.

Exec provider safety note:

* Homebrew installs often expose symlinked binaries under `/opt/homebrew/bin/*`.
* Set `allowSymlinkCommand: true` only when needed for trusted package-manager
  paths, and pair it with `trustedDirs` such as `["/opt/homebrew"]`.

## Apply a saved plan

Apply or preflight a plan generated previously:

```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
fased secrets apply --from /tmp/fased-secrets-plan.json
fased secrets apply --from /tmp/fased-secrets-plan.json --dry-run
fased secrets apply --from /tmp/fased-secrets-plan.json --json
```

Plan contract details (allowed target paths, validation rules, and failure semantics):

* [Secrets Apply Plan Contract](/gateway/secrets-plan-contract)

What `apply` may update:

* `fased.json` (SecretRef targets + provider upserts/deletes)
* `auth-profiles.json` (provider-target scrubbing)
* legacy `auth.json` residues
* `~/.fased/.env` known secret keys whose values were migrated

## Why no rollback backups

`secrets apply` intentionally does not write rollback backups containing old plaintext values.

Safety comes from strict preflight + atomic-ish apply with best-effort in-memory restore on failure.

## Example

```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
# Audit first, then configure, then confirm clean:
fased secrets audit --check
fased secrets configure
fased secrets audit --check
```

If `audit --check` still reports plaintext findings after a partial migration,
verify you also migrated skill keys (`skills.entries.*.apiKey`) and any other
reported target paths.
