7.11 /doctor - 檢查安裝健康狀況
概述
/doctor 命令用於檢查 Claude Code 的安裝健康狀況,診斷常見問題,並提供修復建議。
基本语法
bash
/doctor
功能说明
執行 /doctor 命令後,Claude Code 會:
- 檢查系統環境
- 驗證安裝完整性
- 測試網路連線
- 檢查配置檔案
- 提供診斷報告和修復建議
检查项目
1. 系统环境
- 作業系統版本
- Node.js 版本
- 記憶體和磁碟空間
2. 安裝完整性
- Claude Code 版本
- 依賴包完整性
- 可執行檔案路徑
3. 網路連線
- Anthropic API 連線
- 代理設定
- DNS 解析
4. 配置檔案
- 配置檔案語法
- 配置檔案路徑
- 配置項有效性
5. 認證狀態
- 登入狀態
- 令牌有效性
- 賬戶許可權
python
## 使用场景
### 1\. 遇到问题时诊断
bash
# 当 Claude Code 出现问题时
/doctor
# 查看诊断报告
### 2\. 安装后验证
bash
# 安装完成后验证
/doctor
# 确保安装正常
### 3\. 定期健康检查
bash
# 定期运行健康检查
/doctor
# 确保系统运行正常
## 输出示例
bash
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:网络连接失败
bash
✗ Network Connection
- API Connection: Failed
- Error: Connection timeout
Suggested Fix:
1. Check internet connection
2. Verify proxy settings
3. Try disabling VPN
### 问题 2:认证失败
bash
✗ Authentication
- Status: Not logged in
- Error: Invalid token
Suggested Fix:
1. Run /logout
2. Run /login
3. Verify account credentials
### 问题 3:配置文件错误
bash
✗ 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不會修改任何檔案或設定- 診斷報告會儲存到日誌檔案中
- 某些檢查可能需要網路連線
- 修復建議需要手動執行
与其他命令的配合使用
bash
# 诊断问题,然后修复
/doctor
/login
/doctor
# 执行流程:
# 1. 运行诊断检查
# 2. 根据建议执行修复
# 3. 再次运行诊断确认修复
最佳实践
- 安裝後檢查 :安裝完成後立即執行
/doctor - 問題診斷 :遇到問題時首先執行
/doctor - 定期檢查 :定期執行健康檢查,確保系統正常
- 備份配置 :在修改配置前,先備份配置檔案
總結
/doctor 命令是 Claude Code 中用於診斷問題的重要工具。透過使用此命令,你可以:
- 檢查系統環境
- 驗證安裝完整性
- 測試網路連線
- 檢查配置檔案
- 獲取修復建議
合理使用 /doctor 命令可以幫助你快速診斷和解決 Claude Code 的問題。