来源:code.claude.com/docs/en/quickstart | 整理时间:2026-04-01
前置条件
- 终端(命令行)基础
- 一个代码项目
- Claude 账号(Pro/Max/Teams/Enterprise 或 Console API 账号)
第一步:安装
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
⚠️ Windows 需要先安装 Git for Windows
原生安装会在后台自动更新,始终保持最新版。
第二步:登录
claude
# 首次使用会提示登录
支持的账号类型:
- Claude Pro / Max / Teams / Enterprise(推荐)
- Claude Console(API 密钥访问)
- Amazon Bedrock / Google Vertex AI / Microsoft Foundry
登录后,凭证会保存在本地,后续无需重复登录。
第三步:启动第一个会话
cd /path/to/your/project
claude
进入后可以:
/help— 查看所有命令/resume— 继续之前的对话
第四步:探索代码库
# 了解项目整体
what does this project do?
# 了解技术栈
what technologies does this project use?
# 了解目录结构
explain the folder structure
# 找入口文件
where is the main entry point?
💡 Claude Code 会自动读取相关文件,不需要手动指定
第五步:做第一次代码修改
add a hello world function to the main file
Claude Code 会:
- 找到合适的文件
- 展示拟修改内容
- 请求你的确认
- 执行修改
默认需要确认每次文件修改。可以开启"全部接受"模式跳过确认。
第六步:Git 操作
# 查看修改内容
what files have I changed?
# 提交(自动生成 commit 信息)
commit my changes with a descriptive message
# 创建分支
create a new branch called feature/my-feature
# 查看提交历史
show me the last 5 commits
第七步:修 Bug、加功能
# 加功能(自然语言描述)
add input validation to the user registration form
# 修 Bug
there's a bug where users can submit empty forms - fix it
# Claude 会:
# 1. 找到相关代码
# 2. 理解上下文
# 3. 实现修改
# 4. 如果有测试,运行测试
常用命令速查
| 命令 | 功能 |
|---|---|
claude |
启动交互模式 |
claude "任务" |
执行一次性任务 |
claude -p "查询" |
单次查询后退出 |
claude -c |
继续上次对话 |
claude -r |
从历史会话中选择继续 |
claude commit |
创建 Git commit |
/clear |
清空对话历史 |
/help |
显示帮助 |
exit 或 Ctrl+C |
退出 |
新手技巧
1. 具体描述需求
# 不好:add tests
# 好:write a test for foo.py covering the edge case
# where user is logged out. avoid mocks.
2. 分步骤指令
# 1. 先探索
read /src/auth and understand how we handle sessions
# 2. 再规划
what files need to change to add Google OAuth?
# 3. 最后执行
implement the OAuth flow from your plan
3. 让 Claude 先探索
使用 Plan Mode 安全分析(不会修改文件):
claude --permission-mode plan
4. 利用快捷键
Esc— 停止当前操作Esc + Esc— 撤回并恢复之前的代码状态Ctrl+G— 在文本编辑器中打开计划Ctrl+O— 切换详细输出模式Shift+Tab— 切换权限模式
下一步
- 📖 最佳实践 — 提升效率的进阶技巧
- 🔄 常见工作流 — 典型场景操作指南
- ⚙️ 配置 CLAUDE.md — 让 Claude 记住你的项目规范