Redact environment variable secrets in Cursor

Pass environment variable secrets to Cursor while redacting matching values from its output.

Cursor receives the real environment variables, but any matching values it prints are replaced with [REDACTED].

Prerequisite

Install the Cursor CLI. The Cursor desktop app does not necessarily install the separate agent command.

$ curl https://cursor.com/install -fsS | bash

Verify that agent is available.

$ agent --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 Cursor with redaction

Run Cursor with your real secrets while redacting them from its output.

$ dotenvx run --redact -- agent -p --force 'Run `dotenvx get HELLO` and echo back just Hello VALUE' --output-format text
Hello [REDACTED]