Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Claude Code CLI 快速教程:从环境搭建到批量处理的实用指令集

Claude Code 配置教程(以 Mac 系统为例)

1. 必备工具

工具用途安装地址
Node.js运行环境https://nodejs.org
Git版本控制https://git-scm.com

2. 检查 Node.js 版本

node -v

3. 检查 Git 版本

git --version

4. 安装 Claude Code

npm install -g @anthropic-ai/claude-code

5. 验证 Claude Code 安装

claude --version

6. 配置环境变量

cursor ~/.zshrc
# 或
vim ~/.zshrc

写入以下内容:

export ANTHROPIC_BASE_URL="https://******"
export ANTHROPIC_AUTH_TOKEN="******"

7. 重载配置文件

source ~/.zshrc

8. 启动 Claude

claude

常用指令

指令说明
/help显示全部可用命令
/exit退出当前对话
/clear清除当前对话历史
/rename <名称>重命名会话
/resume [session]恢复已命名会话
/model切换模型
/reviewAI 代码审查
/rewind回退改动(代码 / 对话)
/cost查看 Token 用量和消耗

更多指令见官网:https://code.claude.com/docs/en/overview