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
Cloud Overview & Architecture
The Dual-Engine Model
Cloud Resolver Data Plane
Workload & Agent Tokens
Egress Allowlists & Audit Streams
Cloud REST API Reference
Account (init / login)
Server & Self-Hosting (server)
Docs
Shell Autocompletion
Keychain Auth
Secrets
Environments
Credential Proxy
env Injection
Workspaces & Teams
Projects
Agent Identity
Audit & Governance
Integrations Overview
Claude Desktop
Cursor
OpenClaw
HTTP Proxy (Any)
LangChain (Soon)
CrewAI (Soon)
CI/CD Pipeline
SDK Overview
Python SDK
Python API Reference
Python SDK Manual Testing
JavaScript SDK (Soon)
Ecosystem Overview
Zero-Knowledge MCP Server
Server Overview
5-Layer Architecture
Self-Hosting Guide
Authentication & Keys
Workspaces & Teams
Projects & Scope
Environments
Secrets & Sync Protocol
Agent Identity Resolution
Telemetry & Metrics Engine
Audit Log Sync
API Endpoint 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.1.x
v3.0.0
v2.1.0
v2.0.0
v1.4.0
v1.3.x
v1.2.0
v1.1.x
v1.0.x
CLI ReferenceMerging Environments

Merging Environments

The merge command

agentsecrets environment merge <source> <destination>

Merge is designed for situations where two environments should contain the same keys, but different values. The most common workflow is promoting staging into production while replacing test credentials with live production credentials.

Unlike copy, merge does not blindly duplicate values between environments.

When to merge

Use merge when:

  • the destination environment already exists
  • production credentials differ from staging credentials
  • you want to preserve existing destination secrets unless explicitly updated
  • you want controlled, per-key promotion

Typical example:

staging → test Stripe keys production → live Stripe keys

Both environments contain the same keys, but the values must remain different.

Running a merge

agentsecrets environment merge staging production

For each key in staging, the CLI prompts you to enter the production value. Press Enter to skip a key and leave its existing production value unchanged.

Enter production values for each key (press Enter to skip): STRIPE_KEY (staging: sk_test_***): sk_live_51H... OPENAI_KEY (staging: sk-proj-***): (skipped) DATABASE_URL (staging: pos***): postgresql://prod-host/db

Pressing Enter without typing a value skips that key.

Only keys that exist in both environments are prompted for. New keys in staging are ignored, and existing keys in production that are not present in staging are preserved.

How merge works

Merge only operates on keys that exist in both environments.

Behavior summary:

SituationBehavior
Key exists in source and destinationPrompt for new destination value
Key exists only in sourceIgnored
Key exists only in destinationPreserved
Prompt skippedExisting destination value remains unchanged

Merge never deletes keys. Merge never automatically copies source values into the destination. Every update requires explicit user input.

Prompting behavior

Each prompt includes:

  • the key name
  • a masked preview of the source value
  • an input field for the destination value

Example:

STRIPE_KEY (staging: sk_test_***):

The masked preview exists only to help identify the credential being replaced without exposing the full value.

Safety guarantees

Skipped keys retain whatever value they currently have in the destination environment, or remain unset if they have never been configured there.

Merge never deletes keys from the destination, it only adds or updates keys you explicitly provide a value for during the prompt.

This makes merge a safe operation when you only want to promote a subset of the source environment.

Typical production workflow

agentsecrets environment switch production agentsecrets environment merge staging production agentsecrets secrets pull

This keeps production aligned structurally with staging while preserving production-specific credentials.

Was this helpful?
Thanks for your feedback!
Your feedback helps us improve the platform.