Claude Settings
A Rust library for reading and writing Claude Code settings on Unix-like systems.
Overview
Claude Code uses a hierarchical settings system with multiple levels:
- System (
/etc/claude-code/managed-settings.json) - Read-only, highest priority - Project Local (
.claude/settings.local.json) - Project-specific, not version controlled - Project (
.claude/settings.json) - Project-specific, version controlled - User (
~/.claude/settings.json) - User defaults, lowest priority
This library provides:
- Type-safe settings structures with serde serialization
- Read/write operations for each settings level
- Automatic path resolution based on project structure
- Settings merging with proper precedence handling
Quick Start
use ;
// Create a settings manager
let manager = new;
// Read user settings
if let Ok = manager.read
// Write project settings
let settings = new
.with_model
.with_permissions;
manager.write.unwrap;
// Get effective settings (merged from all levels)
let effective = manager.effective.unwrap;
Settings Structure
The main [Settings] struct supports all Claude Code configuration options:
permissions- Tool permission rules (allow/ask/deny)env- Environment variables for tool executionmodel- Override the default Claude modelhooks- Pre/post tool execution hookssandbox- Command sandboxing configurationattribution- Git commit/PR attribution messagesenabled_plugins- Plugin enable/disable mapcleanup_period_days- Session cleanup periodlanguage- Preferred response language
Structured Permissions
The [permission] module provides structured permission parsing and querying:
use ;
// Parse permission patterns
let perm = parse.unwrap;
assert!;
// Build a permission set
let set = new
.allow
.deny;
// Query permissions
assert_eq!;
assert_eq!;
Figment Integration
Use [merge::FigmentLoader] for advanced configuration merging:
use FigmentLoader;
let loader = with_defaults;
let settings = loader.load.unwrap;
Scoped Settings (Context Manager)
Use [SettingsGuard] for temporary modifications that auto-restore:
use ;
let manager = new;
// Make temporary changes that auto-restore when guard drops
// Original settings automatically restored
# Ok::