add
Add a new environment variable to your Redenv project.
The add command creates a new encrypted secret in your project.
Usage#
redenv add <key> [value]Arguments#
| Name | Required | Description |
|---|---|---|
key | Yes | The environment variable name (e.g., API_KEY) |
value | No | The secret value (interactive prompt if omitted) |
Options#
| Flag | Description |
|---|---|
-p, --project <name> | Specify project name |
-e, --env <env> | Specify environment |
Examples#
Add with inline value#
redenv add API_KEY "sk_test_abc123"Add interactively#
redenv add DATABASE_URL
# Opens multiline editor for inputAdd to specific environment#
redenv add API_KEY "sk_live_xyz" --env productionInteractive Mode#
When the value is omitted, you get a multiline editor:
$ redenv add DATABASE_URL
? Enter value for DATABASE_URL:
> postgresql://user:pass@localhost:5432/mydb
> (↵ submit • ⇧↵ new line)
✔ Added 'DATABASE_URL' → postgresql://user:pass@localhost:5432/mydb in my-app (development)Info
Use interactive mode for:
- Sensitive values (avoids shell history)
- Multiline values (JSON, certificates, etc.)
- Values with special characters
- Variable references (
${KEY}syntax)
Variable References#
You can reference other secrets using ${KEY} syntax:
redenv add BASE_URL "https://api.example.com"
redenv add AUTH_URL "\${BASE_URL}/auth"Error
Use interactive mode for references! Shells like Bash/Zsh interpret ${}
syntax before Redenv sees it. This can corrupt your values or cause errors.
# Dangerous - shell expands ${BASE_URL} first
redenv add AUTH_URL "${BASE_URL}/auth"
# Safe - interactive mode bypasses shell
redenv add AUTH_URL
> ${BASE_URL}/authThe CLI validates that referenced keys exist before saving. See Secret Expansion for details on how references work at runtime.
Key Naming Rules#
- Must start with a letter or underscore
- Can contain letters, numbers, and underscores
- Cannot start with
__(reserved for internal metadata)
# Valid
redenv add MY_API_KEY "value"
redenv add _PRIVATE_KEY "value"
# Invalid
redenv add 123_KEY "value" # Starts with number
redenv add __INTERNAL "value" # Reserved prefix