相关链接
本文基础平台为Windows操作系统。(WSL操作逻辑同Linux)
Windows终端
按win+x组合键,点击终端会打开Windows PowerShell终端,但这是早期的version5版本,我们需要在微软应用商店里下载version7版本,应用名称为PowerShell。

随后呼出终端,右键顶部选择设置,将默认终端选择为PowerShell,输入如下命令检查版本:
# 检查PowerShell版本$PSVersionTable.PSVersionClaudeCode安装

Native原生安装解耦
在官方文档中,推荐的原生安装命令为:
irm https://claude.ai/install.ps1 | iex但由于国内网络问题,通常是无法持续正常访问的,因此我对脚本进行了解耦:
param( [Parameter(Position=0)] [ValidatePattern('^(stable|latest|\d+\.\d+\.\d+(-[^\s]+)?)$')] [string]$Target = "latest")
Set-StrictMode -Version Latest$ErrorActionPreference = "Stop"$ProgressPreference = 'SilentlyContinue'
# Check for 32-bit Windowsif (-not [Environment]::Is64BitProcess) { Write-Error "Claude Code does not support 32-bit Windows. Please use a 64-bit version of Windows." exit 1}
$DOWNLOAD_BASE_URL = "https://downloads.claude.ai/claude-code-releases"$DOWNLOAD_DIR = "$env:USERPROFILE\.claude\downloads"
# Use native ARM64 binary on ARM64 Windows, x64 otherwiseif ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { $platform = "win32-arm64"} else { $platform = "win32-x64"}New-Item -ItemType Directory -Force -Path $DOWNLOAD_DIR | Out-Null
# Always download latest version (which has the most up-to-date installer)try { $version = Invoke-RestMethod -Uri "$DOWNLOAD_BASE_URL/latest" -ErrorAction Stop}catch { Write-Error "Failed to get latest version: $_" exit 1}
try { $manifest = Invoke-RestMethod -Uri "$DOWNLOAD_BASE_URL/$version/manifest.json" -ErrorAction Stop $checksum = $manifest.platforms.$platform.checksum
if (-not $checksum) { Write-Error "Platform $platform not found in manifest" exit 1 }}catch { Write-Error "Failed to get manifest: $_" exit 1}
# Download and verify$binaryPath = "$DOWNLOAD_DIR\claude-$version-$platform.exe"try { Invoke-WebRequest -Uri "$DOWNLOAD_BASE_URL/$version/$platform/claude.exe" -OutFile $binaryPath -ErrorAction Stop}catch { Write-Error "Failed to download binary: $_" if (Test-Path $binaryPath) { Remove-Item -Force $binaryPath } exit 1}
# Calculate checksum$actualChecksum = (Get-FileHash -Path $binaryPath -Algorithm SHA256).Hash.ToLower()
if ($actualChecksum -ne $checksum) { Write-Error "Checksum verification failed" Remove-Item -Force $binaryPath exit 1}
# Run claude install to set up launcher and shell integrationWrite-Output "Setting up Claude Code..."try { if ($Target) { & $binaryPath install $Target } else { & $binaryPath install }}finally { try { # Clean up downloaded file # Wait a moment for any file handles to be released Start-Sleep -Seconds 1 Remove-Item -Force $binaryPath } catch { Write-Warning "Could not remove temporary file: $binaryPath" }}
Write-Output ""Write-Output "$([char]0x2705) Installation complete!"Write-Output ""根据脚本内容,我们先要获取版本号,访问https://downloads.claude.ai/claude-code-releases/latest即可。
然后获取claude.exe本体,下载链接(以x64平台为例)为https://downloads.claude.ai/claude-code-releases/2.1.133/win32-x64/claude.exe,如果后有更新,可以更改这里的版本号获取最新版。
随后指定版本号并执行程序即可(这一步仍需要科学上网TUN模式):.\claude.exe install 2.1.133

这时,我们需要将Claude的程序目录C:\Users\<yourname>\.local\bin\添加进系统环境变量,以便于直接claude命令启动。

ClaudeCode镜像安装脚本
根据上文解耦的内容,并结合mitmproxy分析,我制作了如下的镜像安装脚本,你只需要在powershell7中运行命令即可:
irm https://blog.srprolin.top/install-claude-mirror.ps1 | iexCC-Switch应用
前往CC-Switch官网下载该应用,下面是该项目的简介:
CC Switch 把供应商切换、MCP / Prompts / Skills、代理接管、会话检索和云同步收进同一个桌面应用,你不再需要反复手改 JSON、TOML 或 .env。

这里以GLM Coding Plan的配置为例,API KEY、请求地址和主模型是最重要的三个配置,这里也对应到settings.json文件中的配置,随后启动ClaudeCode就可以跳过登录了。
ClaudeCode基础使用
# 进入项目文件夹cd ./pjc1/
# 启动参数# 新会话启动claude# 继续上次对话启动claude -c# 自动式(完全权限)启动claude --dangerously-skip-permissions
# 使用过程中# 检查安装情况/doctor# 加载之前的会话上下文/resume# 清除上下文/clear# 显示上下文占用/context# 适时压缩上下文/compact# 回滚历史会话与修改 (快捷键:两次Esc)/rewind# 审查做出的代码更改 (自动调优review)/simplify# 创建项目记忆文件 (CLAUDE.md)/init# 编辑记忆文件 (全局/项目/文件夹)/memory# 创建子agent (subagents)/agent# 指定文件@anyfile.md# 退出ClaudeCode会话 (快捷键:两次Ctrl+C)/exit
# 命令帮助/help# 配置信息/config# 模型更改/model# Skill工具/skills# MCP工具/mcp# ClaudeCode插件/plugin| 快捷键 | 说明 |
|---|---|
Shift+Tab | 切换工作模式 |
Ctrl+Enter | 换行 |
Esc | 取消当前操作 / 退出 |
! <command> | 直接执行 shell 命令并返回输出 |
Git For Windows

请前往 Git For Windows 官网进行下载,关于Git相关的命令可以参考Git Book中文版并结合Agent来学习应用。
首先,Git本身作为代码版本管理工具,具有非常大的作用,方便我们随时保存和恢复代码版本;
其次在Windows系统下,Shell工具只有PowerShell和CMD,像Bash工具就需要通过WSL在Linux子系统中使用;
但Git Bash随着Git安装也会被安装,这就很好的为Agent提供了良好的命令行Shell环境,这也是ClaudeCode官方文档中推荐安装的原因。
发现错误或想要改进这篇文章?