README.md
dotman
A command-line tool for managing environment variables securely with password managers. Store, sync, and share environment variables across your team using your preferred secrets provider.
Features
- Secure Storage – Store environment variables in your password manager vault
- Bi-directional Sync – Push local changes to vault and pull updates from it
- Multi-environment Support – Manage dev, staging, production, and custom environments
- Password Manager Integration – Currently supports 1Password and Bitwarden, with an extensible provider system
- Load & Run – Load env vars and execute commands in one step
Installation
| 1 | npm install -g @sairajchouhan/dotman |
Or with your preferred package manager:
| 1 | # pnpm |
| 2 | pnpm add -g @sairajchouhan/dotman |
| 3 | |
| 4 | # yarn |
| 5 | yarn global add @sairajchouhan/dotman |
| 6 | |
| 7 | # bun |
| 8 | bun add -g @sairajchouhan/dotman |
Quick Start
1. Initialize a Project
Run the initialization wizard to set up your project with a password manager:
| 1 | dotman init |
This will:
- Prompt you to select a storage provider (1Password or Bitwarden)
- Guide you through entering required credentials
- Create or update your
.envfile with configuration - Create a project in your vault to store environment variables
2. Push Environment Variables
Push your local environment variables to the vault:
| 1 | # Preview changes first |
| 2 | dotman push |
| 3 | |
| 4 | # Apply changes to vault |
| 5 | dotman push --apply |
3. Pull Environment Variables
Sync environment variables from the vault to your local .env file:
| 1 | # Preview changes first |
| 2 | dotman pull |
| 3 | |
| 4 | # Apply changes locally |
| 5 | dotman pull --apply |
4. Run Commands with Loaded Environment
Load environment variables and run a command:
| 1 | dotman load -- npm run dev |
| 2 | dotman load -- node server.js |
Commands
dotman init
Initialize a new project with a password manager integration.
| 1 | dotman init |
The wizard will guide you through:
- Selecting a storage provider
- Configuring vault/project settings
- Setting up authentication tokens
dotman push
Push local environment variables to the vault.
| 1 | # Preview what will be pushed |
| 2 | dotman push |
| 3 | |
| 4 | # Push changes (for a specific environment) |
| 5 | dotman push -e dev --apply |
Options:
-e, --env <ENV>– Target environment (e.g., dev, stag, prod)-a, --apply– Apply the changes (without this flag, only shows a preview)
dotman pull
Pull environment variables from the vault to local .env file.
| 1 | # Preview what will be pulled |
| 2 | dotman pull |
| 3 | |
| 4 | # Pull changes (for a specific environment) |
| 5 | dotman pull -e prod --apply |
Options:
-e, --env <ENV>– Target environment-a, --apply– Apply the changes locally
dotman load
Load environment variables from .env files and run a command.
| 1 | dotman load -- <command> |
| 2 | |
| 3 | # Examples |
| 4 | dotman load -- npm run dev |
| 5 | dotman load -- python app.py |
| 6 | dotman load -e prod -- node server.js |
Options:
-e, --env <ENV>– Environment to load
dotman env
Manage environments.
dotman env list
List all available environments:
| 1 | dotman env list |
Output:
| 1 | Available Environments: |
| 2 | ★ dev (current) |
| 3 | • stag |
| 4 | • prod (.env) |
| 5 | |
| 6 | 3 environments found |
dotman env new <name>
Create a new environment:
| 1 | dotman env new staging |
This creates:
- A new
.env.stagingfile with placeholders - A corresponding project/section in your vault
dotman env use <name>
Switch to a different environment:
| 1 | dotman env use production |
Provider Setup
1Password
To use 1Password as your storage provider, you'll need:
| Variable | Description |
|---|---|
DOTMAN_PROJECT_NAME | Your project name |
OP_VAULT_NAME | The 1Password vault to use |
OP_SERVICE_ACCOUNT_TOKEN | Service account token for authentication |
Getting a Service Account Token:
- Go to 1Password.com → Settings → Developer → Service Accounts
- Create a new service account with access to your vault
- Copy the token
📖 1Password Service Accounts Documentation
Bitwarden
To use Bitwarden as your storage provider, you'll need:
| Variable | Description |
|---|---|
DOTMAN_PROJECT_NAME | Your project name |
BWS_ACCESS_TOKEN | Bitwarden Secrets Manager access token |
BWS_ORGANIZATION_ID | Your organization ID |
BWS_API_URL | API URL (optional, for self-hosted) |
BWS_IDENTITY_URL | Identity URL (optional, for self-hosted) |
Getting an Access Token:
- Go to Bitwarden → Organizations → Secrets Manager → Access Tokens
- Create a new access token for your project
📖 Bitwarden Access Tokens Documentation
Environment Files
dotman uses a simple naming convention:
| File | Description |
|---|---|
.env | Master file with provider configuration |
.env.<name> | Any environment name you choose |
The part after .env. becomes the environment name. For example:
.env.dev→ environment name isdev.env.staging→ environment name isstaging.env.production→ environment name isproduction.env.local-test→ environment name islocal-test
About the Master .env File
The master .env file primarily stores the configuration keys needed to connect to your secrets provider (like OP_SERVICE_ACCOUNT_TOKEN for 1Password or BWS_ACCESS_TOKEN for Bitwarden).
While you can add application-specific variables to the master .env file and they will be loaded alongside your environment-specific variables, it's recommended to create a separate environment (e.g., .env.dev, .env.local) for your application variables. This keeps things cleaner and makes it easier to:
- Manage different configurations per environment
- Share environment-specific secrets with your team via the vault
- Avoid confusion between provider config and app variables
Note: All
.env*files should be added to.gitignoreand never committed to version control.
Workflow Example
Here's a typical team workflow:
| 1 | # Initial setup (one-time) |
| 2 | dotman init |
| 3 | |
| 4 | # During development |
| 5 | dotman env use dev |
| 6 | dotman pull --apply # Get latest env vars |
| 7 | dotman load -- npm run dev # Run with loaded env |
| 8 | |
| 9 | # Add new variables |
| 10 | echo "NEW_API_KEY=abc123" >> .env.dev |
| 11 | dotman push --apply # Share with team |
| 12 | |
| 13 | # Deploy to production |
| 14 | dotman env use prod |
| 15 | dotman pull --apply |
| 16 | dotman load -- npm start |
Security Notes
- Never commit environment files – Add
.env*to your.gitignoreto exclude all env files (.env,.env.dev,.env.prod, etc.) - Use service accounts – Create dedicated tokens with minimal permissions
- Rotate tokens regularly – Update your service account tokens periodically
- The provider tokens (like
OP_SERVICE_ACCOUNT_TOKEN) are stored locally in your.envfile
Development
| 1 | # Install dependencies |
| 2 | pnpm install |
| 3 | |
| 4 | # Run in development |
| 5 | pnpm dev |
| 6 | |
| 7 | # Build |
| 8 | pnpm build |
| 9 | |
| 10 | # Run tests |
| 11 | pnpm test |
| 12 | |
| 13 | # Format code |
| 14 | pnpm format |
| 15 | |
| 16 | # Lint and fix |
| 17 | pnpm check:write |
License
MIT