OpenClaw Deployment Patterns: Development, Staging, and Production Environments
Complete guide to structuring OpenClaw deployments across dev, staging, and production environments. Isolation strategies, configuration management, and environment-specific agent behaviors.
Deploying OpenClaw across multiple environments isn't just about changing API keys—it's about architecting different agent behaviors, isolation strategies, and failure modes for each stage of your development lifecycle. Here's how I structure deployments that scale from local experimentation to production-grade reliability.
The Three-Environment Model
Every OpenClaw deployment I build follows this three-environment pattern:
- 1Development – Local or cloud sandbox for rapid iteration, debugging, and feature development
- 2Staging – Production-like environment for integration testing, performance validation, and user acceptance
- 3Production – Live environment with monitoring, alerting, and zero-downtime deployment patterns
Development Environment: Fast Iteration with Guardrails
The development environment is where agents learn to fail safely. Key characteristics:
Development Configuration
// openclaw.json (development)
{
"environment": "development",
"gateway": {
"host": "localhost",
"port": 3000,
"cors": ["http://localhost:5173", "http://localhost:3000"]
},
"agents": {
"defaultModel": "anthropic/claude-haiku",
"rateLimit": {
"requestsPerMinute": 30,
"burstSize": 5
}
},
"features": {
"enableDebugLogging": true,
"persistConversations": true,
"allowUnsafeTools": true
}
}Development-specific patterns:
- Model downgrading: Use cheaper models (Claude Haiku, GPT-3.5) for rapid iteration
- Unsafe tool allowance: Enable file system writes, shell access, and experimental APIs
- Conversation persistence: Save all interactions to debug complex multi-turn workflows
- Local-only dependencies: SQLite instead of PostgreSQL, file-based queues instead of Redis
Staging Environment: Production Simulation
Staging is where you catch integration issues before they reach users. It should mirror production as closely as possible:
Staging Configuration
// openclaw.json (staging)
{
"environment": "staging",
"gateway": {
"host": "staging.openclaw.example.com",
"port": 443,
"tls": {
"cert": "/etc/ssl/certs/staging.crt",
"key": "/etc/ssl/private/staging.key"
}
},
"agents": {
"defaultModel": "anthropic/claude-sonnet",
"rateLimit": {
"requestsPerMinute": 60,
"burstSize": 10
},
"timeouts": {
"toolExecution": 30000,
"modelResponse": 60000
}
},
"monitoring": {
"enabled": true,
"metricsEndpoint": "https://metrics.example.com/api/v1/write",
"sampleRate": 0.1
},
"features": {
"enableDebugLogging": false,
"persistConversations": false,
"allowUnsafeTools": false
}
}Staging validation checklist:
- Load testing: Simulate 10x expected traffic with tools like k6 or Locust
- Integration verification: Test all external API connections (OpenAI, Anthropic, Google, etc.)
- Data isolation: Separate databases with realistic but anonymized production data
- Security scanning: Run vulnerability scans on container images and dependencies
- Rollback testing: Verify you can revert to previous version within 5 minutes
Production Environment: Zero-Downtime Operations
Production deployments require different failure modes and recovery strategies:
Production Deployment Strategy
# deploy-production.sh
#!/bin/bash
set -e
# Blue-green deployment pattern
CURRENT_COLOR=$(kubectl get svc/openclaw -o jsonpath='{.spec.selector.color}')
if [ "$CURRENT_COLOR" = "blue" ]; then
NEW_COLOR="green"
else
NEW_COLOR="blue"
fi
echo "Deploying to $NEW_COLOR environment"
# Build and push new image
docker build -t openclaw:$NEW_COLOR .
docker push registry.example.com/openclaw:$NEW_COLOR
# Deploy new version
kubectl apply -f k8s/deployment-$NEW_COLOR.yaml
# Wait for readiness
kubectl rollout status deployment/openclaw-$NEW_COLOR --timeout=300s
# Switch traffic
kubectl patch svc/openclaw -p "{\"spec\":{\"selector\":{\"color\":\"$NEW_COLOR\"}}}"
# Keep old deployment for rollback window
sleep 300 # 5-minute rollback window
kubectl delete deployment/openclaw-$CURRENT_COLORProduction Monitoring Stack
Essential monitoring for production OpenClaw deployments:
Agent Metrics
- • Token usage per model/provider
- • Tool execution success rate
- • Response time percentiles (p50, p95, p99)
- • Error rate by agent type
Infrastructure Metrics
- • Gateway request rate
- • Memory/CPU usage per agent
- • Database connection pool health
- • External API latency
Configuration Management Across Environments
The key to maintainable multi-environment deployments is consistent configuration management:
Environment-Specific Configuration Structure
config/
├── base.json # Shared configuration
├── development.json # Development overrides
├── staging.json # Staging overrides
└── production.json # Production overrides
# Build script merges configurations
const config = merge(
require('./config/base.json'),
require(`./config/${process.env.NODE_ENV}.json`)
);Secret Management
Never commit secrets to version control. Use environment-specific secret stores:
- Development: .env.local files (gitignored) or local Vault instances
- Staging: HashiCorp Vault with limited access policies
- Production: AWS Secrets Manager, GCP Secret Manager, or Azure Key Vault with rotation policies
Agent Behavior Differences Across Environments
Agents should behave differently based on their environment:
| Behavior | Development | Staging | Production |
|---|---|---|---|
| Error Handling | Detailed stack traces | Generic messages + logs | User-friendly messages |
| Tool Permissions | Full access | Restricted access | Minimal access |
| Model Selection | Fast/cheap models | Balanced models | High-quality models |
| Rate Limiting | Generous limits | Production-like limits | Strict limits |
Migration Strategy Between Environments
Moving from development to production requires careful planning:
- Development validation: All new features work in development with synthetic data
- Staging integration: Features integrate with existing systems using anonymized production data
- Canary deployment: Roll out to 5% of production traffic, monitor metrics
- Full rollout: Deploy to 100% of production if canary metrics are healthy
- Rollback plan: Automated rollback if error rate exceeds 2% or latency increases by 50%
FAQ: OpenClaw Deployment Patterns
1. How do I handle database migrations across environments?
Use version-controlled migration scripts with environment-specific rollback strategies. In development, I allow destructive migrations. In staging and production, I use zero-downtime migration patterns like expand/contract or blue-green schema migrations.
2. What's the best way to manage API keys across environments?
Never commit API keys to version control. Use environment variables or secret managers. Development uses .env files, staging uses HashiCorp Vault with limited permissions, and production uses cloud-native secret managers with automatic rotation.
3. How much should staging environment resemble production?
Staging should be as close to production as possible, including infrastructure, data volume, and network topology. The main difference is traffic volume—staging handles synthetic load while production handles real user traffic.
4. When should I use feature flags in OpenClaw deployments?
Use feature flags for: A/B testing new agent behaviors, gradual rollouts of risky changes, emergency kill switches for problematic features, and environment-specific feature enablement (e.g., debugging tools only in development).
5. How do I handle model cost differences across environments?
Development uses cheaper models (Claude Haiku, GPT-3.5) for iteration speed. Staging uses the same models as production but with synthetic queries. Production uses optimal models for quality/cost balance, with fallbacks to cheaper models during traffic spikes.
Continue Learning
Ready to implement multi-environment deployments?
Get the complete OpenClaw Blueprint with production-ready configuration templates, deployment scripts, and monitoring dashboards.
Skip the trial and error
Get the OpenClaw Starter Kit — config templates, 5 ready-made skills, deployment checklist. Everything you need to go from zero to running in under an hour.
$14 $6.99
Get the Starter Kit →Also in the OpenClaw store
Get the free OpenClaw deployment checklist
Production-ready setup steps. Nothing you don't need.