claude_profile
Claude Code account credential management.
Files
| File / Directory | Responsibility |
|---|---|
Cargo.toml |
Crate manifest: dependencies, features, metadata |
src/ |
Library modules and CLI binary (account, token, paths, adapter, commands) |
tests/ |
Test suite for credential management |
docs/ |
Behavioral requirements: features (FR-6–FR-18), invariants, CLI reference |
unilang.commands.yaml |
YAML command metadata for 10 profile commands |
vision.md |
Crate vision, design decisions, and open problems |
vision_ua.md |
Crate vision in Ukrainian |
changelog.md |
Notable changes by version |
Responsibility Table
| Entity | Responsibility | Input→Output | Scope | Out of Scope |
|---|---|---|---|---|
account |
Named credential storage and rotation | name → active credentials | Save, list, switch, delete accounts | ❌ OAuth HTTP refresh → network dep❌ Browser launch → caller |
token |
Active OAuth token expiry status | credentials file → TokenStatus |
Read expiresAt, classify Valid/ExpiringSoon/Expired |
❌ Token refresh → HTTP❌ Server-side window → unobservable |
paths |
~/.claude/ file topology |
HOME → canonical PathBufs |
All ~/.claude/ path constants |
❌ Process execution |
persist |
Persistent user storage path resolution | $PRO/$HOME → PathBuf |
Resolve $PRO/persistent/claude_profile/ with $HOME fallback (FR-15) |
❌ Writing data → caller |
Scope
In Scope:
- Account credential snapshots in
~/.claude/accounts/ - Token expiry detection from
~/.claude/.credentials.json - All canonical
~/.claude/paths viaClaudePaths - Persistent user storage path resolution via
PersistPaths($PRO/$HOME)
Out of Scope:
- ❌ Claude Code process execution →
claude_runner_core - ❌ Continuation detection (session file existence) →
claude_storage_core - ❌ Session directory management →
claude_runner_core::SessionManager - ❌ Pulse keeping (periodic
claudeinvocation) → caller +claude_runner - ❌ Browser launch /
xdg-open→ caller - ❌ OAuth HTTP token refresh → network dependency not allowed
- ❌ Server-side 5-hour subscription window → not locally observable
Account Management
use ;
// Where are the files?
let p = new.expect;
println!;
println!;
println!;
// Check active token status
match status.expect
// List all stored accounts
for acct in list.expect
// Save current credentials as "work"
save.expect;
// Switch to "personal"
switch_account.expect;
// Delete an old account
delete.expect;
File Paths
use ClaudePaths;
let p = new.expect;
println!;
println!;
println!;
println!;
println!;
println!;
println!;
Binary
Two names, same binary — both claude_profile and clp are installed:
Testing