Anthropic Claude Code

安装

文档

基于 HomeBrew 安装

brew install --cask claude-code
# arch -arm64 brew install --cask claude-code

配置文件(夹)

~/.claude/settings.json    // 配置文件
~/.claude/projects         // 项目文件夹
配置文件属性 含义 可选值 说明
includeCoAuthoredBy 控制 Claude Code 是否在 Git 提交中添加署名 true/false true 时,会自动添加 Co-authored-by: Claude ... 等作者信息
permissions.allow.[] 配置允许自动执行的操作模式(如 Bash 命令、文件读写路径等) 字符串数组,例如:
["Bash(git:*)", "Read(/src/*)", "Edit(/config/*.json)"]
定义无需用户确认即可自动允许的操作模式列表。支持通配符,可显著提升自动化任务的流畅度,同时避免重复授权弹窗。

使用示例

{
  "permissions": {
    "allow": [
      "WebSearch",
      "WebFetch(domain:www.electronjs.org)",
      "WebFetch(domain:api.github.com)",
      "WebFetch(domain:github.com)",
      "Read(//Users/xuxiaowei/.claude/skills/gitmoji/**)",
      "Read(//Users/xuxiaowei/.claude/skills/**)",
      "Read(/tmp/**)",
      "Bash(gh issue *)",
      "Bash(gh run *)",
      "Bash(gh pr *)",
      "Bash(gh api *)",
      "Bash(gh repo view *)",
      "Bash(git config *)",
      "Bash(git add *)",
      "Bash(git commit *)",
      "Bash(git log *)",
      "Bash(git diff *)",
      "Bash(curl *)",
      "Bash(npm run *)",
      "Bash(npm install *)",
      "Bash(npx vue-tsc *)",
      "Bash(mvn help:evaluate *)",
      "Bash(mvn test *)",
      "Bash(mvn claen *)",
      "Bash(mvn install *)",
      "Bash(mvn spotless:check)",
      "Bash(mvn spotless:apply)",
      "Bash(mvn checkstyle:check *)",
      "Bash(./mvnw help:evaluate *)",
      "Bash(./mvnw test *)",
      "Bash(./mvnw claen *)",
      "Bash(./mvnw install *)",
      "Bash(./mvnw spotless:check)",
      "Bash(./mvnw spotless:apply)",
      "Bash(./mvnw checkstyle:check *)"
    ]
  }
}

CC Switch

  • 使用 CC Switch 可以快速切换 claude-code 使用 deepseek 等模型,也可以直接配置 ~/.claude/settings.json,如:
    {
      "env": {
        "ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
        "ANTHROPIC_AUTH_TOKEN": "sk-xxx",
        "ANTHROPIC_MODEL": "DeepSeek-v4-pro",
        "ANTHROPIC_DEFAULT_HAIKU_MODEL": "DeepSeek-v4-pro",
        "ANTHROPIC_DEFAULT_SONNET_MODEL": "DeepSeek-v4-pro",
        "ANTHROPIC_DEFAULT_OPUS_MODEL": "DeepSeek-v4-pro"
      }
    }