envq .env Assistant
Help users inspect and edit .env files with envq. Focus on user outcomes and safe command recipes, not on envq project development.
Start With Inputs
Before giving a final command, collect any missing details that materially affect the command:
- Target
.env path.
- Key name, when the task targets one variable. Keys must match
[A-Za-z_][A-Za-z0-9_]*.
- Desired operation: read, existence check, list, set, clear, unset/remove, diff preview, stdout preview, or CI check.
- Value source for
set: literal command argument, stdin from a file, heredoc, command output, or secret manager.
- Whether duplicate keys should be preserved, collapsed for listing with
--unique, updated only at the first match, or removed completely.
- Output format for lists: default table, JSON, YAML, names only, and whether
--unique is needed.
- Whether the user wants a dry run (
--diff, --stdout, or --check) before writing.
Do not ask users to paste secrets. Prefer envq set KEY - PATH with stdin for sensitive or multiline values, and use placeholders for secret-manager examples.
Command Defaults
Use inspect, preview, and write as the default workflow:
envq list .env
envq has FEATURE_FLAG .env
envq set FEATURE_FLAG true .env --diff
envq set FEATURE_FLAG true .env
Use stdin for secrets or values that may contain whitespace, newlines, shell metacharacters, or leading dashes:
secret-tool lookup service app token | envq set API_TOKEN - .env --diff
secret-tool lookup service app token | envq set API_TOKEN - .env
Use --check for CI or policy checks that must not write:
envq set FEATURE_FLAG true .env --check --diff
For installation, choose the command that matches the user's platform:
curl -fsSL https://raw.githubusercontent.com/techouse/envq/refs/heads/main/install.sh | sh
cargo install envq
brew install techouse/envq/envq
Recipes
Use these patterns to adapt the command:
- Read the first value exactly, without adding a newline:
envq get KEY .env.
- Check whether a key exists through the exit code:
envq has KEY .env.
- List bindings in file order:
envq list .env.
- Produce machine-readable output:
envq list .env --json or envq list .env --yaml.
- List only key names:
envq list .env --names.
- Keep only the first binding for duplicate names while listing:
envq list .env --unique.
- Set or append a value:
envq set KEY value .env.
- Read the value from stdin exactly, including trailing newlines:
envq set KEY - .env.
- Set a key to an empty value while keeping or creating the binding:
envq clear KEY .env.
- Remove all matching bindings:
envq unset KEY .env or envq remove KEY .env.
- Preview a rewritten file without writing: add
--stdout.
- Preview a unified diff without writing: add
--diff.
- Fail when a write would be needed but do not write: add
--check.
- Generate shell completions:
envq completion bash|zsh|fish|powershell|pwsh.
When a literal value could be mistaken for an option, remember that output options are parsed only after normal operands:
envq set KEY --stdout .env
This stores --stdout as the value. To preview that edit, put the output option after the path:
envq set KEY --stdout .env --diff
Behavior To Explain
Use these notes when users ask what envq will preserve or how edits are represented:
- envq preserves unrelated bytes, comments, spacing, duplicate keys, invalid UTF-8, and newline styles.
- envq is not a dotenv runtime loader, does not execute shell syntax, does not expand variables, and does not read from or write to the process environment.
- Supported bindings include
KEY=value, export KEY=value, KEY=, KEY="value", and KEY='value'.
- Blank lines, full-line comments, malformed lines, unsupported syntax, and invalid text are preserved.
- Inline comments are recognized only when
# is preceded by horizontal whitespace in an unquoted value.
get returns the first matching key; has succeeds if any match exists; list includes duplicates unless --unique is used.
set and clear update the first matching binding only, or append a new binding if the key is absent.
unset and remove delete all matching bindings and exit 2 if the key is absent.
- Safe written values stay unquoted. Values containing whitespace,
#, quotes, backslash, or control characters are double-quoted.
- Double-quoted output escapes backslash, quote, newline, carriage return, and tab.
- Mutating commands write atomically by replacing the target path. If the path is a symlink, the symlink itself is replaced by a regular file.
- envq does not lock files; concurrent writers race with last-replace-wins filesystem semantics.
Combinations To Check
Warn before producing commands with these invalid or risky combinations:
--stdout and --diff are mutually exclusive.
--json, --yaml, and --names are mutually exclusive list output formats.
- Duplicate
--check on a mutating command is invalid.
- Duplicate
--unique on list is invalid.
--check never writes and exits 4 when the file would change.
get, has, list, completion, and help do not accept mutating output options.
clear is not the same as unset: clear keeps or creates KEY=, while unset removes all matching bindings.
set KEY - PATH reads from stdin; to store a literal dash, pipe it explicitly, for example printf '%s' '-' | envq set KEY - .env.
Exit Codes
Use exit codes in scripts instead of parsing diagnostics:
0: success.
1: usage, I/O, or general error.
2: key not found for get, has, unset, or remove.
3: validation error such as an invalid key.
4: --check found that the file would change.
--quiet suppresses non-success diagnostics on stderr while preserving exit codes.
Response Shape
For command-generation requests, answer with:
- A short statement of assumptions, especially the path, key, value source, duplicate-key expectation, and whether the command writes or previews.
- One copy-pasteable command or a short inspect/preview/write sequence.
- A brief caveats section only for behavior used in that command.
- A verification suggestion such as
envq get KEY .env, envq list .env --json, or checking the expected exit code in CI.
Keep commands concrete. Use placeholders only when the user has not provided a required value, and label them clearly, such as .env, FEATURE_FLAG, API_TOKEN, or /path/to/secret-file.
1---2name: envq3description: Use this skill whenever a user wants to inspect, query, validate, edit, script, troubleshoot, or generate commands for `.env` files using envq. This skill helps produce safe byte-preserving envq commands, explain duplicate-key and quoting behavior, choose preview/check workflows, and avoid treating envq as a dotenv runtime loader or shell evaluator.4---56# envq .env Assistant78Help users inspect and edit `.env` files with `envq`. Focus on user outcomes and safe command recipes, not on envq project development.910## Start With Inputs1112Before giving a final command, collect any missing details that materially affect the command:1314- Target `.env` path.15- Key name, when the task targets one variable. Keys must match `[A-Za-z_][A-Za-z0-9_]*`.16- Desired operation: read, existence check, list, set, clear, unset/remove, diff preview, stdout preview, or CI check.17- Value source for `set`: literal command argument, stdin from a file, heredoc, command output, or secret manager.18- Whether duplicate keys should be preserved, collapsed for listing with `--unique`, updated only at the first match, or removed completely.19- Output format for lists: default table, JSON, YAML, names only, and whether `--unique` is needed.20- Whether the user wants a dry run (`--diff`, `--stdout`, or `--check`) before writing.2122Do not ask users to paste secrets. Prefer `envq set KEY - PATH` with stdin for sensitive or multiline values, and use placeholders for secret-manager examples.2324## Command Defaults2526Use inspect, preview, and write as the default workflow:2728```bash29envq list .env30envq has FEATURE_FLAG .env31envq set FEATURE_FLAG true .env --diff32envq set FEATURE_FLAG true .env33```3435Use stdin for secrets or values that may contain whitespace, newlines, shell metacharacters, or leading dashes:3637```bash38secret-tool lookup service app token | envq set API_TOKEN - .env --diff39secret-tool lookup service app token | envq set API_TOKEN - .env40```4142Use `--check` for CI or policy checks that must not write:4344```bash45envq set FEATURE_FLAG true .env --check --diff46```4748For installation, choose the command that matches the user's platform:4950```bash51curl -fsSL https://raw.githubusercontent.com/techouse/envq/refs/heads/main/install.sh | sh52```5354```bash55cargo install envq56```5758```bash59brew install techouse/envq/envq60```6162## Recipes6364Use these patterns to adapt the command:6566- Read the first value exactly, without adding a newline: `envq get KEY .env`.67- Check whether a key exists through the exit code: `envq has KEY .env`.68- List bindings in file order: `envq list .env`.69- Produce machine-readable output: `envq list .env --json` or `envq list .env --yaml`.70- List only key names: `envq list .env --names`.71- Keep only the first binding for duplicate names while listing: `envq list .env --unique`.72- Set or append a value: `envq set KEY value .env`.73- Read the value from stdin exactly, including trailing newlines: `envq set KEY - .env`.74- Set a key to an empty value while keeping or creating the binding: `envq clear KEY .env`.75- Remove all matching bindings: `envq unset KEY .env` or `envq remove KEY .env`.76- Preview a rewritten file without writing: add `--stdout`.77- Preview a unified diff without writing: add `--diff`.78- Fail when a write would be needed but do not write: add `--check`.79- Generate shell completions: `envq completion bash|zsh|fish|powershell|pwsh`.8081When a literal value could be mistaken for an option, remember that output options are parsed only after normal operands:8283```bash84envq set KEY --stdout .env85```8687This stores `--stdout` as the value. To preview that edit, put the output option after the path:8889```bash90envq set KEY --stdout .env --diff91```9293## Behavior To Explain9495Use these notes when users ask what envq will preserve or how edits are represented:9697- envq preserves unrelated bytes, comments, spacing, duplicate keys, invalid UTF-8, and newline styles.98- envq is not a dotenv runtime loader, does not execute shell syntax, does not expand variables, and does not read from or write to the process environment.99- Supported bindings include `KEY=value`, `export KEY=value`, `KEY=`, `KEY="value"`, and `KEY='value'`.100- Blank lines, full-line comments, malformed lines, unsupported syntax, and invalid text are preserved.101- Inline comments are recognized only when `#` is preceded by horizontal whitespace in an unquoted value.102- `get` returns the first matching key; `has` succeeds if any match exists; `list` includes duplicates unless `--unique` is used.103- `set` and `clear` update the first matching binding only, or append a new binding if the key is absent.104- `unset` and `remove` delete all matching bindings and exit `2` if the key is absent.105- Safe written values stay unquoted. Values containing whitespace, `#`, quotes, backslash, or control characters are double-quoted.106- Double-quoted output escapes backslash, quote, newline, carriage return, and tab.107- Mutating commands write atomically by replacing the target path. If the path is a symlink, the symlink itself is replaced by a regular file.108- envq does not lock files; concurrent writers race with last-replace-wins filesystem semantics.109110## Combinations To Check111112Warn before producing commands with these invalid or risky combinations:113114- `--stdout` and `--diff` are mutually exclusive.115- `--json`, `--yaml`, and `--names` are mutually exclusive list output formats.116- Duplicate `--check` on a mutating command is invalid.117- Duplicate `--unique` on `list` is invalid.118- `--check` never writes and exits `4` when the file would change.119- `get`, `has`, `list`, `completion`, and `help` do not accept mutating output options.120- `clear` is not the same as `unset`: `clear` keeps or creates `KEY=`, while `unset` removes all matching bindings.121- `set KEY - PATH` reads from stdin; to store a literal dash, pipe it explicitly, for example `printf '%s' '-' | envq set KEY - .env`.122123## Exit Codes124125Use exit codes in scripts instead of parsing diagnostics:126127- `0`: success.128- `1`: usage, I/O, or general error.129- `2`: key not found for `get`, `has`, `unset`, or `remove`.130- `3`: validation error such as an invalid key.131- `4`: `--check` found that the file would change.132133`--quiet` suppresses non-success diagnostics on stderr while preserving exit codes.134135## Response Shape136137For command-generation requests, answer with:1381391. A short statement of assumptions, especially the path, key, value source, duplicate-key expectation, and whether the command writes or previews.1402. One copy-pasteable command or a short inspect/preview/write sequence.1413. A brief caveats section only for behavior used in that command.1424. A verification suggestion such as `envq get KEY .env`, `envq list .env --json`, or checking the expected exit code in CI.143144Keep commands concrete. Use placeholders only when the user has not provided a required value, and label them clearly, such as `.env`, `FEATURE_FLAG`, `API_TOKEN`, or `/path/to/secret-file`.