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 ReferenceSwitching Environments

Switching the Active Environment

The switch command

agentsecrets environment switch <environment>

Switches the active environment for the current project.

Valid environments are development, staging, and production. Anything else is rejected with an error listing the valid options.

Examples

Switch to staging:

agentsecrets environment switch staging

Switch to production:

agentsecrets environment switch production

After switching, all environment-aware commands operate against the selected environment by default.

What changes when you switch

Switching environments changes:

  • which secrets the proxy resolves
  • which cloud blobs push and pull operate on
  • which secrets set, get, and delete modify
  • which .env.{environment} file is read or written in Standard mode

The active environment becomes the default context for all subsequent CLI operations in that project directory.

Project-local behavior

The switch command writes the selected environment to .agentsecrets/project.json inside the current project directory. This means environment selection is project-local, not terminal-local. Two different project directories can remain pinned to different environments simultaneously without conflicting with each other.

Example:

~/payments-api → production ~/mobile-app → development

Changing environments in one project does not affect the other. The selected environment is also written to global config as a fallback when no project-local configuration exists.

Proxy behavior

The proxy automatically begins resolving secrets from the new environment immediately after switching. No proxy restart is required.

Example:

agentsecrets environment switch staging

Subsequent proxy requests now resolve staging credentials automatically.

Pulling secrets after switching

Switching environments changes the active context, but does not automatically download secrets for that environment. To fetch the latest secrets locally after switching:

agentsecrets secrets pull

Runagentsecrets secrets pull after switching environments to sync the latest secrets locally.

Verifying the active environment

agentsecrets status

The active environment is always shown in the status output. Verify the current environment before operations that modify or delete secrets, especially in production workflows.

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