SpyBara
Go Premium

settings-example.md 2026-09-24 22:57 UTC to 2026-09-25 23:58 UTC

This page contains 2 additions and 14 deletions.

2026
Sat 12 03:02 Fri 18 23:58 Tue 22 23:59 Fri 25 23:58

設定檔範例

開發者、團隊和組織的實際 settings.json 檔案:複製其中一個,保留您想要的鍵,並變更數值。

本頁面包含三個 settings.json 檔案範例,每個對應一個您儲存設定的位置:

  • 開發者的 ~/.claude/settings.json
  • 團隊的 .claude/settings.json,提交到版本庫
  • 組織的 managed-settings.json

每個檔案都是該讀者的合理檔案,因此您可以看到結構並複製您想要的部分。它們都不是建議的基準。每個數值都來自 設定參考 上的鍵項目,其中包含其類型、預設值和可以設定的位置。

每個範例有兩個標籤。可複製的設定檔 是您儲存的檔案。每個鍵的作用 是相同的檔案,每個鍵上方有註解;Claude Code 不接受設定檔中的註解,因此請從第一個標籤複製。

您自己的設定

一位開發者的個人設定。它選擇一個模型和努力程度,調整終端機,並預先批准一個唯讀命令和一個檔案讀取。未列出的所有內容都保持其預設值。這樣的檔案放在 ~/.claude/settings.json 中,適用於您開啟的每個專案。

將此儲存為 ~/.claude/settings.json。這是有效的 JSON,沒有註解,因此您可以直接貼上並刪除您不想要的鍵。

{
"model": "claude-sonnet-5",
"modelSettings": {
"claude-sonnet-5": { "effortLevel": "xhigh" }
},
"editorMode": "vim",
"theme": "light-daltonized",
"statusLine": {
"type": "command",
"command": "jq -r '\"[\\(.model.display_name)] \\(.context_window.used_percentage // 0)% context\"'",
"padding": 2
},
"spinnerTipsEnabled": false,
"preferredNotifChannel": "terminal_bell",
"permissions": {
"allow": [
"Bash(git diff *)",
"Read(~/.zshrc)"
]
},
"autoUpdatesChannel": "stable",
"cleanupPeriodDays": 20
}

團隊的共享設定

一個團隊的共享設定,提交到版本庫,以便每個複製它的人都獲得相同的權限、hooks 和外掛程式市集。在版本庫的頂部將這樣的檔案儲存在 .claude/settings.json。提交之前需要了解的事項:

  • 雲端工作階段也會讀取它。 一個 雲端工作階段 從版本庫的複製開始,因此提交的檔案也適用於此。
  • 遙測進入受管理或個人設定。 Claude Code 會忽略版本庫設定檔案中的 OpenTelemetry 匯出器變數,除了一些關閉遙測的值。在 受管理設定 中為您的組織設定它們,或在每個人的 ~/.claude/settings.json 中設定。
  • 允許規則等待信任。 允許規則和 extraKnownMarketplaces 項目在每個人 信任此資料夾本身 後生效,不僅是父資料夾;拒絕和詢問規則在每個工作階段中適用,無論是否信任。
  • hook 是版本庫中的指令碼。 此檔案的 hook 執行 .claude/hooks/block-rm.sh;hook 如何解析 說明如何編寫它。
  • 規則匹配所寫的命令和路徑。 Bash(git push *) 不匹配 git -C . push。Read(./.env) 本身會停止檔案工具和命名檔案的命令,例如 cat .env,但不會停止 grep -r 在目錄上執行;此檔案中的 sandbox 區塊關閉了該間隙,因為沙箱 新增您的 Read 拒絕路徑 到每個沙箱化命令無法讀取的內容。

將此儲存為版本庫頂部的 .claude/settings.json 並提交。這是有效的 JSON,沒有註解,因此您可以直接貼上並刪除您不想要的鍵。

{
"permissions": {
"allow": [
"Bash(npm run *)"
],
"ask": [
"Bash(git push *)"
],
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)"
]
},
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/block-rm.sh"
}
]
}
]
},
"extraKnownMarketplaces": {
"acme-tools": {
"source": {
"source": "github",
"repo": "acme-corp/claude-plugins"
}
}
},
"enabledPlugins": {
"code-formatter@acme-tools": true
},
"sandbox": {
"enabled": true,
"filesystem": {
"allowWrite": [
"/tmp/build"
]
},
"network": {
"allowedDomains": [
"registry.npmjs.org",
"*.example.com"
]
}
},
"plansDirectory": "./plans"
}

組織的受管設定

一個 managed-settings.json 檔案,顯示受管鍵的形狀,每個都有一個合理的數值。這不是建議的政策:選擇符合您自己要求的鍵並設定您自己的數值。該範例設定這些鍵:

  • forceLoginMethod 和 forceLoginOrgUUID 固定登入方法和組織
  • availableModels 和 enforceAvailableModels 限制工作階段可以使用的模型
  • permissions.deny 拒絕兩個檔案讀取和 curl 命令 如 Claude 所寫,disableBypassPermissionsMode 移除繞過權限模式
  • allowManagedPermissionRulesOnly 和 allowManagedMcpServersOnly 使受管權限和 MCP 允許清單成為唯一適用的清單
  • allowedMcpServers 透過 URL 固定 MCP 伺服器
  • strictKnownMarketplaces 允許一個外掛程式市集
  • sandbox 沙箱化命令,具有固定的網路允許清單且無沙箱外重試
  • requiredMinimumVersion 設定最低 Claude Code 版本
  • cleanupPeriodDays 將工作階段記錄和其他本機資料的保留期縮短至七天
  • companyAnnouncements 在啟動時顯示訊息

管理員將這樣的檔案部署為 managed-settings.json,或透過 MDM 或 伺服器受管設定 部署相同的 JSON。一個部署的檔案適用於它到達的每台機器或帳戶。要為一個群組提供不同的數值,請將不同的檔案或設定檔部署到該群組,因為 伺服器受管設定尚不支援每個群組的政策。

將此部署為 managed-settings.json,或透過 MDM 或 claude.ai 主控台部署相同的 JSON。這是有效的 JSON,沒有註解;將範例組織 UUID、伺服器 URL 和市集替換為您自己的,並刪除您不想要的鍵。

{
"forceLoginMethod": "claudeai",
"forceLoginOrgUUID": [
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
],
"availableModels": [
"opus",
"sonnet"
],
"enforceAvailableModels": true,
"permissions": {
"deny": [
"Bash(curl *)",
"Read(./.env)",
"Read(./secrets/**)"
],
"disableBypassPermissionsMode": "disable"
},
"allowManagedPermissionRulesOnly": true,
"allowedMcpServers": [
{
"serverUrl": "https://api.githubcopilot.com/*"
}
],
"allowManagedMcpServersOnly": true,
"strictKnownMarketplaces": [
{
"source": "github",
"repo": "acme-corp/approved-plugins"
}
],
"sandbox": {
"enabled": true,
"failIfUnavailable": true,
"allowUnsandboxedCommands": false,
"network": {
"allowedDomains": [
"registry.npmjs.org",
"github.com"
],
"allowManagedDomainsOnly": true
}
},
"requiredMinimumVersion": "2.1.150",
"cleanupPeriodDays": 7,
"companyAnnouncements": [
"Welcome to Acme Corp! Review our code guidelines at docs.example.com"
]
}