Usage Examples
Basic Usage
Section titled “Basic Usage”Initialize with Manual Folder Entry
Section titled “Initialize with Manual Folder Entry”cd /your/projectbwenv init# Enter folder name when prompted: "Production Secrets"direnv allowInteractive Folder Selection
Section titled “Interactive Folder Selection”cd /your/projectbwenv interactive# Select folder by number from the listdirenv allowDebug Modes
Section titled “Debug Modes”bwenv supports different debug levels to help you understand what’s happening:
Default Mode (Steps Only)
Section titled “Default Mode (Steps Only)”bwenv init# Shows: Processing steps, hides secret valuesSilent Mode
Section titled “Silent Mode”bwenv --quiet init# orbwenv -q init# Shows: Minimal output, errors onlyFull Debug Mode
Section titled “Full Debug Mode”bwenv --debug=2 init# orbwenv --debug init# Shows: Processing steps AND actual secret valuesDebug with direnv
Section titled “Debug with direnv”# Set debug level for direnv operationsBWENV_DEBUG=1 direnv allow # Steps onlyBWENV_DEBUG=2 direnv allow # Full debugBWENV_DEBUG=0 direnv allow # SilentReal-World Examples
Section titled “Real-World Examples”Example 1: Web Development Project
Section titled “Example 1: Web Development Project”# Navigate to your web projectcd ~/projects/my-webapp
# Use interactive mode to select "Web App Secrets" folderbwenv interactive# Select: 3) Web App Secrets
# Activate environmentdirenv allow
# Your secrets are now availableecho $DATABASE_URLecho $API_KEYecho $JWT_SECRET
# Start your development servernpm run devExample 2: Multiple Environments
Section titled “Example 2: Multiple Environments”# Development environmentcd ~/projects/myapp-devbwenv init # Select "MyApp - Development"direnv allow
# Staging environmentcd ~/projects/myapp-stagingbwenv init # Select "MyApp - Staging"direnv allow
# Production deploymentcd ~/projects/myapp-prodbwenv init # Select "MyApp - Production"direnv allowExample 3: CI/CD Pipeline
Section titled “Example 3: CI/CD Pipeline”# In your CI/CD scriptcd $WORKSPACE
# Use quiet mode for automated environmentsbwenv --quiet init --folder "CI/CD Secrets"direnv allow
# Run your deployment./deploy.shAdvanced Usage
Section titled “Advanced Usage”Custom Environment Variables
Section titled “Custom Environment Variables”Your Bitwarden items should have custom fields that will become environment variables:
Bitwarden Item: “Database Config”
- Custom Field:
DATABASE_URL→postgresql://user:pass@host:5432/db - Custom Field:
DB_POOL_SIZE→20 - Custom Field:
DB_TIMEOUT→30
After running bwenv init and direnv allow:
echo $DATABASE_URL # postgresql://user:pass@host:5432/dbecho $DB_POOL_SIZE # 20echo $DB_TIMEOUT # 30Working with Teams
Section titled “Working with Teams”- Shared Folder Structure: Organize secrets in Bitwarden folders by project/environment
- Consistent Naming: Use consistent custom field names across team
- Documentation: Document which folder contains which secrets
# Team folder structure example:# - "ProjectX - Development"# - "ProjectX - Staging"# - "ProjectX - Production"# - "Shared Tools"
# Each team member can use:bwenv interactive # Select appropriate folderDebugging Issues
Section titled “Debugging Issues”# Test your setupbwenv test
# Check what's in your .envrccat .envrc
# Debug direnv loadingBWENV_DEBUG=2 direnv allow
# Verify Bitwarden sessionbw status
# List available foldersbw list foldersCleanup
Section titled “Cleanup”Remove Secrets from Project
Section titled “Remove Secrets from Project”bwenv remove# Removes .envrc file from current directoryClear Bitwarden Session
Section titled “Clear Bitwarden Session”bw lock# Locks your Bitwarden sessionTips and Best Practices
Section titled “Tips and Best Practices”Security Best Practices
Section titled “Security Best Practices”- Always lock Bitwarden when done:
bw lock - Use specific folders: Don’t put everything in one folder
- Regular rotation: Rotate secrets regularly
- Team access: Use Bitwarden organizations for team access
Development Workflow
Section titled “Development Workflow”- Per-environment folders: Separate dev/staging/prod secrets
- Consistent field names: Use same variable names across environments
- Version control: Add
.envrcto.gitignore - Team onboarding: Document which folders new team members need
Troubleshooting Workflow
Section titled “Troubleshooting Workflow”# 1. Test installationbwenv test
# 2. Check Bitwarden statusbw status
# 3. List folders (debug what's available)bw list folders
# 4. Try with full debugbwenv --debug=2 interactive
# 5. Check direnvdirenv status