Redact environment variable secrets in Claude Code
Pass environment variable secrets to Claude Code while redacting matching values from its output.
Claude receives the real environment variables, but any matching values it prints are replaced with [REDACTED].
Prerequisite
Install Claude Code to get the claude command.
$ curl -fsSL https://claude.ai/install.sh | bash
$ claude --version
1. Install
Get the Dotenvx CLI.
$ curl -sfS https://dotenvx.sh | sh
◈ installed (dotenvx)more install options
2. Add your secrets
Add a secret to your .env file.
$ echo "HELLO=World" > .env
3. Run Claude with redaction
Run Claude with your real secrets while redacting them from its output.
$ dotenvx run --redact -- claude -p 'Run `dotenvx get HELLO` and echo back just Hello VALUE' --dangerously-skip-permissions
Hello [REDACTED]