Environments

Core Concepts

Environments

Model local, preview, staging, and production configuration as independently encrypted environments with explicit synchronization and history.

Environment types

Every environment has a name and a type. Interactive creation offers local, development, preview, staging, production, or a custom type. Types document intent and participate in protected-environment detection.

Protected-environment detection is intentionally conservative. A name or type containing the token prod, production, or live is protected. Otherwise, only environment names containing default, local, dev, development, test, testing, or ci are treated as local-development environments. Every other name is protected by default.

default, local, dev, test, ci
Not protected unless the environment type explicitly contains prod, production, or live.
production, prod-us, live
Protected because the name contains an explicit production token.
preview, staging, qa, primary, custom names
Protected by the conservative fallback, even when the type is development.
List environments
$ ghostable env list
$ ghostable env list --json
 

Create and seed

Create environments
$ ghostable env create preview --type preview
$ ghostable env create staging --type staging --from-env default --seed keys-only
$ ghostable env create production --type production --from-env staging --seed non-sensitive
 

Seed modes are keys-only, non-sensitive, and all. Keys-only establishes layout without copying values. Non-sensitive copies values that do not appear secret. All copies every value and should receive deliberate review.

Use --from-file instead of --from-env when a local env file should provide the initial key layout.

Push and sync

env push creates or updates keys present in a file without removing other stored keys:

Push values
$ ghostable env push --env staging --file .env.staging --reason "Configure payment sandbox"
 

env sync also deletes stored keys that are absent from the local file:

Synchronize an environment
$ ghostable env sync --env staging --file .env.staging --reason "Remove retired integration"
 

Pull values

Pull merges into an existing file by default and creates a timestamped backup before writing. Use --replace for an exact environment snapshot, --only for selected keys, and --dry-run to inspect the operation without writing.

Materialize values
$ ghostable env pull --env default --file .env
$ ghostable env pull --env staging --file .env.staging --replace
$ ghostable env pull --env production --file .env.production --only APP_KEY --only DATABASE_URL
 

--show-values prints plaintext in command output. Avoid it in shared terminals, logs, CI, and agent sessions.

Supported dotenv syntax

Ghostable uses a line-oriented dotenv parser. It supports unquoted, single-quoted, and same-line double-quoted values; blank lines and comments; optional export prefixes; inline comments introduced by a space followed by #; and disabled entries written as # KEY=value.

Comments and layout
Merge operations preserve blank lines, comments, unrelated keys, and an existing export prefix.
Duplicate keys
The last occurrence wins when reading. Updating that key removes its earlier duplicate entries.
Key normalization
Imported keys are trimmed, uppercased, and normalized to letters, numbers, and underscores.
Interpolation
Values such as ${APP_URL} remain literal; Ghostable does not expand shell or dotenv references.
Multiline values
Quoted values must remain on one physical line. Use escaped newline sequences or another encoding for multiline data.

Replacing a file renders a normalized snapshot and does not preserve its original comments or layout. Use merge behavior when those details matter, and inspect env diff before writing a file with unfamiliar syntax.

Run without a file

Inject decrypted values directly into a child process to reduce plaintext files on disk:

Process injection
$ ghostable env run --env default -- php artisan test
$ ghostable env run --env staging --mask-output -- npm run smoke-test
$ ghostable env shell --env default
 

The child inherits the current process environment by default. Pass --no-inherit to use only Ghostable values plus a minimal system environment, and --strict to validate injected values and fail when requested keys are missing.

--mask-output replaces exact injected values found in child stdout and stderr. It is best-effort log masking, not data-loss prevention: encoded, transformed, split, or file-written values are outside its protection.

Compare and audit

Diff and history
$ ghostable env diff --env default --file .env
$ ghostable env diff --from staging --to production
$ ghostable env history --env production --limit 25
$ ghostable env history --env production --key APP_KEY
 

Diff output is redacted unless --show-values is explicitly requested. History records signed actions, environments, keys, devices, and timestamps.

Rename and delete

Environment lifecycle
$ ghostable env rename --from preview-42 --to preview-43 --reason "Match deployment environment"
$ ghostable env delete --env preview-43
 

Both operations modify repository-backed state. Review and commit the resulting .ghostable/ changes immediately.

CLI 3.x introduction Documentation
Installation Documentation
Start a new project Getting Started
Adopt an existing project Getting Started
Onboard a team member Getting Started
Repository and storage Core Concepts
Environments Core Concepts
Variables and promotions Core Concepts
Access and devices Core Concepts
Daily development workflow Workflows
Review and secret scanning Workflows
Hygiene and rotation Workflows
Automation credentials Automation & CI
Continuous integration Automation & CI
Deployments Automation & CI
Validation Reference
Command reference Reference
Configuration Reference
Security Reference
Backups & Offline Reference
Agent integration Reference
Troubleshooting Reference
Ghostable Desktop overview Desktop
Installation Desktop
Projects and setup Desktop
Interface tour Desktop
Environments and variables Desktop
Local environment files Desktop
Validation and review Desktop
Activity Desktop
Access and automation Desktop
Project settings Desktop
Application settings Desktop
Licensing and updates Desktop
Security and storage Desktop
Troubleshooting Desktop
No results found