主题
Claude Code 相关问题
在 VSCode Claude Code 插件中使用 OpusClaw
Windows
- 完成 环境检查,确认 Claude Code CLI 可用
Win+R进入%userprofile%\.claude- 没有
config.json就新建 - 写入:
json
{
"primaryApiKey": "OpusClaw"
}- 重启 VSCode
macOS
- 完成环境检查
- Finder
Cmd+Shift+G输入~/.claude - 创建
config.json,内容同上 - 重启 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
Win+R输入cmd- 运行:
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"- 重启 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)
- 截图配置 + 报错,联系客服