# CLI reference
Source: https://shld.app/docs/cli · Updated 2026-11-30 · Synced from shld cb495f9f

> Look up every shld command, its purpose, important flags, JSON behavior, and command-specific exit codes.


Use this reference to inspect, run, connect, and maintain shld. Commands and flags below come from `cmd/shld` on main; run `shld <command> --help` for the binary's own option list.

## Output and errors

`shld`, `shld help`, and `shld --help` print top-level help. Unknown commands and most runtime or configuration errors exit 1 with `shld: <error>` on stderr. Command-specific exits appear below.

`--json` is available for `scan`, `run`, `status`, `doctor`, `coverage accept`, `logins`, `auth`, `update`, and `root`. `feed`, `verify`, and `canary` emit JSON without a `--json` option. Interactive `scan` and `run` use text, while pipes and files default to JSON. `run --tui` opens the local terminal dashboard and cannot combine with `--json`.

Grouped terminal screens use color and Unicode only on a terminal. Set `NO_COLOR` to any nonempty value, or set `TERM=dumb`, to get ASCII marks without color. JSON output does not change.

## Collect and inspect

| Command | Purpose and key flags | Exit behavior |
| --- | --- | --- |
| `shld scan` | Collect once and write a report. Uses the shared collection flags below. | Findings do not cause failure; configuration and I/O errors exit 1. |
| `shld run` | Start configured notification export and the local API before the first collection cycle, then poll until SIGINT or SIGTERM. `--tui` selects the terminal dashboard. | Runtime errors exit 1; a termination signal ends the loop normally. |
| `shld status` | Read service, last scan, coverage, limitations, and notification state. `--json`, `--state`, `--listen`, `--api-socket`. | Local API unavailability appears in output and does not itself cause a nonzero exit. |
| `sudo shld doctor` | Run read-only health checks. `--json`, `--state`, `--listen`, `--api-socket`. | 0 pass or skip, 1 warning, 2 failure, 3 invalid use. |
| `sudo shld doctor --fix --dry-run` | Print proposed fixes without changing anything. Add `--json` for a machine plan. | `--fix` alone, `--fix --yes`, and `--undo` exit 3. |
| `shld logins` | Replay SSH history without changing live state. `--state`, `--json`. | Errors exit 1. |
| `sudo shld coverage accept --all` | Accept every newly unreadable path from the last scan at the next scan. | Requires root; errors exit 1. |
| `sudo shld coverage accept PATH...` | Accept named absolute paths. Use exactly one of `--all` or paths. `--state`, `--json`. | Queues `coverage-accept.json`; it does not rewrite the last report. |

The shared `scan` and `run` flags include `--root` (default `.`), `--proc` (default `/proc` on Linux), `--logins` (default `auto`), `--state` (default `.shld`), `--host`, `--interval` (default `1s`), `--listen`, `--max-files` (default `50000`), `--feed-url`, `--feed-key`, `--feed-interval` (default `1h`), `--privileged-policy`, `--privileged-policy-sha256`, `--host-packages` (default `auto`: read the host's OS package databases when `--root` is narrower than `/`), and `--egress-check` (a daily outbound-traffic check, a TCP handshake to two public resolvers; on by default). Empty `--proc`, `--logins` and `--host-packages` values disable those collectors. `--egress-check=false` or `SHLD_EGRESS_CHECK=false` turns the outbound check off. Feed intervals below one minute are refused.

The supplied unit overrides several defaults with state `/var/lib/private/shld`, address `127.0.0.1:8099`, and interval `5s`. Use `sudo shld status` so the CLI can discover a recognized service's actual values.

## Connect and update

| Command | Purpose and key flags | Exit behavior |
| --- | --- | --- |
| `sudo shld auth login` | Start or resume browser-approved connection. | `authorization_required` with `--json --non-interactive` exits 2. |
| `sudo shld auth status` | Verify the saved connection and read recipients. | 0 connected or configured, 2 missing authorization, 1 verification or argument failure. |
| `sudo shld auth logout` | Revoke this server, preserve its tape, and disable export. | Errors exit 1; a recognized running service restarts. |
| `sudo shld auth logout --local-only` | Remove the local secret while remote revocation remains unknown. | Reports `local_only_remote_revocation_unknown`. |
| `shld update --check` | Inspect authenticated candidates without changes. | 0 completed, 2 invalid, 3 verification incomplete, 4 refused, 6 recovery unproved. |
| `sudo shld update` | Apply a supported binary-only update. `--release VERSION`, `--json`. | 0 completed, 2 invalid, 3 verification incomplete, 4 refused, 5 rolled back, 6 recovery unproved. |
| `sudo shld update auto enable` | Install the daily verified update timer and turn it on. The installer runs it on new installations. | 2 invalid use; other failures print the reason and the next command. |
| `sudo shld update auto disable` | Turn automatic updates off. The choice survives later updates. | Same as above. |
| `shld update auto status` | Show whether automatic updates are on and the last attempt. `--json`. | 2 invalid use. |
| `sudo shld update auto resume` | Clear the block an unproved recovery left, after you review it. | Same as above. |
| `sudo shld root` | Show the watched folder, the file that sets it, and whether the service can read it. | 0 shown, 2 invalid arguments, 4 refused when not run as root or `shld.service` is not installed. |
| `sudo shld root PATH` | Watch `PATH` instead: check it like the installer, back up the setting, restart the service and wait for a scan. `--dry-run`, `--json`. | 0 changed, unchanged or planned, 4 refused with nothing changed, 5 restored the old folder after a failed restart, 6 restore failed. |

`shld root` changes only the file scan; OS packages are always checked from the host, whatever the folder. It refuses a relative or missing path, a file, `/`, `/proc`, anything inside the state directory, and a folder the service user cannot read, and then prints the exact fix, such as `sudo chmod o+x /home/user/app`. A stopped service stays stopped and watches the new folder from its next start.

Every auth subcommand accepts `--json`, `--non-interactive`, `--server`, `--auth-dir`, `--system`, `--apply-service`, `--no-service`, and `--host-label`. Only logout accepts `--local-only`. On an installed service host, foreground authorization requires `--no-service`.

## Fixes

Fixes are off until you run `sudo shld fix enable`. A fix runs only for a plan this server wrote itself from recipes compiled into the binary, after a passkey approval that the server checks against the pinned approver keys.

| Command | Purpose |
| --- | --- |
| `sudo shld fix enable` | Pin the fix approver keys after you confirm their fingerprint against the Fixes settings page, then turn fixes on. |
| `sudo shld fix disable` | Turn fixes off on this server. The cloud cannot turn them back on. |
| `shld fix status` | Show whether fixes are on, the pinned approver keys, and the running plan. |
| `shld fix history` | List the fix plans this server proposed or ran. |
| `shld fix show PLAN_ID` | Print one plan and its journal. |
| `sudo shld fix trust accept` | Count newly added approver keys now instead of after 24 hours. |
| `sudo shld fix trust reset` | Forget the pinned approver keys. Run `enable` again to pin new ones. |

The `auto` subcommands manage a signed shadow-mode policy. Shadow mode records what a fix would do and changes nothing.

## Evidence and local files

`shld verify --state DIR` validates an existing tape and emits `valid`, `sequence`, and `head`. Exit 0 means valid, 1 means invalid chain, unsafe state, or an I/O failure, and 2 means `tape_absent`. It can create `tape.lock` for an existing tape.

`shld canary --root DIR --path RELATIVE` creates a new decoy and returns its path and `created` status. The path is required and must not replace an existing file.

`sudo shld privileged-policy init --root DIR --output ABSOLUTE_PATH` creates a new mode-`0600` privileged-file policy and prints its SHA-256 and pin command. `--host` and `--max-files` are optional. It never overwrites.

## Local SBOM export

`shld sbom` first ships in tag `v0.1.0-pilot.20261110.3`; earlier releases do not have it. `shld sbom` writes CycloneDX 1.6 JSON on stdout by default. `--root` selects the inventory root and defaults to `/`. Use `--format spdx` for SPDX 2.3 JSON. `--output FILE` writes a mode-`0600` file instead of stdout.

```sh
shld sbom --root / --output inventory.json
shld sbom --root / --format spdx --output inventory.spdx.json
```

Each package includes its package URL (purl), version, and manifest or install path within the selected root. The command needs no agent, state directory, or network, and sends no inventory off the host.

The command skips packages without an expressible package URL and counts them in a stderr warning. An incomplete scan still writes the SBOM, warns on stderr with affected paths and reasons, and exits 2. A complete export exits 0. Invocation and I/O errors exit 1. File output uses a temporary file and rename in the target directory and refuses a symlink target.

## Advanced services

The evidence sink is experimental and not supported at launch. `shld sink` receives full evidence records on a loopback plain-HTTP listener. Relevant flags are `--state`, `--listen`, `--heartbeat-timeout`, and `--feed-directory`. Remote evidence requires a same-host TLS proxy. Set `SHLD_EVIDENCE_TOKEN` through the environment.

`shld broker --broker-config FILE` serves the broker policy over a private Unix socket. `--socket` defaults to `<state>/broker.sock`, and `--token-ttl` defaults to `30s`. The policy is one strict JSON document with a 1 MiB limit.

`shld feed` provides operator and publisher commands, all with JSON output:

| Subcommand | Purpose |
| --- | --- |
| `feed keygen --output PATH` | Create a new Ed25519 private key without overwriting. |
| `feed sign --key KEY --snapshot FILE --output DIR` | Sign a schema-1 snapshot, or schema 2 with exact `--approval` and `--report`. |
| `feed sync --feed-key KEY` | Synchronize schema-1 feed state; `--url` and `--state` select source and cache. |
| `feed status --feed-key KEY` | Report cached schema-1 manifest, state, and age. |
| `feed mirror --feed-key KEY --output DIR` | Export verified schema-1 cache data. |
| `feed verify-bundles --manifest FILE --feed-key KEY` | Verify a schema-2 signed manifest. |
| `feed sign-bundles --key KEY --in DIR --out NEW_DIR` | Verify and sign a bundle artifact into a new directory. |
| `feed check-bundles --url HTTPS_BASE --manifest FILE` | Check candidate and live bundle publication; `--before-upload` selects preflight checks. |

## Credentials and version

`shld version` prints the injected release tag or development metadata. It ignores any arguments you pass.

The CLI refuses `--token` and `--notify-token`, including misplaced joined forms, because arguments can appear in process listings and parse errors. Use private environment files or systemd credentials. Notification connections use `SHLD_URL`, `SHLD_TOKEN`, and `SHLD_NOTIFY_HOST_ID`. Evidence uses `SHLD_SINK` and `SHLD_EVIDENCE_TOKEN`.

## Limits

Flags are command-specific, and a shared parser flag is not meaningful for every advanced command. Use the installed binary's help when an older release differs from this main-branch reference.

## Related

- [Install and connect a server](/docs/install)
- [Update and roll back shld](/docs/updates)
- [Activity findings](/docs/activity-findings)
- [SSH logins in observe mode](/docs/ssh-logins)
