# `sysknife` CLI Reference
`sysknife` is the command-line interface to the SysKnife daemon. It turns a
natural-language intent into a risk-labelled plan, asks for approval where
needed, and streams execution output in real time.
If you want SysKnife inside Claude Code / Cursor / Codex CLI instead, see
the [main README](https://github.com/lacs-project/sysknife/blob/main/README.md) and run `npx sysknife-setup`. Both paths
share the daemon, the audit chain, and the typed-action set.
---
## Quick start
```sh
# Check that the daemon is reachable
sysknife doctor
# Plan + execute a single intent
sysknife "check disk usage"
# Preview the plan without executing
sysknife --dry-run "list running containers"
# Open the interactive REPL
sysknife
```
---
## Synopsis
```text
sysknife [GLOBAL FLAGS] [SUBCOMMAND | INTENT WORDS...]
```
When no subcommand is given and no intent words are provided, `sysknife` starts
an interactive REPL.
---
## Subcommands
### `sysknife fleet hosts `
Validate and display an explicit host inventory without contacting any daemon.
Each TOML entry names a host, its socket and the SHA-256 pin of its daemon audit
public key:
```toml
[[host]]
name = "web-1"
socket = "unix:///run/user/1000/sysknife-web-1.sock"
key = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
```
```sh
sysknife fleet hosts inventory.toml
sysknife fleet hosts inventory.toml --json
```
Text output shows the name, socket and first 12 key characters. JSON output is
an array containing the full entries in file order. Unix socket paths must be
absolute; Linux also accepts `vsock://CID:PORT`. Names contain 1-64 ASCII letters,
digits, dots, underscores or hyphens. Keys contain exactly 64 lowercase
hexadecimal characters.
An empty inventory, duplicate name/socket/key, missing key, unknown field or
invalid entry rejects the entire inventory with exit code 4. Errors name the
offending host. This command validates the file; live pin checks happen when a
future fleet command connects.
### `sysknife `
Plan and (optionally) execute a natural-language intent.
```sh
sysknife "check disk usage"
sysknife check disk usage # words are joined — same result
sysknife "list running containers"
sysknife "is firewalld active?"
sysknife "layer vim via rpm-ostree"
```
**What happens:**
1. A spinner appears while the LLM plans (`Thinking…` → `Querying …` →
`Proposing plan…`).
2. The coloured plan is printed — each step shows a risk badge
(`● low` / `● medium` / `● HIGH`), the action name, a summary and the
step's parameters.
3. If any step requires approval, you are prompted once for the plan. HIGH-risk
steps always require confirmation regardless of `--yes`.
4. Before each step runs, its header prints the daemon's proposed change and
expected side effects. A MEDIUM or HIGH step that `--yes` did not
auto-approve asks again here, with that change on screen.
5. Execution streams output line by line with a `›` prefix; a `✓` / `✗`
result icon is printed after each step.
The plan and step views are capped at 40 lines per block and 512 columns per
line, so a long parameter list cannot scroll the prompt away. If a block you
are about to answer for does not fit, the run refuses to ask and exits 1;
re-run with `--json` to see it in full. Under `--yes` nothing is asked, so the
capped view is printed and the run continues.
If you ask the planner to remember or forget a preference, the plan lists the
change under **Preference changes** and you answer a separate question before
`prefs.md` changes. Nothing is written under `--dry-run`, `--yes` or
`--non-interactive`, or when you reject the plan. `sysknife_plan` over MCP
never writes preferences.
The natural-language planner has no secure way to collect or resolve a
credential after planning. It therefore does not offer Ubuntu Pro attachment,
and it joins open Wi-Fi networks only: a plan step that carries a Wi-Fi
password is refused. Do not put a Pro token or Wi-Fi password in an intent:
the admission check rejects known credential shapes before contacting the model.
Use the Ubuntu Pro or NetworkManager tools outside SysKnife for those
operations until a separate credential entry path exists. `ProStatus`, `ProDetach`, `EnableProService`, and
`DisableProService` remain available through SysKnife because they do not
take a credential parameter.
The sensitive-data fence matches value-bearing labels (such as
`password=hunter2`, `API_KEY: value`, or `my password is hunter2`), long
Bearer tokens, private-key PEM headers, and known API/token prefixes with
plausible bodies at token boundaries. Security administration requests such
as "set password aging to 90 days", "who can read /etc/passwd", and
"my root disk-full alert keeps firing" remain available. The same fence
checks summary prompts and remembered preferences and withholds matching
intents from the planning notice.
It also matches "with password" or "using token" followed by a quoted
value, or a token containing digits or token punctuation, such as
"with password hunter2". Policy phrases such as "with password aging
enforcement" remain available.
Assignment labels must end in a credential term: `ANTHROPIC_API_KEY` and
`AWS_SECRET_ACCESS_KEY` match, while policy/path settings such as
`PASSWORD_MAX_DAYS=90`, `TOKEN_LIFETIME=3600`, and `API_KEY_FILE=/etc/key`
are allowed unless their values themselves match a known credential format.
This is a format heuristic: an unlabelled password such as "connect to
MyNet with hunter2" can pass it. An allowed intent does not prove that it
contains no secret. Keep credentials out of intents; the fence does not
provide the separate credential entry path described above.
---
### `sysknife doctor`
Check daemon connectivity and print the resolved configuration.
```sh
sysknife doctor
sysknife --json doctor # machine-readable
```
Exit code `0` when the daemon is reachable and the LLM configuration is
valid. Exit code `4` when the daemon is unreachable **or** when the
configuration has a problem (missing provider key, unreadable config).
When the LLM configuration is unreadable, `doctor` still checks the daemon
and reports the config problem as a warning. The `provider` and `model`
fields read `"unknown"` and the `--json` output includes a `warnings` array.
Sample output:
```text
✓ daemon ok
socket unix:///run/sysknife/daemon.sock
host my-silverblue
provider anthropic
model claude-sonnet-4-6
distro fedora
```
---
### `sysknife history`
Query past SysKnife execution history.
```sh
sysknife history
sysknife history --limit 50
sysknife history --status failed
sysknife history --action InstallPackages
sysknife history --since 2026-04-01T00:00:00Z
sysknife history --status succeeded --limit 5 --since 2026-04-10T00:00:00Z
```
**Flags:**
| Flag | Default | Description |
|---|---|---|
| `--limit N` | `20` | Maximum entries to return |
| `--status STATUS` | — | Filter by job status (`succeeded`, `failed`, `canceled`, …) |
| `--action ACTION` | — | Filter by action name (e.g. `InstallPackages`) |
| `--since DATETIME` | — | Only entries after this ISO-8601 date or UTC-qualified datetime |
---
### `sysknife approve`
Issue a one-time receipt for a transaction returned by the MCP
`sysknife_plan` tool. Issuing a receipt requires an interactive terminal. It first
loads and displays the daemon-authoritative action, risk, summary, and proposed
change so an agent cannot substitute an opaque transaction ID. It mints the
receipt only after confirmation; high-risk approvals require typing the exact
action name.
`--max-risk` checks the daemon's preview risk before prompting and refuses any
transaction above the ceiling. `--non-interactive` refuses receipt issuance,
including with `--yes` or unattended consent: a receipt records explicit human
approval. Those auto-approval flags apply to intent execution, not this command.
`--dry-run` loads and displays the preview without prompting or issuing a
receipt. It works without a terminal, including with `--non-interactive`, and
can display risks above `--max-risk` because it approves nothing. With `--json`,
the output contains `transaction_id`, `action_name`, `preview` and `dry_run: true`,
with no `approval_receipt` field.
```sh
sysknife approve 018f2c9d-...
sysknife --json approve 018f2c9d-...
sysknife approve 018f2c9d-... --full
sysknife --dry-run --json approve 018f2c9d-...
```
The proposed change is displayed through a bounded renderer: 40 lines, 512
characters per line. The bounds are there so a long change cannot scroll the
action name and risk level off the screen before you answer.
When the bounds hide anything, approval is refused rather than accepted, and the
message says how many lines were withheld and how many were cut short. Approving
a change you were shown part of would produce a receipt proving you typed a word,
not that you read what you agreed to.
`--full` prints every line and every character, with the same neutralisation
applied, and prints the action, risk and summary **after** the change so the
decision context is the last thing on screen however long the change is. Pipe it
to a pager if you like; the text cannot rewrite your terminal either way.
```text
$ sysknife approve 018f2c9d-...
error: the proposed change does not fit the approval view: 132 line(s) were not
shown. Approving would mean consenting to text you were not shown. Re-run with
--full to see all of it: sysknife approve 018f2c9d-... --full
```
Give the printed `approval_receipt` to the MCP client for that exact step. The
receipt expires after 15 minutes, is bound to the preview's action and params,
and is consumed on first execution. A chat message saying "approved" is not a
receipt.
---
### `sysknife audit`
Inspect and anchor the tamper-evident, Ed25519-signed audit chain the daemon
writes for every executed action.
#### `sysknife audit export`
Export both signed chains from the configured SQLite or PostgreSQL audit store:
```json
{"version":1,"chain":[],"events":[],"partial":false}
```
`chain` contains the stored transaction rows and `events` the stored event
rows, each in ascending `seq` order. Row fields and signatures are preserved.
The top-level object replaces the former transaction-only array; consumers
that iterated the old array should now read `.chain`.
```sh
sysknife audit export
sysknife audit export --since 2026-08-01T00:00:00Z --limit 500
sysknife audit export > audit.json
sysknife audit verify --from audit.json --pubkey /etc/sysknife/audit-key.pub
```
| Flag | Description |
|---|---|
| `--since DATETIME` | Include transaction rows recorded at or after this RFC 3339 timestamp |
| `--limit N` | Emit at most N matching transaction rows; omitted means all matching rows |
Either filter sets `partial: true`; the event chain is still included in full.
Offline verification refuses a partial export with exit code 2. Export without
filters when the file will be verified.
An export is not a redacted artifact. It inherits the confidentiality class of
the audit database, which the daemon keeps `0600` inside a `0700` directory, and
writing one moves that content across the boundary those modes exist to hold.
Every row carries `request_hash`, a commitment to the action name and the
**unredacted** parameters. `compute_request_hash` runs before
`redact_params`, so redaction never reaches the hashed preimage. Since
`chain_version = 4` the commitment is an HMAC-SHA256 keyed by the audit key,
which never leaves the host: an export is still not a redacted artifact, but
the hashes in it can no longer be verified or brute-forced offline. Rows
written by earlier releases (`chain_version` 1–3) carry the unsalted SHA-256
those versions computed, and for them the exposure below still applies — the
column cannot be rewritten, because doing so would break the signature the row
was written with.
For a legacy row where an action's parameters are low entropy and partly
public the hash is worth attacking: for `ConfigureWifi` the SSID is broadcast,
which leaves the passphrase as the only unknown. High-entropy values such as
`ProAttach` tokens are unaffected.
The column cannot be dropped, because `request_hash` is part of the signed bytes
an offline verifier rebuilds. Treat an export with the same care as the database
itself rather than as a sanitised report.
#### `sysknife audit verify`
Verify the audit trail: the transaction chain, the approval-event chain, and
the binding between them. All three are reported and any one can fail the
command. Exits `0` if everything is intact, `1` if any check finds tampering,
`2` if a check cannot establish the history (missing key, unreadable database,
or an empty unanchored transaction log). When the checks disagree the worst
wins, and `1` outranks `2` — if something is provably broken, "could not verify"
would understate it.
With `--json` the report is an object with a top-level `status` plus a `chain`,
`approval_events` and `binding` section, so a pipeline can act on which part
failed. A readable empty transaction log without an independent anchor reports
`CANNOT VERIFY`, exit `2`, and top-level JSON `cannot_verify`, whether it is a
fresh store or an erased one. Its `chain` subresult still reports zero intact
rows: that row-integrity check does not establish which history occurred.
```sh
sysknife audit verify
sysknife audit verify --json
sysknife audit verify --pubkey /etc/sysknife/audit-key.pub
sysknife audit verify --from audit.json --pubkey /etc/sysknife/audit-key.pub
```
| Flag | Description |
|---|---|
| `--json` | Machine-readable JSON report instead of human text |
| `--from FILE` | Verify a complete version-1 export offline. Requires `--pubkey`; opens no database or private key and contacts no checkpoint service. |
| `--pubkey FILE` | Verify with only the exported public key (`.pub`), no private key: the third-party / auditor path. Works with SQLite and PostgreSQL and proves the chain without signing access. |
Offline verification checks both signature chains and their bindings using
the existing verifier. Live status columns and external checkpoints are
outside the exported document. Checking for deletion of an otherwise valid
tail still requires an independently retained checkpoint.
#### `sysknife audit checkpoint`
Sign the current chain tip as a checkpoint and anchor it to an external
append-only database, then verify all anchored checkpoints against the local
chain. Anchoring the tip off-box is what makes tail-truncation and rewrite of
the local chain detectable.
```sh
# credentials via env (preferred; keeps them off the command line)
SYSKNIFE_CHECKPOINT_DB=postgres://user@host/db sysknife audit checkpoint
# or explicitly
sysknife audit checkpoint --db postgres://user@host/db
```
| Flag | Description |
|---|---|
| `--db URL` | Postgres URL of the append-only checkpoint database. Prefer `SYSKNIFE_CHECKPOINT_DB` so credentials are not exposed via `ps` / shell history. |
Each row is signed with Ed25519; verification uses the public key, so an
auditor can verify without the ability to forge. See
[configuration](./configuration.md) for the key and checkpoint-DB env vars.
---
### `sysknife completions `
Print a shell completion script to stdout.
```sh
sysknife completions bash >> ~/.bashrc
sysknife completions zsh >> ~/.zshrc
sysknife completions fish >> ~/.config/fish/completions/sysknife.fish
```
Supported shells: `bash`, `zsh`, `fish`, `elvish`, `powershell`.
---
### `sysknife mcp-server`
Start an MCP (Model Context Protocol) server over stdio, so Claude Code, Claude
Desktop, Cursor, Codex, and any other MCP-capable agent can drive SysKnife.
```sh
sysknife mcp-server
```
It exposes five fixed tools backed by the SysKnife daemon: `sysknife_plan`,
`sysknife_execute`, `sysknife_history`, `sysknife_doctor`, and
`sysknife_audit_verify`. It also generates direct read-only query tools for the
detected distro, such as `sysknife_get_disk_usage`. Planning and execution stay
behind the same approval interlock as the CLI — `sysknife_plan` returns typed
steps with daemon-issued transaction IDs, and each step still requires an
explicit `sysknife approve ` in a real terminal before it can
run. Low risk is not treated as read-only: `AptUpdate` remains plan-only.
Register it with your agent by pointing it at the binary, e.g. in
`claude_desktop_config.json`:
```json
{ "mcpServers": { "sysknife": { "command": "sysknife", "args": ["mcp-server"] } } }
```
`npx sysknife-setup` writes this configuration for the common clients
automatically.
---
### REPL (no arguments)
```sh
sysknife
```
Starts an interactive session. Each line is treated as a natural-language
intent and planned + executed in sequence.
**Key bindings:**
| Key | Action |
|---|---|
| ↑ / ↓ | Navigate command history |
| Ctrl+R | Reverse incremental history search |
| Ctrl+A / Ctrl+E | Jump to line start / end |
| Ctrl+W | Delete word before cursor |
| Ctrl+C | Exit the REPL (same as Ctrl+D; history is saved) |
| Ctrl+D | Exit the REPL |
| `exit` / `quit` | Exit the REPL |
History is persisted to `~/.local/share/sysknife/history` between sessions.
---
## Global flags
Global flags may appear before or after a subcommand. Their behavior depends on
the command:
- `--yes`, `--step-by-step` and the unattended auto-approval override apply to
free-form intents and the REPL. `approve` always requires human confirmation.
- `--max-risk`, `--non-interactive` and `--dry-run` apply to intents, the REPL
and `approve`, as described above. Read-only subcommands perform no approval.
- `--json` controls structured output for intents, `approve`, `doctor` and
`audit verify`; `history` and `audit export` already emit JSON. It has no
effect on `audit checkpoint`, completions or `mcp-server`, which use their
own output formats.
- `--timeout` limits the invocation and `--log-to` tees output sent through the
CLI logger. `audit checkpoint`, completions and the MCP server write directly
to their output.
- The two-key unattended consent check applies to every subcommand, even when
the command performs no auto-approval.
| Flag | Description |
|---|---|
| `--yes` | Auto-approve LOW-risk steps. With `--max-risk medium`, also approves MEDIUM. HIGH always requires human confirmation. |
| `--max-risk LEVEL` | Abort if the plan or approval transaction exceeds this ceiling. Values: `low`, `medium`, `high`. |
| `--non-interactive` | Fail immediately (`exit 1`) if any step would require interactive approval. Use in scripts and CI. |
| `--dry-run` | Print the plan or approval preview and exit without executing or issuing a receipt. |
| `--step-by-step` | Prompt for approval before each individual step instead of once for the whole plan. Each prompt comes *after* that step's daemon preview is printed. The whole-plan risk ceiling and non-interactive checks still run before any execution preview. |
| `--json` | Emit NDJSON to stdout — one JSON object per event (plan, preview, progress, result). All colour and spinner output is suppressed. Safe to pipe. |
| `--timeout SECS` | Hard wall-clock limit for the CLI invocation in seconds. Stops waiting when exceeded; see exit codes below. |
| `--log-to FILE` | Tee stdout to FILE in addition to the terminal. Appends if the file exists; stderr diagnostics are not captured. |
| `--dangerously-skip-approval` | Raises the ceiling `--yes` is clamped to from MEDIUM to HIGH, so `--yes --max-risk high` approves HIGH-risk steps too. It does not switch on `--yes`, `--max-risk` or `--non-interactive`; pass them yourself. Refuses to run unless `SYSKNIFE_I_ACCEPT_UNATTENDED_ROOT=1` is also set. On `mcp-server` it turns on the [MCP unattended mode](mcp.md#unattended-mode). See [Unattended mode](#unattended-mode). |
---
## Unattended mode
`--dangerously-skip-approval` lets a plan written by a language model execute
HIGH-risk actions with nobody confirming them. It exists for scheduled and
CI-driven runs, and it is the only way to lift the rule that `--yes` can never
auto-approve HIGH.
### Two keys, on purpose
The flag alone does nothing but print an explanation and exit 1. It needs the
environment variable as well:
```sh
SYSKNIFE_I_ACCEPT_UNATTENDED_ROOT=1 \
sysknife --dangerously-skip-approval --yes --max-risk high --json \
"apply pending security updates"
```
`--yes` is not optional here. The flag raises the ceiling that `--yes` is
clamped to; it does not switch auto-approval on by itself, so without `--yes`
the run reaches the first prompt, reads EOF on a closed stdin and exits 1.
Neither half is enough alone. A flag left in a script and a variable left in a
shell profile are the two ways this gets armed by accident, and requiring both
means neither accident is sufficient. Only the exact value `1` counts; `true`,
`yes` and `0` are all read as unset.
The consent check applies to every subcommand, including commands such as
`doctor` and `audit export` that do not approve actions. A wrapper that always
adds the flag must therefore also provide the environment variable. The
unattended-mode banner is written to stderr, so structured stdout remains clean.
The flag has no short form and no abbreviation. Typing it has to be a decision.
`sysknife mcp-server` honours the same two keys and the same `--yes` and
`--max-risk` flags, so an MCP agent can run unattended too. Without `--yes` the
server refuses to start. The mechanism is in
[Unattended mode](mcp.md#unattended-mode) of the MCP reference.
### What it turns off
One thing: the approval gate.
- `--yes` may now auto-approve HIGH-risk steps. The cap moves from MEDIUM to
HIGH, and nothing else is switched on.
- When `--yes` approves a HIGH step, its post-preview confirmation no longer
asks, the same as for a MEDIUM step under `--yes --max-risk medium`. The preview is
still fetched and still printed, because it is the only record of what the
run was about to change.
An explicit `--max-risk` still wins. `--dangerously-skip-approval --max-risk
low` aborts on a MEDIUM step, because the flag removes the ceiling the project
imposes, not the one you asked for. `--dry-run` still executes nothing.
### What it does not turn off
Everything that makes SysKnife more than a shell:
- Only actions in the typed catalogue can run, with validated parameters. There
is no path from this flag to an arbitrary command.
- The polkit allowlist still gates every privileged D-Bus call.
- The run still aborts if the daemon rates a step above what the CLI approved.
- Role-based authorization is unchanged. An account that cannot run an action
still cannot run it.
- Every step is still previewed, still gets a transaction row, and is still
signed into the audit chain.
If you want a tool that will run any command an LLM writes, this is not it, and
no flag here turns it into one.
### The audit trail records it
A transaction previewed in this mode carries this sentence in its `warnings`:
> Approved without a human: this step was previewed by a client running with
> --dangerously-skip-approval, so no operator confirmed it.
`warnings` is stored as `warnings_json`, and `warnings_json` is one of the
fields inside the row's Ed25519 signature. So the record is not a log line that
can be edited later: deleting it makes `sysknife audit verify` report that row
`Broken`. `sysknife audit export` carries it like any other field.
The CLI checks that the daemon sent the sentence back, and refuses to execute
if it did not. A daemon older than this field accepts the declaration and drops
it, which would leave an unattended run indistinguishable from an approved one.
Upgrade the daemon, or drop the flag.
### Before you use it
Run it against a machine you can rebuild. The failure mode is not a bad diff to
revert; it is a system change applied by a model with no one watching. A VM
snapshot beforehand costs less than the alternative.
---
## Exit codes
| Code | Meaning |
|---|---|
| `0` | Success |
| `1` | Plan or step **refused** — you rejected it, it exceeded the configured risk ceiling, approval was required but the session is non-interactive, or the planner declined the request outright (distinct from a planning failure, which is `3`) |
| `2` | **Execution failed**, including a daemon preview failure after an earlier plan step executed; also a command-line usage error or the whole-command `--timeout` expired (see below) |
| `3` | **Planning failed** — LLM error, provider unreachable, the intent could not be turned into a plan, or a daemon preview refusal before any plan step executed |
| `4` | **Configuration or daemon error** — invalid configuration, or the daemon could not be reached |
| `5` | **Reboot required** - a step returned `needs_reboot`; remaining steps were not executed and the plan is incomplete. Reboot and deliberately re-run or resume. |
In the REPL, a failed intent prints its diagnostic and the session continues.
When standard input is not a terminal (piped intents) or `--non-interactive` is
set, the process exits with the **first** failed intent's code once the input
ends, including when the session ends with `exit` or `quit`, so a script that
pipes intents fails when any of them does. An interactive terminal session still
exits `0` at `exit`, `quit` or end of input.
If OpenAI reaches its output token limit before completing a proposed tool call,
SysKnife discards the partial plan and returns a planning failure. Split a large
intent into smaller requests; the truncated response is not retried as malformed
tool-call JSON.
Subcommands with their own semantics (for example `sysknife audit verify`) pass
through their own exit code.
Clap returns `2` for malformed command-line arguments, such as an invalid
`--max-risk` value, before planning or execution starts. `--timeout` also returns
`2` and reports `operation timed out after Ns`; it applies to the whole command
and can expire during planning, execution, or another subcommand. Inspect the
diagnostic to distinguish these cases: exit `2` alone does not mean an action ran.
The timeout diagnostic does not identify which phase timed out. A CLI timeout
stops waiting; it does not guarantee cancellation of work already submitted to
the daemon.
---
## Environment variables
### LLM provider
`sysknife` auto-detects between Anthropic and local Ollama from the presence of
`ANTHROPIC_API_KEY`. Every other provider must be selected explicitly with
`SYSKNIFE_LLM_PROVIDER` (and its matching API key set).
| Variable | Description |
|---|---|
| `SYSKNIFE_LLM_PROVIDER` | Force a provider: `anthropic`, `openai`, `gemini`, `ollama`, `groq`, `deepseek`, `mistral`, `xai` |
| `SYSKNIFE_LLM_MODEL` | Override the model name for the selected provider |
| `ANTHROPIC_API_KEY` | Use the Anthropic provider (default model: `claude-sonnet-4-6`) |
| `OPENAI_API_KEY` | Use the OpenAI provider (default model: `gpt-4.1`) |
| `GEMINI_API_KEY` | Use the Gemini provider (default model: `gemini-2.0-flash`) |
| `GROQ_API_KEY` | Use the Groq provider (default model: `openai/gpt-oss-120b`) |
| `DEEPSEEK_API_KEY` | Use the DeepSeek provider (default model: `deepseek-chat`) |
| `MISTRAL_API_KEY` | Use the Mistral provider (default model: `mistral-large-latest`) |
| `XAI_API_KEY` | Use the xAI provider (default model: `grok-3`) |
| `SYSKNIFE_ANTHROPIC_URL` | Override the Anthropic base URL (default: `https://api.anthropic.com`) |
| `SYSKNIFE_OLLAMA_URL` | Override the Ollama base URL (default: `http://localhost:11434`) |
| `SYSKNIFE_BRAIN_MAX_TURNS` | Planning loop turn limit — integer ≥ 1 (default: `10`) |
| `SYSKNIFE_OLLAMA_THINK` | Set `true`/`false` to override thinking-mode detection for Ollama models |
**Auto-detection** (when `SYSKNIFE_LLM_PROVIDER` is not set):
1. `ANTHROPIC_API_KEY` present and non-empty → `anthropic`
2. Otherwise → `ollama` (must be running locally)
The other providers (`openai`, `gemini`, `groq`, `deepseek`, `mistral`, `xai`)
require explicit selection. For example, set `SYSKNIFE_LLM_PROVIDER=openai`
with `OPENAI_API_KEY`, or `SYSKNIFE_LLM_PROVIDER=gemini` with `GEMINI_API_KEY`.
The same pattern applies to the other providers in the table.
### Daemon socket
| Variable | Description |
|---|---|
| `SYSKNIFE_SOCKET` | Daemon socket the CLI dials (`unix://`, `vsock://`, or a bare path). Falls back to the same resolution as `SYSKNIFE_LISTEN_URI`: `$XDG_RUNTIME_DIR/sysknife/daemon.sock`, then `/tmp/sysknife-$UID.sock` as a last resort. Production deployments set this via the systemd unit to `/run/sysknife/daemon.sock`. Audit commands read a local database directly and do not use this socket. |
### Audit database
| Variable | Description |
|---|---|
| `SYSKNIFE_DATABASE_PATH` | SQLite audit database used by `audit export` and `audit verify`. Set this when inspecting a copied database or selecting one store on a machine with multiple deployments. |
### Unattended-mode consent
| Variable | Value | Meaning |
|---|---|---|
| `SYSKNIFE_I_ACCEPT_UNATTENDED_ROOT` | exactly `1` | Second half of the two-key rule for `--dangerously-skip-approval`. Inert on its own: setting it changes nothing until the flag is also passed. Any other value, including `true` and `yes`, reads as unset. |
See [Unattended mode](#unattended-mode) for what the flag does and does not
turn off.
---
## Scripting and CI
For non-interactive use (scripts, CI pipelines), combine `--json`,
`--non-interactive`, and `--max-risk`:
```sh
# Plan only — parse the JSON to inspect before executing
PLAN=$(sysknife --dry-run --json "check disk usage")
echo "$PLAN" | jq '.plan.steps[].action'
# Execute automatically up to medium risk; fail if anything higher appears
sysknife --yes --max-risk medium --non-interactive "list layered packages"
# Full pipeline with a timeout and log
sysknife --yes --max-risk low --non-interactive --timeout 60 \
--log-to /var/log/sysknife/run.log \
"check disk usage"
# Unattended, including HIGH-risk steps. Both keys are required, and every
# step is recorded in the signed chain as having had no human approval.
SYSKNIFE_I_ACCEPT_UNATTENDED_ROOT=1 \
sysknife --dangerously-skip-approval --yes --max-risk high --json --timeout 300 \
"apply pending security updates"
```
A dry run of an intent reports the same refusals as the real run. The plan is
still printed, but the exit code is non-zero when the real run would refuse it:
`1` when a step is above `--max-risk`, `4` when the target distro cannot run a
step. A pre-flight check can therefore treat exit 0 from
`sysknife --dry-run --json ...` as "the real run would be accepted".
`--log-to` records stdout only. Capture stderr separately when the log must
include provider notices, planning progress, and failure diagnostics:
```sh
sysknife --yes --max-risk low --non-interactive --timeout 60 \
--log-to /var/log/sysknife/run.log "check disk usage" \
2>>/var/log/sysknife/run.err
```
The `--json` output schema:
```jsonc
// Planning output
{ "plan": { "intent": "…", "summary": "…", "steps": [
{ "action": "GetDiskUsage", "summary": "…", "risk": "low", "params": {} }
] } }
// Per-step preview (before execution)
{ "summary": "…", "risk_level": "low", "reboot_required": false,
"warnings": [], "request_hash": "…", … }
// Execution progress (one per line the daemon streams while a step runs)
{ "event": "progress", "line": "Executing GetMemoryInfo…" }
// Per-step result (after execution)
{ "status": "succeeded", "summary": "…", "job_id": "…",
"needs_reboot": false, "warnings": [], … }
```
---
## Examples
```sh
# Check if any services are failing
sysknife "which systemd services are failed?"
# See recent SysKnife activity
sysknife history --limit 10
# Dry-run a destructive action to inspect the plan
sysknife --dry-run "layer vim via rpm-ostree"
# Execute step-by-step with manual approval of each action
sysknife --step-by-step "update system"
# Non-interactive: fail fast if the plan needs a human
sysknife --non-interactive --max-risk low "check memory pressure"
# Get JSON output and parse with jq
sysknife --dry-run --json "list containers" | jq '.plan.steps[].action'
# Override the LLM for a single run
SYSKNIFE_LLM_PROVIDER=openai OPENAI_API_KEY=sk-... sysknife "check disk usage"
# Use a local Ollama model
SYSKNIFE_LLM_PROVIDER=ollama SYSKNIFE_LLM_MODEL=llama3.2:3b sysknife "list services"
```
---
## Shell completion setup
Run once per shell:
```sh
# bash (add to ~/.bashrc)
eval "$(sysknife completions bash)"
# zsh (add to ~/.zshrc)
eval "$(sysknife completions zsh)"
# fish
sysknife completions fish | source
```
---
## Related
- [Architecture overview](architecture.md) — trust boundary between CLI, shell,
and daemon
- [Developer guide](developer-guide.md) — building and testing locally
- [User stories](user-stories.md) — end-to-end scenario descriptions