What is AgentSecrets?
The Zero-Knowledge Difference
How AgentSecrets Works
Installation
Quick Start
Migrating from .env Files
Migrating from Vault / AWS
Migrating from dotenv-vault
Production Checklist
Credential Exposure
What Zero-Knowledge Means
The Proxy Model
The Three-Layer Model
Environments
Agent Identity
Storage Modes
The No get() Principle
Secret-Level Policies
Credential Proxy Overview
Secrets Management
Environments
env Injection
Workspaces & Teams
Projects
Agent Identity
Audit & Governance
account (init / login / logout)
server (get / set / status / reset)
secrets (set / list / delete / push / pull)
proxy (start / stop / status / logs)
call (inject requests via proxy)
env (execute commands with secrets)
workspace (list / create / switch / roles)
project (list / create / use / update)
environment (list / switch / copy / merge)
agent (register / list / tokens)
agent policy (set / get / delete)
logs (list / watch / export / verify)
mcp (serve / install / config)
status (system & session diagnostics)
Aliases & Shortcuts
docs (interactive terminal viewer)
Shell Autocompletion
keychain-auth (daemon & security)
Ecosystem Overview
Zero-Knowledge MCP Server
Integrations Overview
Claude Desktop
Cursor IDE
OpenClaw
HTTP Proxy (Any Client)
LangChain (Native)
CrewAI (Native)
CI/CD Pipeline
SDK Overview
Python SDK
Python API Reference
Python SDK Manual Testing
JavaScript SDK (Soon)
ZK-MCP Integration Guide
Server Overview
5-Layer Architecture
Self-Hosting Guide
Self-Hosting Operations Manual
Server Data Migration
Authentication & Keys
Workspaces & Teams Backend
Projects & Scope Backend
Environments Backend
Secrets & Sync Protocol
Agent Identity Resolution
Telemetry & Metrics Engine
Audit Log Sync
API Endpoint Reference
Cloud Overview & Architecture
The Dual-Engine Model
Cloud Resolver Data Plane
Workload & Agent Tokens
Egress Allowlists & Audit Streams
Cloud REST API Reference
Security Overview
Anti-Impersonation & Process Verification
Encryption Model
Zero-Knowledge Sync
Proxy Security Layers
Threat Model
OWASP Top 10 Mitigation
Security FAQ
Third-Party Audit
Reporting Vulnerabilities
Guides Overview
Building on the SDK
Stripe Integration
OpenAI Integration
Multi-Agent Setup
Onboarding Team
CI/CD Pipeline
Publishing ZK MCP
Rotating Credentials
Auditing Team Activity
Dev to Production
Kubernetes Deployment
Monorepo Setup
Production Proxy Hardening
vs .env Files
vs HashiCorp Vault
vs AWS Secrets Manager
vs dotenv-vault
vs Infisical
When Not to Use
Proxy Not Starting
Proxy Not Resolving
Domain Blocked
Sync Conflicts
MCP Not Connecting
Session Token Errors
Proxy Session Authorization
Keychain Storage & Backends
SSRF & Destination Rules
Installation Issues
Error Codes Reference
Frequently Asked Questions
v3.x
v2.1.0
v2.0.0
v1.4.0
v1.3.x
v1.2.0
v1.1.x
v1.0.x
CLI Referenceenv (execute commands with secrets)

env

agentsecrets env --

agentsecrets env -- <command> [args...]

Injects all secrets configured for the active project environment into a child process at spawn time.

Mandatory Output Masking (Stdout/Stderr Redaction)

The env command provides zero-disk, process-isolated secret injection for runtime applications, database drivers, and local tools. By spawning the target command as an isolated child process with real-time output stream redaction, agentsecrets env ensures secrets never touch disk, never leak to shell history, never expose to other processes, and never print to terminal streams.

To guarantee that credentials cannot be exfiltrated through terminal scrollback, crash reports, or stdout inspection, agentsecrets enforces mandatory real-time stream masking:

  1. Real-time Redaction: The parent agentsecrets process intercepts the child's stdout and stderr streams, scanning them in real-time.
  2. Pre-computed Variant Protection: The scanner matches not only the raw secret values but also their common encodings and case transformations to prevent simple obfuscation bypasses:
    • Case-insensitive matches (Uppercase & Lowercase)
    • Base64 (Standard & URL-safe encodings)
    • Hex-encoded representations
    • URL-query escaped values
  3. Always Enforced: This security layer is always active. There are no bypass flags (like --no-mask) to ensure AI agents or malicious scripts cannot turn off the masking.

Note: The actual secret values are still loaded into the child process environment memory, meaning dynamic operations like network API calls proceed normally.

Showcase: Automatic Output Masking

To see output masking in action, suppose you have a secret named TEST_SECRET_MASK with the value SuperSecretKey123 configured in your active development environment.

If you run a command that prints this secret directly, or in any of its common encoded formats, agentsecrets automatically intercepts the output and replaces it with [REDACTED].

1Direct Output Masking

$ agentsecrets env -- sh -c 'echo $TEST_SECRET_MASK' [REDACTED]

2Base64 Encoded Masking

AI agents or rogue scripts might attempt to bypass simple checks by base64-encoding the environment variables. agentsecrets env pre-computes the Base64 representation of your secret values and masks them:

$ agentsecrets env -- sh -c 'echo $TEST_SECRET_MASK | base64' [REDACTED]

3Hex Encoded Masking

Hexadecimal encodings (including common 0x prefixes) are also caught and masked automatically:

$ agentsecrets env -- sh -c 'echo -n $TEST_SECRET_MASK | xxd -p' [REDACTED]

4Case Variation Masking

If the key name itself is accessed with a different case (such as $test_secret_mask instead of $TEST_SECRET_MASK on case-insensitive platforms or configurations), the value is still resolved and masked:

$ agentsecrets env -- sh -c 'echo $test_secret_mask' [REDACTED]
Was this helpful?
Thanks for your feedback!
Your feedback helps us improve the platform.