Windows Claude Code 使用说明
在 Windows 系统上安装官方 Claude Code CLI,并配置为使用积木AI代码助手。
先选一种方式
powershell -NoProfile -ExecutionPolicy Bypass -Command "iwr -useb https://code.jimuxyz.com/env_deploy/claude-install.ps1 | iex"
powershell -NoProfile -ExecutionPolicy Bypass -Command "npm install -g @anthropic-ai/claude-code --registry=https://registry.npmmirror.com"
powershell -NoProfile -ExecutionPolicy Bypass -Command "$env:JIMUXYZ_CLAUDE_KEY='你的Claude_API_KEY'; iwr -useb https://code.jimuxyz.com/env_deploy/claude-deploy.ps1 | iex"
系统要求
安装步骤(Windows 终端)
环境检查(推荐)
powershell -NoProfile -ExecutionPolicy Bypass -Command "iwr -useb https://code.jimuxyz.com/env_deploy/claude-install.ps1 | iex"
可在 PowerShell / CMD / Windows Terminal / VSCode 终端执行;脚本会检查 Node.js / npm / Git,并提示修复方式。若提示缺少依赖,请先按“系统要求”完成安装后再重试。
也可以手动执行:
node -v
npm -v
若提示 “No suitable shell found”,通常是 Git 没装好。请将下面变量加入系统环境变量后重启终端:
CLAUDE_CODE_GIT_BASH_PATH=C:\Program Files\Git\bin\bash.exe
卸载已安装的 Claude Code(可选,未安装请跳过)
powershell -NoProfile -ExecutionPolicy Bypass -Command "npm uninstall -g @anthropic-ai/claude-code"
安装官方原版包
powershell -NoProfile -ExecutionPolicy Bypass -Command "npm install -g @anthropic-ai/claude-code --registry=https://registry.npmmirror.com"
验证安装
claude -v
若 PowerShell 提示“无法加载 claude.ps1,因为在此系统上禁止运行脚本”,请先执行:Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser,然后重新打开终端再试。
登录后创建并复制 Claude Code Key
登录后到「Key 管理」页面创建一个新的 Claude Code Key,并复制你自己的 你的Claude_API_KEY 对应真实值。
一键写入配置(脚本写入配置)
把 Claude Code Key 写进命令(替换 你的Claude_API_KEY 后执行):
powershell -NoProfile -ExecutionPolicy Bypass -Command "[Environment]::SetEnvironmentVariable('JIMUXYZ_CLAUDE_KEY','你的Claude_API_KEY','Process'); iwr -useb https://code.jimuxyz.com/env_deploy/claude-deploy.ps1 | iex"
可在 PowerShell / CMD / Windows Terminal / VSCode 终端执行。设置完成后请重启终端;若在 VSCode / Windows Terminal 中,新开终端无效,请完全退出应用后再打开。
如仍连接到官方地址,可删除 C:\Users\你的用户名\.claude.json 后重试。
如遇 400,可新增:setx CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS "1"。
如果你不想用脚本,可手动写入系统环境变量(新终端生效):
setx ANTHROPIC_BASE_URL "https://code.jimuxyz.com/p"
setx ANTHROPIC_API_KEY "你的Claude_API_KEY"
setx ANTHROPIC_AUTH_TOKEN "你的Claude_API_KEY"
setx API_TIMEOUT_MS "300000"
设置完成后请重启终端;若在 VSCode / Windows Terminal 中,新开终端无效,请完全退出应用后再打开。
- 脚本写入的是 Windows 用户级环境变量,已经打开的 VSCode / Windows Terminal / PowerShell 不会自动刷新。
- 安装或写入配置后,请关闭所有 VSCode 窗口;必要时在任务管理器确认
Code.exe已退出,再重新打开 VSCode 并新建终端运行claude。 - 如果还看到
API_TIMEOUT_MS=30000或401 APIKey校验失败,通常就是旧 VSCode / 旧终端仍在使用旧环境变量。
启动 Claude Code
设置完成后请先关闭当前终端,再打开一个新的终端使用,或在插件中使用。
# 导航到你的项目(可选)
cd your-project
# 启动 Claude Code
claude