Workflow-008: Production Deployment
Document Control
- Workflow ID: 008
- Version: 1.0
- Status: Active
- Complexity: High
- Duration: 2-8 hours
- Team Size: 2-5 developers
Overview
End-to-end production deployment workflow using Claude Code for automated testing, security validation, and deployment orchestration.
┌─────────────────────────────────────────────────────────────────────┐
│ PRODUCTION DEPLOYMENT FLOW │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ [1] PRE-DEPLOY [2] SECURITY [3] BUILD [4] DEPLOY │
│ ┌────────────┐ ┌────────────┐ ┌────────────┐ ┌──────────┐ │
│ │ • Tests │ ──► │ • Scan │──► │ • Assets │─► │ • Stage │ │
│ │ • Lint │ │ • Audit │ │ • Bundle │ │ • Prod │ │
│ │ • Types │ │ • Secrets │ │ • Optimize │ │ • Verify │ │
│ └────────────┘ └────────────┘ └────────────┘ └──────────┘ │
│ │ │ │ │ │
│ ▼ ▼ ▼ ▼ │
│ [5] MONITOR [6] ROLLBACK [7] CLEANUP [8] REPORT │
│ ┌────────────┐ ┌────────────┐ ┌────────────┐ ┌──────────┐ │
│ │ • Health │ │ • Previous │ │ • Artifacts│ │ • Metrics│ │
│ │ • Metrics │ │ • Version │ │ • Logs │ │ • Status │ │
│ │ • Alerts │ │ • Recovery │ │ • Temp │ │ • Team │ │
│ └────────────┘ └────────────┘ └────────────┘ └──────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────┘Prerequisites
Required SOPs
- [x] SOP-001: API Setup
- [x] SOP-008: GitHub Integration
- [x] SOP-012: Error Handling
- [x] SOP-013: Testing Framework
- [x] SOP-014: Monitoring & Logging
Environment Setup
- Production infrastructure ready
- Deployment pipeline configured
- Monitoring systems active
- Rollback procedures tested
Phase 1: Pre-Deployment Validation
Step 1.1: Comprehensive Testing
bash
# Run full test suite
claude-code "Run all tests including unit, integration, and e2e tests. Show detailed results."
# Performance testing
claude-code "Run performance tests and benchmark against production requirements"
# Load testing
claude-code "Execute load tests to verify the system can handle expected traffic"Step 1.2: Code Quality Checks
bash
# Linting and formatting
claude-code "Run all linting checks and fix any issues"
# Type checking
claude-code "Perform TypeScript type checking and resolve any type errors"
# Code coverage analysis
claude-code "Generate code coverage report and ensure it meets our 80% threshold"Step 1.3: Dependency Audit
bash
# Security audit
claude-code "Run npm/pip security audit and fix any vulnerable dependencies"
# License compliance
claude-code "Check all dependencies for license compliance issues"
# Version compatibility
claude-code "Verify all dependencies are compatible with production environment"Phase 2: Security Validation
Step 2.1: Security Scanning
bash
# Static security analysis
claude-code "Run SAST (static application security testing) on the codebase"
# Dependency vulnerabilities
claude-code "Scan for known vulnerabilities in dependencies and generate report"
# Container security (if applicable)
claude-code "Scan Docker images for security vulnerabilities"Step 2.2: Secrets Management
bash
# Secrets audit
claude-code "Scan the codebase for accidentally committed secrets or API keys"
# Environment variables validation
claude-code "Verify all required environment variables are set for production"
# Configuration security
claude-code "Review production configuration for security best practices"Step 2.3: Compliance Checks
bash
# GDPR compliance (if applicable)
claude-code "Review data handling for GDPR compliance requirements"
# Security headers
claude-code "Verify all required security headers are implemented"
# Authentication audit
claude-code "Review authentication and authorization implementation"Phase 3: Build & Optimization
Step 3.1: Production Build
bash
# Clean build environment
claude-code "Clean all build artifacts and node_modules, then install fresh dependencies"
# Production build
claude-code "Build the application for production with optimizations enabled"
# Asset optimization
claude-code "Optimize images, minify CSS/JS, and compress assets for production"Step 3.2: Bundle Analysis
bash
# Bundle size analysis
claude-code "Analyze bundle sizes and identify any unusually large dependencies"
# Performance optimization
claude-code "Check for potential performance optimizations in the build output"
# Tree shaking verification
claude-code "Verify that tree shaking is working correctly and dead code is eliminated"Step 3.3: Build Verification
bash
# Build integrity check
claude-code "Verify the production build starts correctly and all routes are accessible"
# Environment-specific testing
claude-code "Test the build with production-like environment variables"
# Critical path testing
claude-code "Test the most critical user workflows against the production build"Phase 4: Deployment Execution
Step 4.1: Staging Deployment
bash
# Deploy to staging
claude-code "Deploy the application to staging environment and verify deployment"
# Staging smoke tests
claude-code "Run smoke tests against the staging deployment"
# Integration testing
claude-code "Run integration tests against staging to verify external service connections"Step 4.2: Production Deployment
bash
# Database migration (if needed)
claude-code "Run database migrations in production (if any are pending)"
# Blue-green deployment
claude-code "Deploy to production using blue-green deployment strategy"
# Health checks
claude-code "Verify all health check endpoints are responding correctly"Step 4.3: Traffic Validation
bash
# Gradual traffic increase
claude-code "Monitor the deployment and gradually increase traffic if all metrics are healthy"
# Real user monitoring
claude-code "Check real user metrics and error rates from the new deployment"
# Performance monitoring
claude-code "Monitor response times, CPU, memory usage during traffic ramp-up"Phase 5: Post-Deployment Monitoring
Step 5.1: Health Monitoring
bash
# System health check
claude-code "Check all system health metrics including CPU, memory, disk, and network"
# Application health
claude-code "Verify all application endpoints are responding within SLA requirements"
# Database health
claude-code "Check database connection pools, query performance, and replication status"Step 5.2: Performance Validation
bash
# Response time monitoring
claude-code "Monitor API response times and compare against pre-deployment baselines"
# Throughput analysis
claude-code "Verify the system is handling the expected request throughput"
# Error rate monitoring
claude-code "Monitor error rates and ensure they're within acceptable thresholds"Step 5.3: Business Metrics
bash
# User activity monitoring
claude-code "Monitor user activity patterns and conversion rates"
# Feature usage analytics
claude-code "Track usage of newly deployed features"
# Revenue impact analysis
claude-code "Monitor revenue metrics if applicable to the deployment"Phase 6: Rollback Procedures (If Needed)
Step 6.1: Rollback Decision
bash
# Issue assessment
claude-code "Assess the severity of issues and determine if rollback is necessary"
# Stakeholder notification
claude-code "Notify stakeholders about the issues and rollback decision"
# Impact analysis
claude-code "Analyze the impact of rolling back vs fixing forward"Step 6.2: Rollback Execution
bash
# Database rollback (if needed)
claude-code "Rollback database migrations if they were part of this deployment"
# Application rollback
claude-code "Rollback the application to the previous known good version"
# Configuration rollback
claude-code "Restore previous configuration settings"Step 6.3: Post-Rollback Verification
bash
# System verification
claude-code "Verify the system is fully functional after rollback"
# Data integrity check
claude-code "Check data integrity after rollback operations"
# User communication
claude-code "Prepare communication for users about the rollback"Phase 7: Cleanup & Documentation
Step 7.1: Artifact Cleanup
bash
# Clean build artifacts
claude-code "Clean up temporary build artifacts and deployment files"
# Log archival
claude-code "Archive deployment logs for future reference"
# Temporary resource cleanup
claude-code "Remove any temporary cloud resources created during deployment"Step 7.2: Documentation Updates
bash
# Deployment documentation
claude-code "Update deployment documentation with any new procedures learned"
# Runbook updates
claude-code "Update operational runbooks based on deployment experience"
# Architecture documentation
claude-code "Update architecture diagrams if any changes were made"Step 7.3: Knowledge Sharing
bash
# Post-deployment review
claude-code "Schedule and prepare agenda for post-deployment review meeting"
# Lessons learned documentation
claude-code "Document lessons learned and improvement opportunities"
# Team communication
claude-code "Prepare deployment summary for team and stakeholders"Phase 8: Reporting & Analysis
Step 8.1: Deployment Report
bash
# Success metrics report
claude-code "Generate report showing deployment success metrics and timeline"
# Performance comparison
claude-code "Compare pre and post-deployment performance metrics"
# Issue summary
claude-code "Summarize any issues encountered and how they were resolved"Step 8.2: Stakeholder Communication
bash
# Executive summary
claude-code "Create executive summary of deployment results"
# Technical team update
claude-code "Send detailed technical update to development teams"
# Customer communication
claude-code "Prepare customer-facing communication about new features (if applicable)"Step 8.3: Continuous Improvement
bash
# Process improvement
claude-code "Analyze deployment process and identify improvement opportunities"
# Automation opportunities
claude-code "Identify manual steps that could be automated"
# Tool evaluation
claude-code "Evaluate new tools or services that could improve future deployments"Advanced Deployment Patterns
Blue-Green Deployment
bash
# Setup blue-green infrastructure
claude-code "Set up blue-green deployment infrastructure with load balancer"
# Deploy to inactive environment
claude-code "Deploy new version to the inactive (green) environment"
# Switch traffic
claude-code "After validation, switch traffic from blue to green environment"Canary Deployment
bash
# Deploy canary version
claude-code "Deploy new version to subset of production infrastructure"
# Monitor canary metrics
claude-code "Monitor canary deployment metrics and error rates"
# Gradual rollout
claude-code "Gradually increase traffic to canary version based on metrics"Rolling Deployment
bash
# Rolling update strategy
claude-code "Update instances one at a time to maintain service availability"
# Health check validation
claude-code "Validate each instance is healthy before updating the next one"
# Rollback individual instances
claude-code "Rollback individual instances if health checks fail"Container Deployment
Docker Deployment
bash
# Build production image
claude-code "Build Docker image with production optimizations"
# Security scanning
claude-code "Scan Docker image for security vulnerabilities"
# Registry push
claude-code "Tag and push image to production container registry"
# Container deployment
claude-code "Deploy container to production orchestration platform"Kubernetes Deployment
bash
# Manifest validation
claude-code "Validate Kubernetes deployment manifests"
# Resource allocation
claude-code "Verify resource requests and limits are appropriate"
# Deployment execution
claude-code "Apply Kubernetes manifests and monitor pod startup"
# Service verification
claude-code "Verify services and ingress are working correctly"Cloud Platform Integration
AWS Deployment
bash
# ECS deployment
claude-code "Deploy to AWS ECS with proper task definitions"
# Lambda deployment
claude-code "Deploy serverless functions to AWS Lambda"
# S3 asset deployment
claude-code "Deploy static assets to S3 with CloudFront invalidation"Google Cloud Deployment
bash
# Cloud Run deployment
claude-code "Deploy containerized app to Google Cloud Run"
# App Engine deployment
claude-code "Deploy to Google App Engine with proper scaling settings"
# Firebase hosting
claude-code "Deploy frontend assets to Firebase hosting"Azure Deployment
bash
# Container Instances
claude-code "Deploy to Azure Container Instances"
# App Service deployment
claude-code "Deploy web application to Azure App Service"
# Static Web Apps
claude-code "Deploy static frontend to Azure Static Web Apps"Monitoring & Alerting
Application Monitoring
bash
# APM setup
claude-code "Configure Application Performance Monitoring"
# Custom metrics
claude-code "Set up custom business metrics monitoring"
# Distributed tracing
claude-code "Configure distributed tracing for microservices"Alert Configuration
bash
# Error rate alerts
claude-code "Set up alerts for elevated error rates"
# Performance alerts
claude-code "Configure alerts for response time degradation"
# Resource alerts
claude-code "Set up alerts for high resource utilization"Security Considerations
Runtime Security
bash
# Runtime protection
claude-code "Configure runtime application security protection"
# Vulnerability scanning
claude-code "Set up continuous vulnerability scanning"
# Compliance monitoring
claude-code "Configure compliance monitoring for production environment"Access Controls
bash
# Production access
claude-code "Review and audit production access permissions"
# Service accounts
claude-code "Audit service account permissions and keys"
# Network security
claude-code "Verify network security groups and firewall rules"Disaster Recovery
Backup Verification
bash
# Data backup validation
claude-code "Verify all critical data is being backed up"
# Configuration backup
claude-code "Ensure configuration and infrastructure are backed up"
# Recovery testing
claude-code "Test disaster recovery procedures"Business Continuity
bash
# Failover procedures
claude-code "Document and test failover procedures"
# Service dependencies
claude-code "Map and test all service dependencies"
# Communication plan
claude-code "Update incident communication procedures"Success Metrics
Deployment KPIs
| Metric | Target | Measurement |
|---|---|---|
| Deployment Success Rate | >95% | Successful deployments / Total deployments |
| Mean Time to Deploy | <30 min | Average deployment duration |
| Rollback Rate | <5% | Rollbacks / Total deployments |
| Mean Time to Recovery | <15 min | Time from issue detection to resolution |
Quality Metrics
| Metric | Target | Measurement |
|---|---|---|
| Post-Deploy Error Rate | <0.1% | Errors / Total requests |
| Performance Regression | <10% | Response time increase |
| Availability | >99.9% | Uptime during deployment window |
| Security Issues | 0 | Critical/High security findings |
Emergency Procedures
Incident Response
bash
# Issue detection
claude-code "Set up automated issue detection and alerting"
# Escalation procedures
claude-code "Define clear escalation paths for different issue severities"
# Communication protocols
claude-code "Establish incident communication protocols"Quick Recovery
bash
# Emergency rollback
claude-code "Execute emergency rollback procedure"
# Traffic redirection
claude-code "Redirect traffic to backup systems if needed"
# Status page updates
claude-code "Update status page with current incident information"Production Readiness Checklist:
- [ ] All tests pass
- [ ] Security scans clean
- [ ] Performance verified
- [ ] Monitoring configured
- [ ] Rollback tested
- [ ] Team notified
- [ ] Documentation updated
Next Steps: After successful deployment, proceed to SOP-014: Monitoring & Logging for ongoing operations.