概述
Claude Code 是一个代理编码工具,可以读取你的代码库、编辑文件、运行命令,并与你的开发工具集成。可在终端、IDE、桌面应用和浏览器中使用。
Claude Code 是一个由 AI 驱动的编码助手,可帮助你构建功能、修复错误和自动化开发任务。它理解你的整个代码库,可以跨多个文件和工具工作以完成任务。
开始使用
选择你的环境来开始使用。大多数界面需要 Claude 订阅 或 Anthropic 控制台 账户。终端 CLI 和 VS Code 也支持第三方提供商。
功能完整的 CLI,用于直接在终端中使用 Claude Code。编辑文件、运行命令,并从命令行管理整个项目。
To install Claude Code, use one of the following methods:
macOS, Linux, WSL:
curl -fsSL https://claude.ai/install.sh | bash
Windows PowerShell:
irm https://claude.ai/install.ps1 | iex
Windows CMD:
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
If you see The token '&&' is not a valid statement separator, you're in PowerShell, not CMD. If you see 'irm' is not recognized as an internal or external command, you're in CMD, not PowerShell. Your prompt shows PS C:\ when you're in PowerShell and C:\ without the PS when you're in CMD.
Git for Windows is recommended on native Windows so Claude Code can use the Bash tool. If Git for Windows is not installed, Claude Code uses PowerShell as the shell tool instead. WSL setups do not need Git for Windows.
Native installations automatically update in the background to keep you on the latest version.
brew install --cask claude-code
Homebrew offers two casks. claude-code tracks the stable release channel, which is typically about a week behind and skips releases with major regressions. claude-code@latest tracks the latest channel and receives new versions as soon as they ship.
Homebrew installations do not auto-update. Run brew upgrade claude-code or brew upgrade claude-code@latest, depending on which cask you installed, to get the latest features and security fixes.
winget install Anthropic.ClaudeCode
WinGet installations do not auto-update. Run winget upgrade Anthropic.ClaudeCode periodically to get the latest features and security fixes.
You can also install with [apt, dnf, or apk](/anthropic/claude-code/history/docs/en/2026-06-09-0634..2026-06-10-2357/setup/#install-with-linux-package-managers) on Debian, Fedora, RHEL, and Alpine.
然后在任何项目中启动 Claude Code:
```bash theme={null}
cd your-project
claude
```
首次使用时,系统会提示你登录。就这样
<Tip>
查看[高级设置](/anthropic/claude-code/history/docs/zh-CN/2026-06-09-0634..2026-06-10-2357/setup/)了解安装选项、手动更新或卸载说明。如果遇到问题,请访问[安装故障排除](/anthropic/claude-code/history/docs/zh-CN/2026-06-09-0634..2026-06-10-2357/troubleshoot-install/)。
</Tip>
VS Code 扩展在编辑器中直接提供内联差异、@-提及、计划审查和对话历史。
或在扩展视图中搜索"Claude Code"(Mac 上为 Cmd+Shift+X,Windows/Linux 上为 Ctrl+Shift+X)。安装后,打开命令面板(Cmd+Shift+P / Ctrl+Shift+P),输入"Claude Code",然后选择在新标签页中打开。
一个独立应用,用于在 IDE 或终端之外运行 Claude Code。直观地查看差异、并行运行多个会话、安排定期任务,并启动云会话。
下载并安装:
- macOS(Intel 和 Apple Silicon)
- Windows(x64)
- Windows ARM64
安装后,启动 Claude,登录,然后点击代码标签开始编码。需要付费订阅。
在浏览器中运行 Claude Code,无需本地设置。启动长时间运行的任务,完成后再检查,处理你本地没有的仓库,或并行运行多个任务。可在桌面浏览器和 Claude iOS 应用中使用。
在 claude.ai/code 开始编码。
一个用于 IntelliJ IDEA、PyCharm、WebStorm 和其他 JetBrains IDE 的插件,具有交互式差异查看和选择上下文共享。
从 JetBrains Marketplace 安装 Claude Code 插件,然后重启你的 IDE。
你可以做什么
以下是你可以使用 Claude Code 的一些方式:
```bash theme={null}
claude "write tests for the auth module, run them, and fix any failures"
```
构建功能和修复错误
用简单的语言描述你想要的内容。Claude Code 规划方法、跨多个文件编写代码,并验证其工作。
对于错误,粘贴错误消息或描述症状。Claude Code 通过你的代码库追踪问题、识别根本原因并实施修复。查看常见工作流了解更多示例。
创建提交和拉取请求
Claude Code 直接与 git 配合工作。它暂存更改、编写提交消息、创建分支并打开拉取请求。
claude "commit my changes with a descriptive message"
在 CI 中,你可以使用 GitHub Actions 或 GitLab CI/CD 自动化代码审查和问题分类。
使用 MCP 连接你的工具
Model Context Protocol (MCP) 是一个开放标准,用于将 AI 工具连接到外部数据源。使用 MCP,Claude Code 可以读取 Google Drive 中的设计文档、更新 Jira 中的工单、从 Slack 拉取数据,或使用你自己的自定义工具。MCP 快速入门端到端连接你的第一个服务器。
使用说明、skills 和 hooks 进行自定义
运行代理团队并构建自定义代理
生成多个 Claude Code 代理,同时处理任务的不同部分。主导代理协调工作、分配子任务并合并结果。
要在并行中运行多个完整会话并从一个屏幕观看它们,请使用后台代理。对于完全自定义的工作流,Agent SDK 让你构建由 Claude Code 的工具和功能驱动的自己的代理,完全控制编排、工具访问和权限。
使用 CLI 进行管道、脚本和自动化
Claude Code 是可组合的,遵循 Unix 哲学。将日志管道传入其中、在 CI 中运行它,或将其与其他工具链接:
# 分析最近的日志输出
tail -200 app.log | claude -p "Slack me if you see any anomalies"
# 在 CI 中自动化翻译
claude -p "translate new strings into French and raise a PR for review"
# 跨文件的批量操作
git diff main --name-only | claude -p "review these changed files for security issues"
查看 CLI 参考了解完整的命令和标志集。
安排定期任务
在任何地方使用 Claude Code
每个界面都连接到相同的底层 Claude Code 引擎,因此你的 CLAUDE.md 文件、设置和 MCP 服务器可在所有界面中工作。
除了上面的终端、VS Code、JetBrains、桌面和网络环境外,Claude Code 还与 CI/CD、聊天和浏览器工作流集成:
| 我想要... | 最佳选项 |
|---|---|
| 从我的手机或另一台设备继续本地会话 | 远程控制 |
| 从 Telegram、Discord、iMessage 或我自己的 webhook 推送事件到会话中 | Channels |
| 在本地启动任务,在移动设备上继续 | 网络或 Claude iOS 应用 |
| 按定期计划运行 Claude | Routines 或桌面计划任务 |
| 自动化 PR 审查和问题分类 | GitHub Actions 或 GitLab CI/CD |
| 在每个 PR 上获得自动代码审查 | GitHub Code Review |
| 将 Slack 中的错误报告路由到拉取请求 | Slack |
| 调试实时网络应用 | Chrome |
| 为你自己的工作流构建自定义代理 | Agent SDK |
后续步骤
安装 Claude Code 后,这些指南可帮助你深入了解。