NodeOps
UK

Guide

Managing Environment Variables from the Command Line

CLI tools let you set, list, remove, and sync environment variables directly from the terminal. The best tools support pulling remote variables to a local .env file and pushing local files to remote, so your development and production environments stay in sync.

The problem

Environment variables are the standard way to configure applications across environments. But managing them usually means logging into a dashboard, navigating to settings, editing one at a time, and hoping you did not miss one. Syncing between local development and production is even worse.

The problem with dashboard-based env var management

Editing environment variables through a web UI is slow, error-prone, and unscriptable. You cannot automate it in CI/CD. You cannot review changes in a pull request. You cannot sync with your local development setup without copy-pasting values one at a time. And if you have multiple environments (staging, production, preview), the problem multiplies.

What good CLI env var management looks like

A good CLI tool for environment variables should support: setting multiple variables in one command, listing with optional masking, removing variables, pulling remote values to a local .env file, and pushing local .env files to remote. It should also support targeting specific environments and working non-interactively in CI/CD.

Local .env file sync

The most common pain point is keeping local .env files in sync with production. A CLI pull command downloads remote variables to a .env file for local development. A push command uploads your local .env file to the remote environment. This eliminates manual copy-pasting and reduces configuration drift.

Approaches compared

Platform CLI (Vercel, Railway, CreateOS)

Pros

  • Integrated with deployment
  • Supports multiple environments
  • Pull/push .env sync

Cons

  • Tied to one platform

Best for: Teams using a single deployment platform

dotenv + manual management

Pros

  • No tool dependency
  • Works with any platform

Cons

  • No sync between environments
  • Manual copy-paste to dashboards
  • Easy to leak in git

Best for: Simple projects with one environment

Vault / AWS Secrets Manager

Pros

  • Enterprise-grade security
  • Audit trails
  • Rotation support

Cons

  • Complex setup
  • Overkill for small teams

Best for: Enterprise teams with compliance requirements

Manage env vars with CreateOS CLI

Here is how to do it step by step using CreateOS CLI.

1

List variables

$ createos env list

Shows all environment variables for your project. Use --hide to mask values.

2

Set variables

$ createos env set DATABASE_URL=postgres://... API_KEY=sk-xxx

Set one or more variables in a single command. Merges with existing.

3

Pull to local .env

$ createos env pull

Downloads remote variables to .env.{environment}. Auto-adds to .gitignore.

4

Push from local

$ createos env push

Uploads your local .env file to the remote environment. Shows diff before applying.

Frequently asked questions

How do I sync .env files between local and production?
Use a CLI tool that supports pull and push. Pull downloads remote variables to a local .env file. Push uploads your local .env file to the remote environment. CreateOS CLI does this with createos env pull and createos env push.
Should I commit .env files to git?
Never commit .env files with real values to git. Instead, commit a .env.example file with empty values as documentation. Use a CLI tool to sync actual values between environments without git.
How do I manage env vars in CI/CD?
Store sensitive values as CI secrets (e.g., GitHub Actions secrets). Use a CLI tool to set them on the deployment platform: createos env set DATABASE_URL=$DB_URL --project $ID --environment $ENV_ID. This keeps secrets out of your codebase.
What is the best CLI for managing environment variables?
For integrated deployment workflows, platform CLIs like Vercel CLI, Railway CLI, or CreateOS CLI work best because they tie env vars directly to deployments and environments. CreateOS CLI adds .env file pull/push sync, which most alternatives lack.

Try it yourself

$ brew install createos

100,000+ Builders. One Workspace.

Get product updates, builder stories, and early access to features that help you ship faster.

CreateOS is a unified intelligent workspace where ideas move seamlessly from concept to live deployment, eliminating context-switching across tools, infrastructure, and workflows with the opportunity to monetize ideas immediately on the CreateOS Marketplace.