Class: AgentSettings::Adapters::Claude

Inherits:
Object
  • Object
show all
Defined in:
lib/agent_settings/adapters/claude.rb

Overview

Adapter for Claude Code agent configuration.

Claude Code stores configuration in JSON files at various locations:

  • Global: ~/.claude/settings.json (user-level config)
  • Project: .claude/settings.json (project-level config)
  • Local: .claude/settings.local.json (local overrides, not committed)
  • Managed: /Library/Application Support/ClaudeCode/managed-settings.json (macOS system-level)

Precedence (highest to lowest): managed > local > project > global

Environment variable CLAUDE_CONFIG_DIR can override the global config location.

Examples:

adapter = Claude.new
layers = adapter.layers(dir: "/work/my_app", env: ENV, trusted: true)
env_overrides = adapter.env_overrides(dir: "/work/my_app", env: ENV, trusted: true)

Instance Method Summary collapse

Instance Method Details

#env_overrides(dir:, env:, trusted:) ⇒ Array<EnvOverride>

Get environment variable overrides for Claude Code.

Checks for CLAUDE_CONFIG_DIR environment variable and returns an EnvOverride if it's set. The override is active if the resulting settings.json file exists.

Parameters:

  • dir (String)

    project directory path (unused)

  • env (Hash)

    environment variables hash

  • trusted (Boolean)

    whether the project is trusted (unused)

Returns:

  • (Array<EnvOverride>)

    detected environment overrides



47
48
49
# File 'lib/agent_settings/adapters/claude.rb', line 47

def env_overrides(dir:, env:, trusted:) # rubocop:disable Lint/UnusedMethodArgument
  build_env_overrides(env)
end

#layers(dir:, env:, trusted:) ⇒ Array<Location>

Get all config layers for Claude Code.

Returns an array of Location objects representing all possible config file locations, ordered by precedence (highest first). Only one layer will be marked as active (the first existing one).

Parameters:

  • dir (String)

    project directory path

  • env (Hash)

    environment variables hash

  • trusted (Boolean)

    whether the project is trusted (unused for Claude)

Returns:

  • (Array<Location>)

    config layers in precedence order



33
34
35
# File 'lib/agent_settings/adapters/claude.rb', line 33

def layers(dir:, env:, trusted:) # rubocop:disable Lint/UnusedMethodArgument
  build_layers(dir, env)
end

#warningsArray<String>

Get warnings for Claude Code configuration.

Claude Code doesn't produce any warnings currently.

Returns:

  • (Array<String>)

    empty array



56
# File 'lib/agent_settings/adapters/claude.rb', line 56

def warnings(*) = []