Skip to main content

openclaw doctor

Diagnostic tool that checks system health and automatically repairs common issues.

Usage

Options

boolean
Apply suggested fixes without prompting (non-interactive)
boolean
Run in non-interactive mode (equivalent to —fix)
boolean
Automatically generate and configure gateway token if missing
boolean
Show workspace improvement suggestions (default: true)

What Doctor Checks

The doctor command performs comprehensive system diagnostics:

1. Configuration

  • Config file validity - JSON5 syntax and schema validation
  • Gateway configuration - Mode, port, bind, auth settings
  • Legacy config migration - Detects and migrates deprecated settings
  • Missing required fields - Ensures all required config is present

2. Authentication

  • Gateway auth - Token/password configuration
  • Auth profiles - Model provider credentials
  • OAuth profiles - Anthropic/OpenAI OAuth status
  • Deprecated profiles - Removes obsolete CLI auth profiles

3. Gateway Health

  • Reachability - Can the gateway be reached?
  • Service status - Is the daemon installed and running?
  • Port conflicts - Is the port already in use?
  • Daemon configuration - Service configuration validity

4. Channels

  • Channel connectivity - Are channels reachable?
  • Token validity - Are channel tokens configured correctly?
  • Recent errors - Checks channel logs for issues

5. Workspace

  • Directory existence - Is the workspace accessible?
  • Bootstrap files - Are guide files present?
  • Skills directory - Is skills structure correct?
  • Memory system - Is memory search configured?

6. System Integration

  • systemd lingering (Linux) - User session persistence
  • LaunchAgent overrides (macOS) - Environment conflicts
  • Shell completion - Command completion setup
  • Path environment - Is openclaw on PATH?

7. State Integrity

  • Session files - Session store validity
  • Lock files - Stale lock detection and cleanup
  • Legacy state - Old data migration
  • Backup suggestions - Workspace backup reminders

8. Security

  • Auth warnings - Insecure configurations
  • Token exposure - Tokens in env/logs
  • Bind warnings - Unsafe bind modes
  • Sandbox scope - Container security settings

9. Updates

  • Version check - Is an update available?
  • Update channel - Current channel status
  • UI protocol - Frontend/backend version compatibility

10. Docker/Sandbox

  • Docker availability - Is Docker installed?
  • Sandbox images - Are required images present?
  • Image updates - Are images up to date?

Automatic Repairs

Doctor can automatically fix many issues:

Config Repairs

  • Migrate legacy configuration format
  • Generate missing gateway token
  • Fix gateway auth mode
  • Update deprecated settings
  • Repair malformed config

Auth Repairs

  • Remove deprecated auth profiles
  • Fix OAuth profile IDs
  • Clear invalid session overrides

Gateway Repairs

  • Repair daemon configuration
  • Fix service install issues
  • Regenerate gateway token

Workspace Repairs

  • Create missing directories
  • Install bootstrap files
  • Fix skills structure

System Repairs

  • Enable systemd lingering (Linux)
  • Install shell completion
  • Fix PATH configuration

Examples

Output Format

Doctor organizes findings into sections:

Status Indicators

  • (green) - Check passed
  • (yellow) - Warning, may need attention
  • (red) - Error, requires action

Interactive Prompts

When run interactively, doctor prompts for repairs:
Options:
  • Y - Apply the fix
  • n - Skip this fix
  • Ctrl+C - Exit doctor
Use --fix to auto-accept all prompts.

Common Issues

Gateway Won’t Start

Symptoms:
  • openclaw gateway start fails
  • Gateway not reachable
Doctor checks:
  1. Config validation
  2. Port conflicts (lsof -i :18789)
  3. Gateway auth configuration
  4. Daemon service status
Suggested fixes:

Channel Not Working

Symptoms:
  • Messages not sending/receiving
  • Channel shows offline
Doctor checks:
  1. Channel token validity
  2. Channel connectivity
  3. Recent channel errors
  4. Gateway health
Suggested fixes:

Config Invalid

Symptoms:
  • Commands fail with config errors
  • Gateway won’t start
Doctor checks:
  1. JSON5 syntax
  2. Schema validation
  3. Required fields
  4. Type checking
Suggested fixes:

After Update Issues

Symptoms:
  • Commands fail after update
  • Config incompatible
Doctor checks:
  1. Config schema version
  2. Legacy migrations
  3. UI protocol version
  4. Dependencies
Suggested fixes:

systemd Service Stops (Linux)

Symptoms:
  • Gateway stops on logout
  • Service not persistent
Doctor checks:
  1. User lingering status
  2. Service configuration
Suggested fixes:

Exit Codes

  • 0 - Doctor completed successfully
  • 1 - Doctor found critical issues
  • 2 - Doctor encountered errors
Use in scripts:

Scheduling

Run doctor periodically:

Cron

systemd Timer

Create ~/.config/systemd/user/openclaw-doctor.timer:
And ~/.config/systemd/user/openclaw-doctor.service:
Enable:

Logs

Doctor operations are logged to:
View doctor-specific logs:

Migration Detection

Doctor detects and migrates:
  • Legacy session format - Old session file structure
  • Old agent state - Pre-2026 agent configuration
  • WhatsApp auth migration - Auth directory changes
  • Config schema updates - Field renames/restructuring

Manual Migration

If automatic migration fails:

Security Warnings

Doctor checks for security issues:

Auth Mode None

Token in Logs

Unsafe Bind

Best Practices

  1. Run after install: openclaw onboard then openclaw doctor
  2. Run after updates: openclaw update then openclaw doctor
  3. Run before reporting issues: Include doctor output in bug reports
  4. Run periodically: Weekly health checks recommended
  5. Review warnings: Don’t ignore yellow warnings