A secure command-line utility for managing secrets in macOS Keychain with seamless .env file integration.
- Secure Storage: Store sensitive data in macOS Keychain instead of plain text files
- Environment Integration: Seamlessly resolve
keychain://placeholders in.envfiles - Clipboard Management: Copy secrets to clipboard with automatic clearing after 45 seconds
- Pattern Matching: List and search secrets using wildcards
- Simple CLI: Intuitive commands for adding, removing, and managing secrets
- Zero Dependencies: Pure bash script using native macOS security tools
# Add the tap
brew tap tyom/kcm
# Install kcm
brew install kcm# Download the script
curl -O https://raw.githubusercontent.com/tyom/homebrew-kcm/main/kcm
# Make it executable
chmod +x kcm
# Move to your PATH
sudo mv kcm /usr/local/bin/Add a secret to the Keychain and get the .env entry:
# Interactive mode (prompts for value)
kcm add DATABASE_URL
# From stdin
echo "secret-value" | kcm add TOKEN -
cat ~/secret-file.txt | kcm add AWS_SECRET -After adding, you'll get a .env entry like:
DATABASE_URL="keychain://DATABASE_URL"
Run any command with secrets from your .env file automatically resolved:
# Use default .env file
kcm use -- npm run dev
# Specify a custom env file
kcm use --env-file .env.production -- node server.js
# Access resolved variables in scripts
kcm use -- bash -c 'echo $DATABASE_URL'# Show a secret value
kcm show DATABASE_URL
# Copy to clipboard (auto-clears after 45 seconds)
kcm copy API_KEY
# List all accessible secrets
kcm ls
# List secrets matching a pattern
kcm ls "DATABASE*"
kcm ls "*_KEY"
# Note: Only shows secrets that kcm can access
# Some app-specific secrets may have access restrictions
# Remove a secret
kcm remove OLD_API_KEYYour .env files can use the special keychain:// prefix to reference Keychain secrets:
# .env example
DATABASE_URL="keychain://DATABASE_URL"
API_KEY="keychain://API_KEY"
REDIS_URL="keychain://REDIS_URL"
# Regular values work too
PORT=3000
NODE_ENV=developmentWhen you run kcm use -- <command>, all keychain:// references are automatically resolved from the Keychain.
Secrets stored in macOS Keychain with OS-level encryption. Auto-clearing clipboard, input validation, safe parsing.
See SECURITY.md for full security policy, best practices, and limitations.
# Add your database credentials
kcm add DATABASE_URL
# Add your API keys
kcm add STRIPE_KEY
kcm add SENDGRID_KEY
# Create your .env file
cat > .env << EOF
DATABASE_URL="keychain://DATABASE_URL"
STRIPE_KEY="keychain://STRIPE_KEY"
SENDGRID_KEY="keychain://SENDGRID_KEY"
PORT=3000
EOF
# Run your application
kcm use -- npm run dev# Store deployment credentials
kcm add AWS_ACCESS_KEY_ID
kcm add AWS_SECRET_ACCESS_KEY
# Deploy script
kcm use --env-file .env.deploy -- ./deploy.shShare .env files with keychain:// placeholders in your repository. Each team member stores their own credentials locally:
# Team member setup
git clone https://github.com/yourteam/project
cd project
# Each member adds their own credentials
kcm add DATABASE_URL # Enter their dev database URL
kcm add API_KEY # Enter their personal API key
# Everyone can now run the app with their own credentials
kcm use -- npm start- macOS (uses native
securitycommand) - Bash 4.0 or higher
- Access to macOS Keychain
When using kcm for the first time or accessing certain secrets, macOS will display a security dialog asking for your password or Touch ID. This is normal behavior - macOS is protecting your Keychain and requires your authorization to allow kcm to access stored secrets.
You may see prompts like:
- "kcm wants to use your confidential information stored in [KEY_NAME] in your keychain"
- You can click "Always Allow" to avoid repeated prompts for the same secret
If you encounter permission errors, ensure you have access to the login keychain:
security list-keychainsYou can verify entries directly using macOS security command:
security find-generic-password -s "YOUR_KEY_NAME" -wIf a secret seems stuck or corrupted:
# Remove using kcm
kcm remove KEY_NAME
# Or remove directly via security command
security delete-generic-password -s "KEY_NAME"See RELEASE.md for release process.
See ARCHITECTURE.md for technical design and implementation details.
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details
Created by Tyom Semonov
Built with ♥︎ using native macOS security tools for maximum compatibility and security.