Running Any Process with Environment Injection
Because agentsecrets env operates at the operating system process boundary via the standard POSIX execve interface, it is 100% runtime- and language-agnostic. Any application that can read system environment variables can run with AgentSecrets without installing an SDK or modifying a single line of code.
Production Recipes & Integration Examples
1Docker & Docker Compose (Zero-Disk Secrets)
When building microservices or local containers, developers often place sensitive database passwords or API keys directly in docker-compose.yml or load them from a .env file that gets committed by accident.
Instead, define your Compose services to inherit variables from the host environment:
</div> # docker-compose.yml services: api: image: my-company/api:latest ports: - "8000:8000" environment: # Docker automatically binds these from host memory if not defined in YAML - DATABASE_URL - STRIPE_SECRET_KEY - REDIS_PASSWORD
Now, launch your containers with in-memory injection:
agentsecrets env -- docker compose up
- Why this works: Docker Compose reads
DATABASE_URLandSTRIPE_SECRET_KEYdirectly from the parent environment created byagentsecrets envin RAM. - Security Win: No
.envfile exists on the host disk. Docker Compose configuration files can be committed safely to Git.
2Full-Stack Web Frameworks
Node.js / Next.js / Express
Run your development server or production build script:
agentsecrets env -- npm run dev </div> # Or with pnpm / yarn / bun: agentsecrets env -- bun run dev
Inside your Next.js API routes or server components:
// app/api/checkout/route.ts // Standard process.env access — no dotenv, no dotenv-vault packages required const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
Python / Django / FastAPI
Run database migrations or local development servers:
agentsecrets env -- python manage.py migrate agentsecrets env -- python manage.py runserver 0.0.0.0:8000
In your settings.py:
import os # Resolves immediately from child process memory SECRET_KEY = os.environ.get("DJANGO_SECRET_KEY") DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql", "NAME": os.environ.get("DB_NAME"), "USER": os.environ.get("DB_USER"), "PASSWORD": os.environ.get("DB_PASSWORD"), "HOST": os.environ.get("DB_HOST", "localhost"), "PORT": os.environ.get("DB_PORT", "5432"), } }
3Background Queues & Asynchronous Workers (Celery, BullMQ, Sidekiq)
Background workers require persistent database and broker connections, and must shut down gracefully when deployments occur or when developers press Ctrl+C.
Because agentsecrets env implements an active POSIX Signal Supervisor, it forwards SIGINT and SIGTERM directly to the worker process:
agentsecrets env -- celery -A myproject worker --loglevel=info
When you terminate the worker with Ctrl+C, agentsecrets env forwards the interrupt directly to Celery. Celery acknowledges the signal, stops accepting new tasks, waits for in-flight tasks to complete, and closes Redis/RabbitMQ connections cleanly without orphaning worker processes.
4Claude Desktop & Cursor IDE (AI MCP Servers)
Model Context Protocol (MCP) servers allow AI assistants like Claude Desktop and Cursor to interact with tools. Most MCP servers (e.g. Postgres MCP, Stripe MCP, GitHub MCP) require API keys configured in claude_desktop_config.json.
Storing plaintext API keys in Claude Desktop's JSON configuration is dangerous because any file-reading prompt injection can read the JSON file.
Wrap the MCP server command in agentsecrets env:
{ "mcpServers": { "stripe": { "command": "agentsecrets", "args": ["env", "--", "npx", "-y", "@stripe/mcp"] }, "postgres": { "command": "agentsecrets", "args": ["env", "--", "npx", "-y", "@modelcontextprotocol/server-postgres"] } } }
- Security Win: Notice the complete absence of an
"env"block inclaude_desktop_config.json. - When Claude Desktop launches the MCP server,
agentsecrets envretrievesSTRIPE_SECRET_KEYandPOSTGRES_URLdirectly from your OS Keychain and injects them into the spawned MCP process memory.
5Running Interactive Shells & REPLs
You can launch an interactive shell where all active environment secrets are temporarily accessible:
agentsecrets env -- bash
Or launch interactive language REPLs:
agentsecrets env -- python agentsecrets env -- node
- Because
childCmd.Stdin = os.Stdin, input is piped directly to your terminal. - Once you type
exitor close the shell, the process terminates and all decrypted secrets disappear from memory.
Common Edge Cases & Troubleshooting
Why the -- Delimiter is Mandatory
If you run:
agentsecrets env python manage.py runserver --help
Without --, the Cobra CLI parser checks --help and displays the help page for agentsecrets env rather than passing --help to Django.
Always include -- to cleanly partition the CLI boundary:
agentsecrets env -- python manage.py runserver --help
Passing Complex Pipeline Commands (sh -c)
If you want to use pipes (|), shell redirects (>), or command chains (&&), wrap them in sh -c so your host shell doesn't execute the pipe before AgentSecrets spawns:
# Correct: Subshell receives the injected variables agentsecrets env -- sh -c 'python export.py | gzip > backup.gz' # Incorrect: The host shell executes the pipe outside of AgentSecrets agentsecrets env -- python export.py | gzip > backup.gz
Path Resolution (exec.LookPath)
agentsecrets env uses the host system $PATH to resolve the target executable. If you are using virtual environments (Python venv or poetry) or local Node binaries (npx, ./node_modules/.bin):
# Activate your virtualenv first: source .venv/bin/activate agentsecrets env -- python main.py # Or specify the path directly: agentsecrets env -- .venv/bin/python main.py agentsecrets env -- ./node_modules/.bin/jest