Environment-aware deployment orchestrator with support for multiple strategies, automatic rollback, and health monitoring.
Orchestrates environment-aware deployments with blue-green, canary, and rolling strategies including automatic rollback.
/plugin marketplace add rafaelkamimura/claude-tools/plugin install rafaelkamimura-claude-tools@rafaelkamimura/claude-toolsEnvironment-aware deployment orchestrator with support for multiple strategies, automatic rollback, and health monitoring.
STOP → "Select deployment target:"
1. Development - Local/dev environment
2. Staging - Pre-production testing
3. Production - Live environment
4. Custom - Specify environment
Choose environment (1-4):
Deployment Strategy
1. Rolling update - Gradual replacement
2. Blue-green - Instant switchover
3. Canary - Percentage-based rollout
4. Recreate - Stop old, start new
5. Feature flag - Toggle-based
Choose strategy (1-5):
Deployment Options
Verify Build
# Check if build exists
if [ ! -f "dist/index.js" ] && [ ! -d "build" ]; then
echo "No build found. Running build..."
npm run build || make build || cargo build --release
fi
Run Tests
# Critical tests only
npm run test:smoke || pytest tests/smoke || go test ./tests/smoke
Check Dependencies
# Verify all dependencies are installed
npm ci --production || pip install -r requirements.txt --no-dev
Security Scan
# Quick security check
npm audit --production || safety check
Build Docker Image
# Build with version tag
VERSION=$(git describe --tags --always)
docker build -t myapp:$VERSION .
docker tag myapp:$VERSION myapp:latest
Push to Registry
# Push to registry (ECR, DockerHub, GCR)
docker push myapp:$VERSION
docker push myapp:latest
Deploy to Kubernetes
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
spec:
containers:
- name: myapp
image: myapp:VERSION
livenessProbe:
httpGet:
path: /health
port: 8080
readinessProbe:
httpGet:
path: /ready
port: 8080
Apply Deployment
kubectl apply -f deployment.yaml
kubectl rollout status deployment/myapp
AWS Lambda
# Package function
zip -r function.zip . -x "*.git*"
# Deploy
aws lambda update-function-code \
--function-name myapp \
--zip-file fileb://function.zip
# Update alias
aws lambda update-alias \
--function-name myapp \
--name production \
--function-version $LATEST
Vercel/Netlify
# Vercel
vercel --prod
# Netlify
netlify deploy --prod
Cloud Functions
# Google Cloud
gcloud functions deploy myapp \
--runtime nodejs18 \
--trigger-http \
--allow-unauthenticated
# Azure
func azure functionapp publish myapp
Setup Blue Environment
# Deploy to blue environment
kubectl apply -f blue-deployment.yaml
kubectl wait --for=condition=available deployment/myapp-blue
Run Smoke Tests
# Test blue environment
BLUE_URL="http://blue.myapp.com"
curl -f $BLUE_URL/health || exit 1
npm run test:e2e -- --url=$BLUE_URL
Switch Traffic
# Update service to point to blue
apiVersion: v1
kind: Service
metadata:
name: myapp
spec:
selector:
app: myapp
version: blue
Verify and Cleanup
# Monitor metrics
kubectl top pods -l app=myapp,version=blue
# Remove green after success
kubectl delete deployment myapp-green
Deploy Canary Version
# Deploy with 10% traffic
kubectl apply -f canary-deployment.yaml
kubectl scale deployment/myapp-canary --replicas=1
kubectl scale deployment/myapp-stable --replicas=9
Monitor Metrics
// Check error rates
const canaryErrors = await getMetrics('canary', 'errors');
const stableErrors = await getMetrics('stable', 'errors');
if (canaryErrors > stableErrors * 1.5) {
console.log('Canary failing, rolling back');
rollback();
}
Progressive Rollout
# Increase canary traffic
for percent in 10 25 50 75 100; do
updateTrafficSplit(canary: $percent, stable: $((100-$percent)))
sleep 300 # Wait 5 minutes
checkHealth() || rollback
done
Liveness Check
# Basic health endpoint
curl -f http://app.com/health || exit 1
Readiness Check
# Check if app is ready for traffic
curl -f http://app.com/ready || exit 1
Smoke Tests
// Critical path testing
const tests = [
() => checkHomepage(),
() => checkLogin(),
() => checkAPI(),
() => checkDatabase()
];
for (const test of tests) {
await test();
}
Performance Check
# Response time check
response_time=$(curl -w "%{time_total}" -o /dev/null -s http://app.com)
if (( $(echo "$response_time > 2" | bc -l) )); then
echo "Performance degraded"
rollback
fi
Automatic Rollback Triggers
rollback_conditions:
- health_check_failures: 3
- error_rate: > 5%
- response_time: > 2s
- memory_usage: > 90%
- crash_loop: true
Rollback Execution
# Kubernetes rollback
kubectl rollout undo deployment/myapp
# Docker rollback
docker service update --image myapp:previous myapp
# Lambda rollback
aws lambda update-alias \
--function-name myapp \
--function-version $PREVIOUS_VERSION
Database Rollback
# Rollback migrations
npm run migrate:down || python manage.py migrate previous_migration
Monitoring Setup
// Set up alerts
createAlert({
metric: 'error_rate',
threshold: 1,
duration: '5m',
action: 'notify'
});
Performance Baseline
# Capture metrics
kubectl top pods > metrics-baseline.txt
curl -X POST monitoring.api/baseline \
-d "{\"deployment\": \"$VERSION\", \"metrics\": $(cat metrics-baseline.txt)}"
Notification
## Deployment Successful
**Environment**: Production
**Version**: v2.3.1
**Strategy**: Blue-Green
**Duration**: 4m 32s
### Health Status
- API: ✅ Healthy
- Database: ✅ Connected
- Cache: ✅ Available
### Performance
- Response Time: 145ms (↓ 12%)
- Error Rate: 0.01% (→ 0%)
- Throughput: 1,200 req/s (↑ 8%)
### Next Steps
- Monitor for 30 minutes
- Check user feedback
- Review error logs
# Deployment Report
## Summary
- **Application**: MyApp
- **Version**: 2.3.1
- **Environment**: Production
- **Status**: SUCCESS
- **Duration**: 4m 32s
## Deployment Steps
| Step | Status | Duration |
|------|--------|----------|
| Pre-deployment tests | ✅ | 45s |
| Build Docker image | ✅ | 1m 20s |
| Push to registry | ✅ | 30s |
| Deploy to K8s | ✅ | 1m 15s |
| Health checks | ✅ | 42s |
| Traffic switch | ✅ | 10s |
## Validation Results
- Unit Tests: 156/156 passed
- Integration Tests: 42/42 passed
- Smoke Tests: 8/8 passed
- Security Scan: No issues
## Resource Usage
- CPU: 2.4 cores (60% of limit)
- Memory: 512MB (40% of limit)
- Pods: 3 running
## Rollback Plan
If issues occur:
1. Run: kubectl rollout undo deployment/myapp
2. Verify: kubectl rollout status deployment/myapp
3. Check: curl http://app.com/health
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
# Two identical environments
# Instant traffic switch
# Zero downtime
# Easy rollback
# Gradual traffic shift
# Risk mitigation
# A/B testing capable
# Metric-based promotion
{
"environments": {
"development": {
"url": "https://dev.myapp.com",
"strategy": "recreate",
"tests": "smoke"
},
"staging": {
"url": "https://staging.myapp.com",
"strategy": "rolling",
"tests": "full"
},
"production": {
"url": "https://myapp.com",
"strategy": "blue-green",
"tests": "smoke",
"approvals": ["lead", "qa"]
}
},
"rollback": {
"automatic": true,
"conditions": {
"errorRate": 0.05,
"responseTime": 2000
}
},
"notifications": {
"slack": "#deployments",
"email": ["team@company.com"]
}
}
Pre-Deployment
During Deployment
Post-Deployment