Skip to content

Claude Code 相关问题

在 VSCode Claude Code 插件中使用 OpusClaw

Windows

  1. 完成 环境检查,确认 Claude Code CLI 可用
  2. Win+R 进入 %userprofile%\.claude
  3. 没有 config.json 就新建
  4. 写入:
json
{
  "primaryApiKey": "OpusClaw"
}
  1. 重启 VSCode

macOS

  1. 完成环境检查
  2. Finder Cmd+Shift+G 输入 ~/.claude
  3. 创建 config.json,内容同上
  4. 重启 VSCode

Claude Code 常用命令

命令用途
claude在当前目录启动交互式 REPL
claude "question"带初始 query 启动 REPL
claude -p "question"一次问答,输出后退出(脚本场景常用)
claude -c恢复最近一次会话
claude -r "<id>" "task"指定会话 ID 恢复并继续
claude update更新 CLI 到最新版本
claude --model sonnet指定使用 Sonnet 4.6
claude --verbose输出详细日志

Claude Code 报"无法连接到 Anthropic 服务"

如果 claude 启动时报 Unable to connect to Anthropic services,通常是 onboarding 状态没保存好。

Windows

  1. Win+R 输入 cmd
  2. 运行:
powershell
powershell -Command "$f='%USERPROFILE%\.claude.json';$j=Get-Content $f|ConvertFrom-Json;$j|Add-Member -NotePropertyName 'hasCompletedOnboarding' -NotePropertyValue $true -Force;$j|ConvertTo-Json|Set-Content $f"
  1. 重启 Claude CLI

macOS

bash
jq '. + {"hasCompletedOnboarding": true}' ~/.claude.json > /tmp/tmp.json && mv /tmp/tmp.json ~/.claude.json

然后重启 Claude CLI。

切换回 200K 上下文 + 禁用非必要流量

如果你不需要 1M 长上下文(默认 200K 已经够用),可以关掉以省 token:

进入 ~/.claude(Windows: %userprofile%\.claude),编辑 settings.json:

json
{
  "env": {
    "CLAUDE_CODE_DISABLE_1M_CONTEXT": "1",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
    "CLAUDE_CODE_DISABLE_TERMINAL_TITLE": "1"
  }
}

这些都是 Claude Code 提供的官方环境变量开关,关掉非必要流量能降低 token 消耗。

仍解决不了?

  • 检查 Base URL 是不是 https://api.opusclaw.me(不是 https://opusclaw.me)
  • 检查 API Key 是不是 claude 分组令牌(不是 chatgpt / gemini)
  • 截图配置 + 报错,联系客服

OpusClaw