Secure credential management for Claude API - inspired by aws-vault
claude-vault is a CLI tool for managing multiple Claude API credentials with automatic profile detection and secure keychain storage.
- π Secure Storage: API keys and OAuth tokens stored in macOS Keychain (Linux/Windows support coming soon)
- π« OAuth Support: Import and manage OAuth tokens from Claude Code for subscription accounts
- π Multiple Profiles: Manage personal, work, and project-specific Claude accounts
- π― Auto-Detection: Automatically detect profiles from
.claude-profilefiles - β‘ Command Execution: Run commands with profile credentials via
execandenv - π Claude Code Integration: Automatically switches Claude Code keychain to use selected profile (β¨ NEW!)
- π Auto Token Refresh: Automatically refreshes expired OAuth tokens
- π Shell Completion: Tab completion for Bash, Zsh, and Fish
- β¨ Simple CLI: Intuitive commands for profile management
- π¦ Smart Caching: Performance-optimized profile detection with intelligent caching
- π§ͺ Well-Tested: Comprehensive test coverage (26 passing tests)
git clone https://github.com/rtzr/claude-vault.git
cd claude-vault
cargo build --release
sudo mv target/release/claude-vault /usr/local/bin/brew install claude-vaultEnable tab completion for your shell:
Bash
# Generate completion script
claude-vault completion bash > ~/.local/share/bash-completion/completions/claude-vault
# Or add to your ~/.bashrc
echo 'eval "$(claude-vault completion bash)"' >> ~/.bashrcZsh
# Generate completion script
claude-vault completion zsh > ~/.zsh/completions/_claude-vault
# Or add to your ~/.zshrc
echo 'eval "$(claude-vault completion zsh)"' >> ~/.zshrc
# Make sure completion system is initialized
echo 'autoload -Uz compinit && compinit' >> ~/.zshrcFish
# Generate completion script
claude-vault completion fish > ~/.config/fish/completions/claude-vault.fishclaude-vault add personal
# Enter your Claude API key when promptedclaude-vault listclaude-vault default personal# First, login to Claude Code
claude /login
# Then import the OAuth token
claude-vault import oauth --profile subscription# Add with name only
claude-vault add work
# Add with description
claude-vault add work --description "Company account"claude-vault listOutput:
Profiles:
β’ personal - Personal projects
Last used: 2025-11-10T12:30:00Z
β’ work - Company account
claude-vault show personal# With confirmation
claude-vault remove work
# Skip confirmation
claude-vault remove work --yesclaude-vault default personalIf you have a Claude Pro/Max subscription and use Claude Code, you can import your OAuth token:
# First, login to Claude Code to get a fresh token
claude /login
# Import the OAuth token to a profile
claude-vault import oauth --profile subscription
# Or use default profile name if not specified
claude-vault import oauthNote: OAuth tokens expire periodically. When your token expires, simply run claude /login in Claude Code and re-import:
claude /login
claude-vault import oauth --profile subscription# Execute command with detected/default profile
claude-vault exec claude --version
# Execute command with specific profile
claude-vault exec --profile work claude --model sonnet "Hello world"
# Use in scripts
claude-vault exec npm run testπ Claude Code Integration:
When using OAuth profiles, claude-vault exec automatically switches Claude Code's keychain to use the selected profile:
# Using rtzr (max) profile with Claude Code
claude-vault exec --profile rtzr claude "Hello from max subscription!"
# Using personal (pro) profile with Claude Code
claude-vault exec --profile personal claude "Hello from pro subscription!"
# After execution, automatically restores original Claude Code keychainThis allows you to seamlessly switch between multiple Claude subscription accounts without manual /logout and /login.
# Export for shell integration
eval $(claude-vault env)
# Export specific profile
eval $(claude-vault env --profile work)Create a .claude-profile file in your project root:
# In your work project
cd ~/work/my-project
echo "work" > .claude-profile
# In your personal project
cd ~/personal/side-project
echo "personal" > .claude-profileNow when you run Claude Code or other tools, claude-vault can automatically detect and use the appropriate profile.
Configuration is stored in ~/.claude-vault/config.toml:
version = "1.0"
default_profile = "personal"
[[profiles]]
name = "personal"
description = "Personal projects"
credential_type = "api-key"
created_at = "2025-11-10T12:00:00Z"
[[profiles]]
name = "subscription"
description = "Claude Pro subscription"
credential_type = "oauth"
created_at = "2025-11-10T14:30:00Z"
expires_at = "2025-11-17T14:30:00Z"Credentials are securely stored in your system keychain:
- macOS: Keychain Access (separate entries for API keys and OAuth tokens)
- Linux: Secret Service API (coming soon)
- Windows: Windows Credential Manager (coming soon)
The tool supports two types of credentials:
- API Keys: For Pay-as-you-go accounts (format:
sk-ant-...) - OAuth Tokens: For Claude Pro/Max subscription accounts (imported from Claude Code)
- Rust 1.70+
- macOS 12+ (for MVP)
cargo buildcargo testcargo run -- add test
cargo run -- list- MVP: Core profile management
- macOS Keychain integration
- Basic CLI commands
- Automatic profile detection (
.claude-profile) -
execcommand for command execution -
envcommand for shell integration - Shell completion scripts (Bash, Zsh, Fish)
- OAuth token support for subscription accounts
- Automatic token refresh for OAuth tokens
- Claude Code keychain integration (automatic profile switching)
- Linux support (for OAuth tokens)
- Windows support
- Homebrew formula
- Usage statistics
- Team features
Comprehensive guides and best practices:
- π Usage Guide - Advanced usage scenarios and workflows
- π Claude Code Integration - Integrate with Claude Code seamlessly
- π§ Troubleshooting - Common issues and solutions
- β¨ Best Practices - Security and operational best practices
- β FAQ - Frequently asked questions
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details
Inspired by aws-vault - the excellent credential management tool for AWS.
Status: β¨ MVP Complete - Ready for Use
Built with Rust π¦