How do `openclaw doctor`, `openclaw doctor --fix` and `openclaw doctor --lint` differ, and which can you run without risking a write?
answer
- postures, not verbosity levels
- prompts are not the same as writes
- repair stops and restarts the service
- read-only with an exit code for CI
- deep means more services, not more health
basics
~20 sPlain openclaw doctor is an interactive health flow that can still migrate legacy config and state; --fix applies supported repairs and stops, repairs and restarts the managed Gateway; --lint, like bare --json, is read-only, and --lint exits nonzero on findings for CI.
solid answer
~40 s`openclaw doctor` checks the Gateway, the service definition, channels, plugins, skills, model routing, local state and config migrations. Its postures differ in what they may change. **Guided** `openclaw doctor` prompts before repairs but can copy legacy config and apply automatic state migrations, and `--non-interactive` only suppresses prompts, not those writes. **Repair**, `openclaw doctor --fix` (alias `--repair`), applies the supported fixes; for a managed Gateway it stops the service, repairs, restarts it once and verifies readiness, so run it from a shell outside the Gateway's process tree. **Lint**, `openclaw doctor --lint`, is read-only and exits nonzero for findings at `--severity-min`, which makes it the CI and monitoring posture; bare `--json` is read-only too but always exits successfully. `--deep` adds a scan for extra gateway installs, not a deeper health probe.
go deeper
Recall the three common forms: openclaw doctor to check and be guided, openclaw doctor --fix to repair, and openclaw doctor --lint for a read-only report.
Explain each posture's write contract: guided runs can migrate config and state, --non-interactive only drops prompts, --fix stops, repairs and restarts the managed Gateway, and lint and bare --json never write.
Show operational judgment: run repair outside the Gateway's process tree, use lint thresholds and --all in monitoring, and know that rehearsing on copied state can still touch the original workspaces.
Decide which Doctor posture each actor gets: automation and dashboards read-only, scheduled lint as the alarm, and repair reserved for a person in a change window with a backup.
## One command, several postures `openclaw doctor` is OpenClaw's health-check and repair tool for the Gateway, its background service, channels, plugins, skills, model routing, local state and config migrations. It is also the command OpenClaw's own installer and updater call on upgrades. What makes it easy to misuse is that its flags are not verbosity levels. They select a **posture**, and each posture has a different contract about writing to your install. | Posture | Command | Writes? | Exit behaviour | |---|---|---|---| | Guided checks | `openclaw doctor` | can copy legacy config and apply automatic state migrations; asks before recommended repairs | interactive | | Advisory JSON | `openclaw doctor --json` | no | succeeds after the report; read `ok` and `findings` | | Repair | `openclaw doctor --fix` (alias `--repair`) | yes, supported repairs | nonzero when a repair cannot finish | | Lint | `openclaw doctor --lint [--json]` | no | nonzero for findings at the chosen threshold | ## The guided run is not read-only The most common surprise is that **plain `openclaw doctor` can change files**. The guided flow can copy legacy config and apply automatic state migrations, and it asks **Apply recommended config repairs now?** before the rest. Adding `--non-interactive` suppresses the prompts; it does not suppress those safe automatic writes. When you want a diagnosis that is guaranteed not to touch anything, for example on a production host before a change window, use `--lint` or bare `--json`. Both read-only postures reject `--fix`, `--repair`, `--force`, `--yes` and `--generate-gateway-token`. ## What `--fix` actually does to a running Gateway Repair is coordinated with the managed service: 1. Doctor finds the matching managed Gateway and checks ownership of the Gateway, the state and the agent databases. 2. It **stops** that Gateway, takes read-only schema snapshots and keeps other processes out during repair. 3. It applies the supported repairs, such as config migrations, legacy session imports, a stale service definition or outdated native policy (for example a missing systemd `KillMode=mixed`). 4. It **restarts** the same service once and verifies readiness. Three practical consequences: - Run it **from a shell outside the Gateway's process tree**, not from a command the Gateway itself launched, because stopping the service would cancel the repair. - A stopped service that targets the current installation is started and verified after a successful standalone `--fix`. - `--force` alone does not select repair; `openclaw doctor --force` stays guided. With `--fix`, `--repair` or `--yes` it allows more aggressive choices, without bypassing ownership or confirmation rules. If a repair cannot finish, Doctor leaves the stopped service stopped, exits with code 1 and names the path and next action. ## Lint for gates and monitoring `openclaw doctor --lint` runs the structured health checks read-only. Use: - `--severity-min info|warning|error` to set the threshold that makes it exit nonzero; - `--all` to include opt-in checks that the default set leaves out; - `--only <id>` and `--skip <id>` to select checks. Those selectors are accepted only together with `--lint`. Bare `--json` uses the default lint selection but keeps the advisory exit code, which suits a dashboard and does not suit a CI gate. ## When Doctor runs without you asking Doctor is also part of OpenClaw's upgrade path, which is why its posture rules matter: - re-running the installer script on an existing install runs `openclaw doctor --fix` before it reports success; - `openclaw update` runs Doctor before activating the new version, using the non-interactive repair path for migrations that would block Gateway startup; - on large installs, update-time Doctor can defer optional inspections to leave time for required repairs. Each one shows as an `update-inspection-deferred` warning: it did not pass or fail, it was not run. Run `openclaw doctor --fix` after activation to complete them. ## Neighbouring tools people confuse with it - `openclaw doctor --deep` scans system services for extra gateway installs and reports recent supervisor restart handoffs; it is not a stronger health probe. - `openclaw gateway status --deep` inspects the installed service and how it is reached, the first stop when Doctor reports a missing or unmanaged service. - `openclaw triage` runs read-only checks and writes a sanitized prompt to hand to a coding agent. - `openclaw channels status --probe` is the tool for channel permissions, which Doctor points you to. One more trap when rehearsing repairs on a copy: `doctor --fix` follows explicitly configured workspace and store paths, so pointing `OPENCLAW_STATE_DIR` and `OPENCLAW_CONFIG_PATH` at a copy does not redirect those, and Doctor can modify the originals.
- Why should you not run `openclaw doctor --fix` from a command the OpenClaw Gateway itself launched?Repair stops the managed Gateway before it touches state. A shell that is a child of that Gateway can be stopped along with it, cancelling the repair mid-way. Doctor's guidance is to run repair from a shell outside the Gateway's process tree; automatic triage likewise refuses a repair that would need to stop the Gateway it is running under.
- Which `openclaw doctor` form would you put in a nightly monitoring job, and why not plain `--json`?`openclaw doctor --lint --json --severity-min warning`, adding `--all` when you want opt-in checks such as systemd lingering. Lint is read-only and exits nonzero when findings reach the threshold, so the job fails visibly. Bare `--json` is also read-only but always exits successfully, so a scheduler would report green while the findings sit unread.
- Plain openclaw doctor only reads and never changes anything
- --non-interactive makes doctor a safe read-only check
- doctor --fix edits state while the Gateway keeps serving
- doctor --deep runs a more thorough health probe of the Gateway
- doctor --force on its own applies aggressive repairs