Real-time Sync (Dev Mode)

The envmanager dev command watches for changes in EnvManager and automatically updates your local .env file in real-time. No more manual pulls when teammates update variables.

Basic Usage

envmanager dev

This starts a daemon that:

  1. Performs an initial sync of all variables
  2. Connects to EnvManager's real-time service
  3. Updates your local .env when changes are detected
  4. Shows changes in the terminal

Output:

Dev mode started

  Project:     my-app
  Environment: development
  Output:      .env
  Strategy:    remote_wins
  Watching:    local + remote

Watching for changes. Press Ctrl+C to stop.

[14:32:05] + NEW_VAR
[14:33:12] ~ API_URL
[14:35:44] - OLD_VAR

Options

OptionDescription
-e, --environment <name>Environment name (default: from config)
-p, --project <id>Project ID (default: from config)
-o, --output <file>Output file path (default: .env)
--no-watchDisable local file watching
--strategy <type>Merge strategy (see below)

Merge Strategies

When both local and remote changes occur, the CLI uses a merge strategy to resolve conflicts.

remote_wins (default)

Remote changes always overwrite local. Best for keeping in sync with your team.

envmanager dev --strategy remote_wins

local_wins

Local changes are preserved, only new remote variables are added.

envmanager dev --strategy local_wins

merge_new

Only add new variables from remote, never modify existing local values.

envmanager dev --strategy merge_new

How It Works

  1. Initial Sync: On startup, variables are fetched and merged with your local .env
  2. Real-time Connection: A WebSocket connection is established to EnvManager
  3. Change Detection: When a variable is added, updated, or deleted remotely:
    • The CLI receives a notification
    • It fetches the full updated variable (secrets are decrypted)
    • Your local .env is updated according to the merge strategy
  4. Local Watching: By default, local .env changes are also detected (for logging)

Stopping Dev Mode

Press Ctrl+C to gracefully stop:

^C
Stopping dev mode...

Press Ctrl+C twice to force stop immediately.

Use Cases

Team Development

When multiple developers work on the same project, changes made by one developer are instantly available to others:

Developer A adds DATABASE_URL in web UI
          ↓
Developer B's terminal shows: [14:32:05] + DATABASE_URL
          ↓
Developer B's .env is automatically updated

Environment Switching

Quickly switch between environments during development:

# Work on staging
envmanager dev --environment staging

# Switch to production (in another terminal)
envmanager dev --environment production --output .env.production

Multiple Projects

Run dev mode for multiple projects simultaneously:

# Terminal 1: Backend
cd backend && envmanager dev

# Terminal 2: Frontend
cd frontend && envmanager dev

Troubleshooting

Connection Lost

If the real-time connection drops, the CLI automatically reconnects:

Disconnected from realtime
Reconnecting...
Realtime connected

Variables Not Updating

  1. Check you have access to the environment:
    envmanager list variables
    
  2. Verify the correct environment:
    envmanager config get environment
    
  3. Check the merge strategy isn't blocking updates:
    envmanager dev --strategy remote_wins
    

High CPU Usage

If file watching causes issues, disable local watching:

envmanager dev --no-watch

Get DevOps tips in your inbox

Security best practices and product updates. No spam.

No spam. Unsubscribe anytime.