1194 字
6 分钟
ClaudeCode原生安装与使用 | Agent | CC-Switch
分享使用agent工具时的一些小心得

相关链接#

本文基础平台为Windows操作系统。(WSL操作逻辑同Linux)

Windows终端#

win+x组合键,点击终端会打开Windows PowerShell终端,但这是早期的version5版本,我们需要在微软应用商店里下载version7版本,应用名称为PowerShell

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

Terminal window
# 检查PowerShell版本
$PSVersionTable.PSVersion

ClaudeCode安装#

Native原生安装解耦#

在官方文档中,推荐的原生安装命令为:

Terminal window
irm https://claude.ai/install.ps1 | iex

但由于国内网络问题,通常是无法持续正常访问的,因此我对脚本进行了解耦:

Terminal window
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 Windows
if (-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 otherwise
if ($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 integration
Write-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中运行命令即可:

Terminal window
irm https://blog.srprolin.top/install-claude-mirror.ps1 | iex

CC-Switch应用#

前往CC-Switch官网下载该应用,下面是该项目的简介:

CC Switch 把供应商切换、MCP / Prompts / Skills、代理接管、会话检索和云同步收进同一个桌面应用,你不再需要反复手改 JSON、TOML 或 .env。

这里以GLM Coding Plan的配置为例,API KEY请求地址主模型是最重要的三个配置,这里也对应到settings.json文件中的配置,随后启动ClaudeCode就可以跳过登录了。

ClaudeCode基础使用#

Terminal window
# 进入项目文件夹
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工具只有PowerShellCMD,像Bash工具就需要通过WSL在Linux子系统中使用;

Git Bash随着Git安装也会被安装,这就很好的为Agent提供了良好的命令行Shell环境,这也是ClaudeCode官方文档中推荐安装的原因。

这篇文章是否对你有帮助?

发现错误或想要改进这篇文章?

文章修订历史 (5 次)

查看变更记录
2026-05-24 684d945

feat: 完善安装脚本交互流程

2026-05-22 e745f38

docs: 更新 ClaudeCode 安装指南,新增镜像安装脚本

2026-05-22 85ae569

CMS:Update Posts “agent-1”

2026-05-15 dc08220

CMS:Update Posts “agent-1”

2026-05-08 8f6043a

posts: 发布文章

ClaudeCode原生安装与使用 | Agent | CC-Switch
https://blog.srprolin.top/posts/agent-1/
作者
RoL1n
发布于
2026-05-09
许可协议
CC BY-NC-SA 4.0

目录
  1. 1
    相关链接
  2. 2
    Windows终端
  3. 3
    ClaudeCode安装
  4. 4
    CC-Switch应用
  5. 5
    ClaudeCode基础使用
  6. 6
    Git For Windows