Expand description
Read-side access to Claude Code’s on-disk settings files.
Claude Code reads up to four JSON files in increasing order of precedence (later layers override earlier ones):
~/.claude/settings.json– user defaults~/.claude/settings.local.json– user-private overrides<project>/.claude/settings.json– project-shared (checked into version control)<project>/.claude/settings.local.json– project-private overrides (typically gitignored)
Plus a managed (enterprise) layer that lives outside these paths and isn’t covered here.
This module reads each layer as opaque serde_json::Value and
returns them side-by-side, without merging. Claude Code’s
merge semantics are non-trivial and not fully documented (some
object fields deep-merge, some arrays concatenate, some replace),
and reproducing them here would risk diverging from the binary’s
actual behavior in subtle ways. Callers who want an “effective”
view can apply their own merge with full knowledge of which
source produced which value – the per-layer split makes that
attribution possible.
§What’s in a settings file
Field names worth knowing (not exhaustive; survives unknown keys since values are kept as raw JSON):
env– environment variables passed to spawnedclaudesubprocesses. Often contains secrets (ANTHROPIC_API_KEY, tokens, etc.). Useredact_env_valuesbefore forwarding to a less-trusted consumer.permissions–{ allow: [...], deny: [...] }Bash-pattern and tool-name allow/deny lists.hooks– map keyed by hook event (PreToolUse,PostToolUse,UserPromptSubmit, etc.); values are arrays of shell-command hook configs.statusLine– statusline command config.enabledPlugins– map of plugin keys to enabled state.enableAllProjectMcpServers,enabledMcpjsonServers– MCP server gates.
§Example
use claude_wrapper::settings::SettingsLoader;
let layers = SettingsLoader::home()?
.project_root("/path/to/repo")
.load()?;
if let Some(user) = &layers.user {
println!("user settings present: {} top-level keys",
user.as_object().map(|o| o.len()).unwrap_or(0));
}Structs§
- Settings
- Parsed settings layers as returned by
SettingsLoader::load. - Settings
Loader - Builder/loader for the settings layers.
- Settings
Paths - Absolute paths the loader would read, regardless of which files
exist. Returned alongside
Settingsso diagnostics can show “the project layer would come from<path>” even when the file isn’t there.
Enums§
- Settings
Layer - One of the four settings layers Claude Code can read.
Functions§
- redact_
env_ values - Replace every value under the top-level
envobject with"<redacted>", keeping the keys visible. Safe to call on any JSON value, including non-objects and objects without anenvfield. Other top-level keys (permissions,hooks, etc.) are left untouched.