การตั้งค่า Claude Code
Claude Code มีการกำหนดค่าแบบ hierarchical ผ่านระบบ scope ที่กำหนดว่าการตั้งค่าใช้ที่ไหนและแชร์กับใคร การตั้งค่าจัดการผ่านคำสั่ง /config หรือแก้ไขไฟล์การกำหนดค่าโดยตรง
Configuration Scopes
Claude Code ใช้ 4 configuration scopes ตามลำดับ priority (สูงสุดถึงต่ำสุด):
- Managed - Server-managed, system-level settings (ไม่สามารถ override ได้)
- Command line arguments - Temporary session overrides
- Local - Personal overrides สำหรับ projects เฉพาะ (
.claude/settings.local.json) - Project - Team-shared settings (
.claude/settings.jsonใน repository) - User - Personal preferences สำหรับทุก projects (
~/.claude/settings.json)
ตำแหน่ง Scope และการใช้งาน
| Scope | ตำแหน่ง | ใครได้รับผล | แชร์กับทีม |
|---|---|---|---|
| Managed | Server/plist/registry/managed-settings.json | ผู้ใช้ทั้งหมดในเครื่อง | ใช่ (IT deployed) |
| User | ~/.claude/ | คุณ ทุก projects | ไม่ |
| Project | .claude/ ใน repository | ผู้ร่วมทีมทั้งหมด | ใช่ (git committed) |
| Local | .claude/settings.local.json | คุณ เฉพาะ repo นี้ | ไม่ (gitignored) |
เมื่อไหรควรใช้แต่ละ Scope
- Managed: Organization-wide security policies, compliance requirements
- User: Personal preferences, themes, API keys, tools ที่ใช้ทุกที่
- Project: Team-shared settings, plugins, MCP servers, standardized tooling
- Local: Personal overrides, testing configurations, machine-specific settings
Settings Files
ตำแหน่งไฟล์
User settings: ~/.claude/settings.json
Project settings: .claude/settings.json (checked in)
Local settings: .claude/settings.local.json (gitignored)
Managed settings:
- macOS: /Library/Application Support/ClaudeCode/
- Linux/WSL: /etc/claude-code/
- Windows: C:\Program Files\ClaudeCode\
MCP servers: ~/.claude.json (user) or .mcp.json (project)
ตัวอย่าง settings.json
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"permissions": {
"allow": [
"Bash(npm run lint)",
"Bash(npm run test *)",
"Read(~/.zshrc)"
],
"deny": [
"Bash(curl *)",
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)"
]
},
"env": {
"CLAUDE_CODE_ENABLE_TELEMETRY": "1",
"OTEL_METRICS_EXPORTER": "otlp"
},
"companyAnnouncements": [
"Welcome to Acme Corp! Review our code guidelines at docs.acme.com"
]
}
Key Settings
การกำหนดค่า Model
model- Override default model (ใช้/modelเพื่อเปลี่ยนใน session)availableModels- จำกัด models ที่ผู้ใช้สามารถเลือกได้enforceAvailableModels- จำกัด Default model ให้อยู่ใน allowlistfallbackModel- Fallback models เมื่อ primary ไม่พร้อมใช้งาน
Permissions & Security
permissions- กำหนด allow/deny rules สำหรับ tools และการเข้าถึงไฟล์allowManagedPermissionRulesOnly- ใช้เฉพาะกฎจาก managed settingsforceLoginMethod- จำกัดให้ใช้claudeaiหรือconsoleaccountsforceLoginOrgUUID- ต้องการ Anthropic organization เฉพาะ
Features
alwaysThinkingEnabled- เปิดใช้ extended thinking โดยค่าเริ่มต้นautoMemoryEnabled- เปิดใช้ auto memory (ค่าเริ่มต้น:true)autoMode- กำหนดค่า auto mode classifier rulesautoCompactEnabled- Auto-compact conversations (ค่าเริ่มต้น:true)fileCheckpointingEnabled- เปิดใช้/rewindfunctionality (ค่าเริ่มต้น:true)
Display & UX
language- ภาษาที่ต้องการสำหรับ responseeditorMode-"normal"หรือ"vim"keybindingsoutputStyle- ปรับ system prompt output stylepreferredNotifChannel- วิธีการแจ้งเตือน (terminal bell, desktop เป็นต้น)prefersReducedMotion- ลด UI animations
Advanced
env- Environment variables สำหรับทุก sessionshooks- Custom lifecycle event handlersapiKeyHelper- Script เพื่อสร้าง auth valuesautoMemoryDirectory- Custom memory storage locationclaudeMd- Organization-wide CLAUDE.md instructions (managed only)
Settings Precedence & Reloading
การตั้งค่าส่วนใหญ่โหลดใหม่แบบ real-time เมื่อไฟล์เปลี่ยนแปลง อย่างไรก็ตาม สิ่งเหล่านี้ต้องการ restart:
model(ใช้/modelแทน)outputStyle(rebuild เมื่อ/clearหรือ restart)
Plugin และ Marketplace Controls
pluginSuggestionMarketplaces- ชื่อ marketplace สำหรับ plugin suggestionsblockedMarketplaces- Blocklist ของ marketplace sourcesstrictKnownMarketplaces- จำกัดเฉพาะ marketplace sources ที่รู้จักpluginTrustMessage- Custom trust warning สำหรับการติดตั้ง plugin
ไฟล์การกำหนดค่าเพิ่มเติม
~/.claude.json- OAuth session, MCP servers, per-project state, cachesCLAUDE.mdหรือ.claude/CLAUDE.md- Project-specific instructionsmanaged-settings.d/- Drop-in directory สำหรับ policy fragments (merge ตามตัวอักษร)
Claude Code จัดการ backups ที่มี timestamp โดยอัตโนมัติ เก็บ 5 เวอร์ชันล่าสุด