Migrating plaintext secrets
pw-env does not rewrite plaintext values automatically. Migration is an explicit, interactive step.
Keep safe local values out of migration
Mark values that should remain plaintext with pw-env:ignore either on the same line or on the comment line directly above the entry.
LOG_LEVEL=debug # pw-env:ignore
# pw-env:ignore
LOCAL_ONLY_TOKEN=dev-tokenRun the migration
pw-env migrate .To migrate into a different backend just for this run, pass --backend op, --backend bw, or --backend gpg.
The migration flow:
- Parses the
.envfile and finds plaintext values. - Highlights entries that look like secrets.
- Opens an interactive multi-select prompt.
- Stores the selected values in the effective backend, or the backend chosen by flag.
- Verifies each stored value before clearing it from
.env.
Entries that look like secrets are selected by default in the prompt.
Before and after
Before migration:
DATABASE_URL=postgres://user:pass@localhost:5432/app
API_KEY=super-secret-token
LOG_LEVEL=debug # pw-env:ignoreAfter a successful migration:
DATABASE_URL=
API_KEY=
LOG_LEVEL=debug # pw-env:ignoreOnly values that were stored and verified are cleared. Skipped entries and failed writes stay in .env.
Terminal requirements
pw-env migrate requires an interactive terminal. If stdin or stderr is not a terminal, the command exits instead of attempting a partially interactive run.
After migration
Run pw-env load . or your usual pw-env export command to confirm that the project now resolves the keys from the backend.
