Claude Code 使用教程
在 VS Code / Cursor 中配置和使用 Claude Code
🚀
快速开始
💻
VS Code 1.98+
或 Cursor
🔑
API Key
从本站获取
🌐
网络连接
访问 API 网关
1
安装 Claude Code 扩展
方式一:扩展商店安装(推荐)
- 1打开 VS Code / Cursor
- 2按 Ctrl+Shift+X(Mac: Cmd+Shift+X)打开扩展面板
- 3搜索
Claude Code for VS Code - 4点击 Install 安装扩展
2
配置 API 端点
⚠️ 重要步骤
必须先禁用登录提示,然后配置第三方 API 端点才能使用本站服务
步骤 2.1:禁用登录提示
方式一:快捷链接(推荐)
方式二:手动搜索
- • 打开 IDE 设置(Ctrl+, / Cmd+,)
- • 搜索
claudeCode.disableLoginPrompt - • 勾选 Disable Login Prompt 选项
步骤 2.2:配置 settings.json
编辑 Claude Code 配置文件 ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "替换成自己KEY",
"ANTHROPIC_BASE_URL": "https://api.xn--jc2am9tp1j.xn--fiqs8s",
"API_TIMEOUT_MS": "600000",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
}
}
配置文件位置:
• Windows: C:\Users\用户名\.claude\settings.json
• macOS/Linux: ~/.claude/settings.json
3
开始使用 Claude Code
打开 Claude Code 面板
- • 命令面板:按 Ctrl+Shift+P(Mac: Cmd+Shift+P),输入 "Claude Code"
- • 状态栏:点击窗口右下角的 ✱ Claude Code
- • 快捷键:Alt+K 快速发送提示
常用命令
/help
- 查看帮助
/model
- 切换模型
/compact
- 压缩对话
/resume
- 恢复会话
💡
常见工作流示例
🔍 代码理解
> what does this project do? > explain the folder structure > where is the main entry point?
✏️ 代码编辑
> add input validation to the form > refactor to use async/await > fix the bug where users can submit empty
🔧 Git 操作
> what files have I changed? > commit with a descriptive message > help me resolve merge conflicts
🧪 测试与文档
> write unit tests for calculator > update README with instructions > review my changes and suggest improvements
⌨️
快捷键参考
| 功能 | Windows/Linux | macOS |
|---|---|---|
| 打开命令面板 | Ctrl+Shift+P | Cmd+Shift+P |
| 快速发送提示 | Alt+K | Alt+K |
| 取消当前操作 | Ctrl+Esc | Cmd+Esc |
| 新建对话 | Ctrl+N | Cmd+N |
| 打开设置 | Ctrl+, | Cmd+, |
❓
常见问题
Q: 扩展无法安装?
确保 VS Code 版本 ≥ 1.98.0,或尝试使用命令行安装方式。
Q: Claude Code 不响应?
检查 settings.json 配置是否正确,确保 API 端点和 Key 填写无误。
Q: 如何切换模型?
在对话中输入 /model 命令即可切换不同的 Claude 模型。
🔗