Claude-Code
Claude Code 资源及使用笔记
官方 CLAUDE.md 最佳实践
https://www.anthropic.com/engineering/claude-code-best-practices
Common workflows
https://docs.anthropic.com/en/docs/claude-code/common-workflows
Mac 安装 Claude Code
1、Homebrew 安装 Node.js 及 NPM
确保 Node.js 版本 ≥ 18.0
安装 Node.js 时会自动安装包管理工具 npm
brew install node
node -v
v23.11.0
npm -v
11.5.2
2、npm 全局安装 Claude Code
npm install -g @anthropic-ai/claude-code
claude --version
1.0.83 (Claude Code)
CLAUDE.md 文件
开启全自动(YOLO)模式
修改全局 ~/.claude/settings.json 配置文件
或,修改项目 .claude 目录下的 settings.local.json 
{
  "permissions": {
    "defaultMode": "bypassPermissions"
  }
}
Claude Code 命令
/resume 继续之前的对话
/resume 输入命令后弹出历史对话列表,选择即可继续之前对话
/compact 压缩总结对话历史
压缩对话历史,只保留上下文摘要,从而减少 token 占用。
达到上线后会自动压缩
/context 可视化查看上下文占用
> /context 
  ⎿  
      Context Usage
     ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛀ ⛁   claude-sonnet-4-5-20250929 · 142k/200k tokens (71%)
     ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ 
     ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁   ⛁ System prompt: 2.8k tokens (1.4%)
     ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁   ⛁ System tools: 13.4k tokens (6.7%)
     ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛶   ⛁ MCP tools: 575 tokens (0.3%)
     ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶   ⛁ Messages: 79.8k tokens (39.9%)
     ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶   ⛶ Free space: 58k (29.2%)
     ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛝ ⛝ ⛝   ⛝ Autocompact buffer: 45.0k tokens (22.5%)
     ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ 
     ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ 
     MCP tools · /mcp
     └ mcp__ide__getDiagnostics (ide): 575 tokens
     SlashCommand Tool · 0 commands
     └ Total: 879 tokens
Claude API 中转站
使用方法:
登录后在 令牌管理 中创建令牌,有的分组需要选 『claude code』,选无限额度
复制 sk密钥,编辑 ~/.zshrc 导出下面2个环境变量即可
vim ~/.zshrc
export ANTHROPIC_BASE_URL=https://xxx.com
export ANTHROPIC_AUTH_TOKEN=sk-xxxxxxxxxxxxxxxxxxxxxxxx
AnyRouter 免费
SuperXiaoAi
CodeMirror
https://api.codemirror.codes/console
InstCopilot/DuckCoding
https://instcopilot-api.com/
https://duckcoding.com/
Your API 大模型API中转
https://yourapi.cn/
https://fast.yourapi.cn/
2025.8.17
yourapi.cn  claude-sonnet-4-20250514 百万输出 tokens 人民币 8.1 元
fast.yourapi.cn  laude-sonnet-4-20250514 百万输出 tokens 人民币 4.5 元
2025.8.25
yourapi.cn  claude-sonnet-4-20250514 百万输出 tokens 人民币 67.5 元
fast.yourapi.cn claude-sonnet-4-20250514 百万输出 tokens 人民币 15 元
2025.10.30
yourapi.cn claude-sonnet-4-5-20250929 百万输出 67.5 人民币,叠加最便宜 0.24 分组,百万输出 16.2 人民币
fast.yourapi.cn claude-sonnet-4-5-20250929 百万输出 15 人民币,叠加最便宜的 0.3 倍率分组,百万输出 4.5 人民币
ShareYourCC
Claude Code 工具
New API
Claude Code 代理/中转站 基本上都是使用 New API 开发的
https://github.com/QuantumNous/new-api
https://www.newapi.ai/
Claude Relay Service
自建 Claude-code 中转
https://github.com/Wei-Shaw/claude-relay-service
Claude Code Router
https://github.com/musistudio/claude-code-router
SuperClaude
https://github.com/SuperClaude-Org/SuperClaude_Framework
有用 MCP
mcp: pandoc puppeteer github excel playwright context7
CCometixLine Claude Code 自定义状态栏
https://github.com/Haleclipse/CCometixLine/blob/master/README.zh.md
Claude Code StatusLine | 小工具 大用处
https://linux.do/t/topic/859699
安装:
npm install -g @cometix/ccline
编辑 ~/.claude/settings.json 增加 statusLine 字段配置:
{
  "statusLine": {
    "type": "command", 
    "command": "~/.claude/ccline/ccline",
    "padding": 0
  }
}
安装 meslo-lg 字体族
brew install font-meslo-lg-nerd-font
终端配置字体:
- iTerm2 配置字体:Preferences - Profiles - Default - Text - Font 选择 MesloLGS Nerd Font Mono
- PyCharm/IDEA 配置终端字体:Preferences - Editor - Color Scheme - Console Font - 勾选 Use console font instead of the default - Font 选择 MesloLGS Nerd Font Mono
- VSCode/Cursor 终端字体配置:Ctrl + , 打开配置 - 搜索 terminal.integrated.fontFamily - 输入 MesloLGS Nerd Font Mono
Gemini CLI
https://github.com/google-gemini/gemini-cli
This account requires setting the GOOGLE_CLOUD_PROJECT env var
Failed to login. Message: This account requires setting the GOOGLE_CLOUD_PROJECT env var.
See https://goo.gle/gemini-cli-auth-docs#workspace-gca
打开 Google Cloud 控制台,查看 项目 ID
https://console.cloud.google.com/
vim ~/.zshrc
export GOOGLE_CLOUD_PROJECT=”YOUR_PROJECT_ID”
source ~/.zshrc
上一篇 NPM-Package
下一篇 Docker-安装
页面信息
location:protocol: host: hostname: origin: pathname: href: document:referrer: navigator:platform: userAgent: