HomeClaude Code › 中文指南
OverviewInstallCLI referencePricing & limitsAgent SDKSkills & pluginsGitHubWeb, desktop & IDEModelsErrorsOpen source?TutorialFor studentsQA automation中文指南
更新于 September 22, 2026

Claude Code 怎么用:从安装到日常使用

Claude Code 是 Anthropic 官方的命令行编程智能体:它会读取你的代码仓库、制定计划、修改文件、运行测试并提交改动。本文用中文把安装、命令、费用和常见问题讲清楚。

要点

  • 安装:npm install -g @anthropic-ai/claude-code(需要 Node.js 18+),或使用一键安装脚本。
  • 通过两个环境变量即可接入本网关:ANTHROPIC_BASE_URL 和 ANTHROPIC_API_KEY。
  • 按 token 计费,长会话每一轮都会重发全部上下文——所以要经常用 /compact
  • 本站积分按 7.69 倍面值充值($13 可得 $100 额度),也有 $1 起的不限量套餐。

Claude Code 是什么

它不是一个带代码按钮的聊天窗口,而是一个智能体循环:你描述目标,它检查仓库、给出计划、修改文件、运行命令、读取报错并迭代,做危险操作前会先征求许可。它以 npm 包(当前版本 2.1.278)、原生安装器、VS Code / JetBrains 插件、桌面应用和网页版的形式发布。

安装

# 方式一:npm(需要 Node.js 18+)
npm install -g @anthropic-ai/claude-code
claude --version

# 方式二:一键脚本(macOS / Linux / WSL,无需 Node)
curl -fsSL https://claude.ai/install.sh | bash
# Windows PowerShell
irm https://claude.ai/install.ps1 | iex

Windows 下推荐在 WSL 中使用;如果安装后提示找不到 claude 命令,重新打开终端让 PATH 生效即可。

接入网关:两行配置

export ANTHROPIC_BASE_URL=https://aiprimetech.io
export ANTHROPIC_API_KEY=你的网关密钥
claude

把这两行写进 ~/.zshrc~/.bashrc。进入会话后用 /status 确认当前连接的地址与密钥,用 /model 切换模型。网关提供的全部 Claude 模型都可以直接使用。

常用命令

价格与用量

Claude Code 本身免费,费用来自它背后的模型:要么是 Claude Pro/Max 订阅的用量额度,要么是 API 按 token 计费。它每一轮都会重发完整对话和读过的文件,所以长会话费用会快速增长。

套餐时长价格
Unlimited 1 Hour1 hour$1
Unlimited 24 Hours24 hours$10
Unlimited 1 Week1 week$49
Unlimited 15 Days15 days$89

查看全部不限量套餐 →

通过本网关:积分按 7.69 倍面值充值,即 $13 可获得 $100 的按官方价计费的额度(相当于 87% 折扣);重度使用可选不限量套餐,期间不按 token 计费。

Claude Code 开源吗

不开源。CLI 以编译压缩后的 JavaScript 通过 npm 发布,Anthropic 未公开源码。开源的是周边:Agent SDK、GitHub Action、官方 skills 仓库。2026 年曾发生 npm 版本附带 source map 的泄露事件,但这并未改变许可证。想要开源方案,OpenCode、Aider、Cline、Goose 都支持相同的 API,用网关密钥即可使用。

常见报错

常见问题

Claude Code 免费吗?

工具本身免费,使用需要订阅或 API 额度。本站新账户有起始额度,最便宜的持续方案是按小时计费的不限量套餐。

国内能用 Claude Code 吗?

Claude Code 支持自定义 API 地址(ANTHROPIC_BASE_URL),接入本网关后即可正常使用,支付支持银行卡和加密货币。

Claude Code 默认用什么模型?

默认为 Sonnet 档位的当前模型,可用 `/model`、`--model` 或环境变量 ANTHROPIC_DEFAULT_SONNET_MODEL 修改。

在网关上运行 Claude Code

同样的模型,两行环境变量,积分按 7.69 倍面值充值,或选择不限量套餐。

获取 API 密钥 查看套餐

AI Prime Tech is an independent API gateway and is not affiliated with, endorsed by, or sponsored by Anthropic. “Claude” and “Claude Code” are trademarks of Anthropic. Claude Code features described here follow Anthropic’s public documentation at the time of writing and change frequently; prices and model lists on this page are read from this gateway’s live settings.

更多 Claude Code 指南

Claude Code: the complete guideHow to install Claude CodeClaude Code CLI documentation: commands and flagsClaude Code pricing and limits, explainedThe Claude Code SDK, now the Claude Agent SDKClaude Code skills and pluginsClaude Code in GitHub: the App, the Action and @claudeDoes Claude Code have a web interface? Web, desktop and IDE explainedWhich model Claude Code uses, and how to change itClaude Code errors and how to fix themIs Claude Code open source?Claude Code tutorial: your first real sessionClaude Code for studentsHow to use Claude Code for QA automation