Expand description
Settings document accessors - read the three Claude Code
configuration files. Reads return raw serde_json::Value
documents; consumers own the merge / precedence semantics.
Resolution rules match the claude CLI as of 2.1.117:
- User settings at
<config_dir>/settings.json.<config_dir>is the path the caller passes - typically the per-spawn account binding stored on theForgeSdkBridge. - Project-local settings at
<cwd>/.claude/settings.local.json. Tied to the projectβs working directory;<config_dir>does not affect this path. - User preferences at
$HOME/.claude.json(note the leading dot - this is a file at the home root, not a directory under it). Per-user preferences (notification channel, gitignore respect, terminal-progress-bar, etc.);<config_dir>does not affect this either.
Re-exportsΒ§
use std::io::Write as _;πuse std::path::Path;πuse std::path::PathBuf;πuse serde_json::Value;π
StructsΒ§
- Settings
Documents - Three raw settings documents, each
Nonewhen the underlying file is absent or unreadable. Malformed JSON also yieldsNone- consumers that care about distinguishing missing vs. corrupt should re-read directly.
FunctionsΒ§
- home_
dir π - read_
json_ πfile - resolve_
symlink π - Walk a symlink chain to the file it ultimately names, resolving each
relative target against its own linkβs parent. Not
canonicalize, which fails on a dangling link: a link whose target is missing should still resolve, so the write recreates the canonical file rather than clobbering the link. - save_
document - Write one settings document, leaving the file it replaces whole.
- settings_
documents - Read the three Claude Code settings documents from disk.
- unique_
temp_ πpath - user_
preferences - The per-user preferences document alone, for a reader that wants
nothing else out of it.
Nonewhen the file is absent or unreadable. - write_
then_ πrename