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 show *)", "Read(/src/*)", "Edit(/config/*.json)"]
定义无需用户确认即可自动允许的操作模式列表。支持通配符,可显著提升自动化任务的流畅度,同时避免重复授权弹窗。
permissions.deny.[] 配置禁止自动执行的操作模式(如 Bash 命令、文件读写路径等) 字符串数组,例如:
["Bash(git push *)"]
定义不允许的操作模式列表。支持通配符,保证安全。

使用示例

{
  "permissions": {
    "deny": [
      "Bash(git push *)"
    ],
    "allow": [
      "WebSearch",
      "WebFetch(domain:www.electronjs.org)",
      "WebFetch(domain:api.github.com)",
      "WebFetch(domain:github.com)",
      "WebFetch(domain:raw.githubusercontent.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(./mvnw help:evaluate *)",
      "Bash(mvn test *)",
      "Bash(./mvnw test *)",
      "Bash(mvn clean *)",
      "Bash(./mvnw clean *)",
      "Bash(mvn install *)",
      "Bash(./mvnw install *)",
      "Bash(mvn spotless:check)",
      "Bash(./mvnw spotless:check)",
      "Bash(mvn spotless:apply)",
      "Bash(./mvnw spotless:apply)",
      "Bash(mvn checkstyle:check *)",
      "Bash(./mvnw checkstyle:check *)",
      "Bash(echo \"Exit: $?\")",
      "Read(//tmp/**)",
      "Bash(export https_proxy=http://127.0.0.1:1087)"
    ],
    "additionalDirectories": [
      "/tmp",
      "/private/tmp"
    ]
  },
  "includeCoAuthoredBy": false
}

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"
      }
    }
    

NAK: “Bash(./mvnw claen *)”,

感谢提醒,已修改

拒绝推送 权限 效果

{
  "permissions": {
    "deny": [
      "Bash(git push *)"
    ]
  }
}