Skip to main content

Module settings

Module settings 

Source
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 the ForgeSdkBridge.
  • 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Β§

SettingsDocuments
Three raw settings documents, each None when the underlying file is absent or unreadable. Malformed JSON also yields None - 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. None when the file is absent or unreadable.
write_then_rename πŸ”’