/doctor - 检查安装健康状况

诊断环境、配置与连接问题

概述

/doctor 命令用于检查 Claude Code 的安装健康状况,诊断常见问题,并提供修复建议。

基本语法

/doctor

功能说明

执行 /doctor 后,Claude Code 会:

  • 检查系统环境。
  • 验证安装完整性。
  • 测试网络连接。
  • 检查配置文件。
  • 输出诊断报告与修复建议。

检查项目

  1. 系统环境:操作系统版本、Node.js 版本、内存与磁盘空间。
  2. 安装完整性:Claude Code 版本、依赖完整性、可执行路径。
  3. 网络连接:API 连接、代理设置、DNS 解析。
  4. 配置文件:语法、路径、配置项有效性。
  5. 认证状态:登录状态、令牌有效性、账户权限。

使用场景

1. 遇到问题时诊断

# 当 Claude Code 出现问题时
/doctor

# 查看诊断报告

2. 安装后验证

# 安装完成后验证
/doctor

# 确保安装正常

3. 定期健康检查

# 定期运行健康检查
/doctor

# 确保系统运行正常

输出示例

Claude Code Health Check
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

 System Environment
  - OS: Windows 11
  - Node.js: v18.17.0
  - Memory: 16 GB
  - Disk: 50 GB available

 Installation
  - Version: 1.0.124
  - Dependencies: All installed
  - Executable: Found at C:\Program Files\claude\bin\claude.exe

 Network Connection
  - API Connection: OK
  - Proxy: Not configured
  - DNS: Resolving correctly

 Configuration
  - Config File: Valid
  - Config Path: C:\Users\user\.config\claude\config.json
  - Settings: All valid

 Authentication
  - Status: Logged in
  - Token: Valid
  - Permissions: Full access

Overall Status: Healthy

常见问题诊断

问题 1:网络连接失败

 Network Connection
  - API Connection: Failed
  - Error: Connection timeout

Suggested Fix:
1. Check internet connection
2. Verify proxy settings
3. Try disabling VPN

问题 2:认证失败

 Authentication
  - Status: Not logged in
  - Error: Invalid token

Suggested Fix:
1. Run /logout
2. Run /login
3. Verify account credentials

问题 3:配置文件错误

 Configuration
  - Config File: Invalid syntax
  - Error: Unexpected token at line 10

Suggested Fix:
1. Check config.json syntax
2. Run /config to reset settings
3. Restore from backup

注意事项

  • /doctor 不会修改任何文件或设置。
  • 诊断报告会保存到日志文件中。
  • 某些检查需要网络连接。
  • 修复建议需要手动执行。

与其他命令的配合使用

# 诊断问题,然后修复
/doctor
/login
/doctor

# 执行流程:
# 1. 运行诊断检查
# 2. 根据建议执行修复
# 3. 再次运行诊断确认修复

最佳实践

  • 安装后立即运行 /doctor
  • 遇到问题时先诊断再修复。
  • 定期运行健康检查。
  • 修改配置前先备份配置文件。

总结

/doctor 命令帮助你快速诊断环境与配置问题,是排查故障的首选工具。

On this page