coderclaw doctor is the repair + migration tool for CoderClaw. It fixes stale
config/state, checks health, and provides actionable repair steps.
coderclaw doctor
coderclaw doctor --yes
Accept defaults without prompting (including restart/service/sandbox repair steps when applicable).
coderclaw doctor --repair
Apply recommended repairs without prompting (repairs + restarts where safe).
coderclaw doctor --repair --force
Apply aggressive repairs too (overwrites custom supervisor configs).
coderclaw doctor --non-interactive
Run without prompts and only apply safe migrations (config normalization + on-disk state moves). Skips restart/service/sandbox actions that require human confirmation. Legacy state migrations run automatically when detected.
coderclaw doctor --deep
Scan system services for extra gateway installs (launchd/systemd/schtasks).
If you want to review changes before writing, open the config file first:
cat ~/.coderclaw/coderclaw.json
models.providers.opencode).~/coderclaw).18789).gateway.auth.token is set (local mode; offers token generation).If this is a git checkout and doctor is running interactively, it offers to update (fetch/rebase/build) before running doctor.
If the config contains legacy value shapes (for example messages.ackReaction
without a channel-specific override), doctor normalizes them into the current
schema.
When the config contains deprecated keys, other commands refuse to run and ask
you to run coderclaw doctor.
Doctor will:
~/.coderclaw/coderclaw.json with the updated schema.The Gateway also auto-runs doctor migrations on startup when it detects a legacy config format, so stale configs are repaired without manual intervention.
Current migrations:
routing.allowFrom β channels.whatsapp.allowFromrouting.groupChat.requireMention β channels.whatsapp/telegram/imessage.groups."*".requireMentionrouting.groupChat.historyLimit β messages.groupChat.historyLimitrouting.groupChat.mentionPatterns β messages.groupChat.mentionPatternsrouting.queue β messages.queuerouting.bindings β top-level bindingsrouting.agents/routing.defaultAgentId β agents.list + agents.list[].defaultrouting.agentToAgent β tools.agentToAgentrouting.transcribeAudio β tools.media.audio.modelsbindings[].match.accountID β bindings[].match.accountIdidentity β agents.list[].identityagent.* β agents.defaults + tools.* (tools/elevated/exec/sandbox/subagents)agent.model/allowedModels/modelAliases/modelFallbacks/imageModelFallbacks
β agents.defaults.models + agents.defaults.model.primary/fallbacks + agents.defaults.imageModel.primary/fallbacksIf youβve added models.providers.opencode (or opencode-zen) manually, it
overrides the built-in OpenCode Zen catalog from @mariozechner/pi-ai. That can
force every model onto a single API or zero out costs. Doctor warns so you can
remove the override and restore per-model API routing + costs.
Doctor can migrate older on-disk layouts into the current structure:
~/.coderclaw/sessions/ to ~/.coderclaw/agents/<agentId>/sessions/~/.coderclaw/agent/ to ~/.coderclaw/agents/<agentId>/agent/~/.coderclaw/credentials/*.json (except oauth.json)~/.coderclaw/credentials/whatsapp/<accountId>/... (default account id: default)These migrations are best-effort and idempotent; doctor will emit warnings when
it leaves any legacy folders behind as backups. The Gateway/CLI also auto-migrates
the legacy sessions + agent dir on startup so history/auth/models land in the
per-agent path without a manual doctor run. WhatsApp auth is intentionally only
migrated via coderclaw doctor.
The state directory is the operational brainstem. If it vanishes, you lose sessions, credentials, logs, and config (unless you have backups elsewhere).
Doctor checks:
chown hint when owner/group mismatch is detected).sessions/ and the session store directory are
required to persist history and avoid ENOENT crashes.~/.coderclaw folders exist across
home directories or when CODERCLAW_STATE_DIR points elsewhere (history can
split between installs).gateway.mode=remote, doctor reminds you to run
it on the remote host (the state lives there).~/.coderclaw/coderclaw.json is
group/world readable and offers to tighten to 600.Doctor inspects OAuth profiles in the auth store, warns when tokens are
expiring/expired, and can refresh them when safe. If the Anthropic Claude Code
profile is stale, it suggests running claude setup-token (or pasting a setup-token).
Refresh prompts only appear when running interactively (TTY); --non-interactive
skips refresh attempts.
Doctor also reports auth profiles that are temporarily unusable due to:
If hooks.gmail.model is set, doctor validates the model reference against the
catalog and allowlist and warns when it wonβt resolve or is disallowed.
When sandboxing is enabled, doctor checks Docker images and offers to build or switch to legacy names if the current image is missing.
Doctor detects legacy gateway services (launchd/systemd/schtasks) and offers to remove them and install the CoderClaw service using the current gateway port. It can also scan for extra gateway-like services and print cleanup hints. Profile-named CoderClaw gateway services are considered first-class and are not flagged as βextra.β
Doctor emits warnings when a provider is open to DMs without an allowlist, or when a policy is configured in a dangerous way.
If running as a systemd user service, doctor ensures lingering is enabled so the gateway stays alive after logout.
Doctor prints a quick summary of eligible/missing/blocked skills for the current workspace.
Doctor warns when gateway.auth is missing on a local gateway and offers to
generate a token. Use coderclaw doctor --generate-gateway-token to force token
creation in automation.
Doctor runs a health check and offers to restart the gateway when it looks unhealthy.
If the gateway is healthy, doctor runs a channel status probe and reports warnings with suggested fixes.
Doctor checks the installed supervisor config (launchd/systemd/schtasks) for missing or outdated defaults (e.g., systemd network-online dependencies and restart delay). When it finds a mismatch, it recommends an update and can rewrite the service file/task to the current defaults.
Notes:
coderclaw doctor prompts before rewriting supervisor config.coderclaw doctor --yes accepts the default repair prompts.coderclaw doctor --repair applies recommended fixes without prompts.coderclaw doctor --repair --force overwrites custom supervisor configs.coderclaw gateway install --force.Doctor inspects the service runtime (PID, last exit status) and warns when the
service is installed but not actually running. It also checks for port collisions
on the gateway port (default 18789) and reports likely causes (gateway already
running, SSH tunnel).
Doctor warns when the gateway service runs on Bun or a version-managed Node path
(nvm, fnm, volta, asdf, etc.). WhatsApp + Telegram channels require Node,
and version-manager paths can break after upgrades because the service does not
load your shell init. Doctor offers to migrate to a system Node install when
available (Homebrew/apt/choco).
Doctor persists any config changes and stamps wizard metadata to record the doctor run.
Doctor suggests a workspace memory system when missing and prints a backup tip if the workspace is not already under git.
See /concepts/agent-workspace for a full guide to workspace structure and git backup (recommended private GitHub or GitLab).