| name | deployment-procedures |
| description | Production deployment procedures including pre-deployment checklist, deployment workflow, post-deployment verification, and rollback procedures. CRITICAL skill for safe deployments. |
Deployment Procedures
⚠️ CRITICAL SKILL: This skill handles production deployments. Always follow procedures carefully.
Overview
This skill provides step-by-step procedures for safe production deployments.
Pre-Deployment Checklist
Before ANY deployment, verify:
## Pre-Deployment Checklist
### Code Quality
- [ ] All tests passing (unit, integration, e2e)
- [ ] Code reviewed and approved
- [ ] No linting errors
- [ ] No TypeScript errors
- [ ] No console.log statements
### Build
- [ ] Production build successful
- [ ] Bundle size acceptable
- [ ] No build warnings
### Environment
- [ ] All environment variables configured
- [ ] Secrets up to date
- [ ] Database migrations ready
- [ ] Feature flags set correctly
### Communication
- [ ] Team notified of deployment
- [ ] Stakeholders informed (if major)
- [ ] Support team aware
### Safety
- [ ] Rollback plan documented
- [ ] Database backup completed
- [ ] Current version noted
- [ ] Monitoring dashboard open
Deployment Workflow
Step 1: BACKUP
pm2 list
git log -1 --oneline
cp -r /app/current /backup/app-$(date +%Y%m%d-%H%M%S)
pg_dump -h localhost -U dbuser dbname > backup-$(date +%Y%m%d).sql
Step 2: BUILD
git pull origin main
npm ci --production
npm run build
npm run migrate
Step 3: DEPLOY
pm2 reload ecosystem.config.js --update-env
docker-compose pull
docker-compose up -d
Step 4: VERIFY
pm2 list
curl -s http://localhost:3000/health
pm2 logs app-name --lines 50
curl -s http://localhost:3000/api/status
Step 5: CONFIRM OR ROLLBACK
If issues detected → Execute Rollback Procedure
If all good → Confirm deployment complete
Post-Deployment Verification
#!/bin/bash
echo "=== Post-Deployment Verification ==="
echo -n "Health Check: "
STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/health)
if [ "$STATUS" = "200" ]; then
echo "✅ PASS"
else
echo "❌ FAIL (Status: $STATUS)"
exit 1
fi
echo -n "API Status: "
API_STATUS=$(curl -s http://localhost:3000/api/status | jq -r '.status')
if [ "$API_STATUS" = "ok" ]; then
echo "✅ PASS"
else
echo "❌ FAIL"
exit 1
fi
echo -n "Error Check: "
ERRORS=$(pm2 logs app-name --lines 100 --nostream 2>&1 | grep -c "ERROR\|Error\|error")
if [ "$ERRORS" -lt 5 ]; then
echo "✅ PASS ($ERRORS errors)"
else
echo "⚠️ WARNING ( errors detected)"
-n
pm2 show app-name | grep
Rollback Procedure
Quick Rollback
#!/bin/bash
echo "⚠️ Starting Rollback..."
pm2 stop app-name
LATEST_BACKUP=$(ls -t /backup/ | head -1)
rm -rf /app/current/*
cp -r /backup/$LATEST_BACKUP/* /app/current/
pm2 start app-name
curl -s http://localhost:3000/health
echo "✅ Rollback Complete"
Database Rollback
psql -h localhost -U dbuser -d dbname < /backup/latest.sql
npm run migrate:down
PM2 Commands Reference
pm2 start ecosystem.config.js
pm2 reload app-name
pm2 restart app-name
pm2 stop app-name
pm2 delete app-name
pm2 list
pm2 monit
pm2 logs app-name
pm2 show app-name
pm2 scale app-name 4
pm2 save
pm2 startup
Emergency Procedures
Service Completely Down
pm2 list
df -h && free -m && top -bn1 | head -20
pm2 logs app-name --err --lines 200
pm2 restart app-name
./rollback.sh
High CPU/Memory
pm2 monit
pm2 scale app-name 1
pm2 restart app-name
pm2 scale app-name +2
Modern Deployment & AIOps (2025)
AI-Monitored Canary Release
- Shift 1% traffic to 'Green' environment.
- AI monitor analyzes logs/metrics for 60 seconds.
- If anomaly score > threshold, trigger auto-rollback.
- Else, increase traffic to 10%, then 100%.
Predictive Incident Management
- Use AI to scan logs during deployment for "Silent Failures" (errors that don't trigger HTTP 500s but show logical drift).
- Auto-Mitigation: AI can auto-scale instances if it predicts a traffic spike based on deployment-related latency increase.
Infrastructure-as-Code (2025)
- Pulumi/Terraform: Use AI-generated, security-hardened templates with least-privilege IAM roles.
Best Practices
- Never deploy on Fridays (unless urgent)
- Always have rollback plan ready
- Monitor for 15+ minutes after deploy
- Small, frequent deploys over big releases
- Use feature flags for risky changes
- Document all deployments in changelog