Skip to main content

การตั้งค่า Claude Code

Claude Code มีการกำหนดค่าแบบ hierarchical ผ่านระบบ scope ที่กำหนดว่าการตั้งค่าใช้ที่ไหนและแชร์กับใคร การตั้งค่าจัดการผ่านคำสั่ง /config หรือแก้ไขไฟล์การกำหนดค่าโดยตรง

Configuration Scopes

Claude Code ใช้ 4 configuration scopes ตามลำดับ priority (สูงสุดถึงต่ำสุด):

  1. Managed - Server-managed, system-level settings (ไม่สามารถ override ได้)
  2. Command line arguments - Temporary session overrides
  3. Local - Personal overrides สำหรับ projects เฉพาะ (.claude/settings.local.json)
  4. Project - Team-shared settings (.claude/settings.json ใน repository)
  5. User - Personal preferences สำหรับทุก projects (~/.claude/settings.json)

ตำแหน่ง Scope และการใช้งาน

Scopeตำแหน่งใครได้รับผลแชร์กับทีม
ManagedServer/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 ให้อยู่ใน allowlist
  • fallbackModel - Fallback models เมื่อ primary ไม่พร้อมใช้งาน

Permissions & Security

  • permissions - กำหนด allow/deny rules สำหรับ tools และการเข้าถึงไฟล์
  • allowManagedPermissionRulesOnly - ใช้เฉพาะกฎจาก managed settings
  • forceLoginMethod - จำกัดให้ใช้ claudeai หรือ console accounts
  • forceLoginOrgUUID - ต้องการ Anthropic organization เฉพาะ

Features

  • alwaysThinkingEnabled - เปิดใช้ extended thinking โดยค่าเริ่มต้น
  • autoMemoryEnabled - เปิดใช้ auto memory (ค่าเริ่มต้น: true)
  • autoMode - กำหนดค่า auto mode classifier rules
  • autoCompactEnabled - Auto-compact conversations (ค่าเริ่มต้น: true)
  • fileCheckpointingEnabled - เปิดใช้ /rewind functionality (ค่าเริ่มต้น: true)

Display & UX

  • language - ภาษาที่ต้องการสำหรับ response
  • editorMode - "normal" หรือ "vim" keybindings
  • outputStyle - ปรับ system prompt output style
  • preferredNotifChannel - วิธีการแจ้งเตือน (terminal bell, desktop เป็นต้น)
  • prefersReducedMotion - ลด UI animations

Advanced

  • env - Environment variables สำหรับทุก sessions
  • hooks - Custom lifecycle event handlers
  • apiKeyHelper - Script เพื่อสร้าง auth values
  • autoMemoryDirectory - Custom memory storage location
  • claudeMd - 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 suggestions
  • blockedMarketplaces - Blocklist ของ marketplace sources
  • strictKnownMarketplaces - จำกัดเฉพาะ marketplace sources ที่รู้จัก
  • pluginTrustMessage - Custom trust warning สำหรับการติดตั้ง plugin

ไฟล์การกำหนดค่าเพิ่มเติม

  • ~/.claude.json - OAuth session, MCP servers, per-project state, caches
  • CLAUDE.md หรือ .claude/CLAUDE.md - Project-specific instructions
  • managed-settings.d/ - Drop-in directory สำหรับ policy fragments (merge ตามตัวอักษร)

Claude Code จัดการ backups ที่มี timestamp โดยอัตโนมัติ เก็บ 5 เวอร์ชันล่าสุด