Production Readiness
Purpose
Comprehensive pre-deployment validation to ensure code is production-ready.
Specialist Agent
I am a production readiness specialist ensuring deployment safety.
Methodology (Deployment Gate Pattern):
- Complete quality audit (theater → functionality → style)
- Security deep-dive (vulnerabilities, secrets, unsafe patterns)
- Performance benchmarking (load testing, bottlenecks)
- Documentation validation (README, API docs, deployment docs)
- Dependency audit (outdated, vulnerable packages)
- Configuration check (environment variables, secrets management)
- Monitoring setup (logging, metrics, alerts)
- Rollback plan verification
- Generate deployment checklist
- Final go/no-go decision
Quality Gates (all must pass):
- ✅ All tests passing (100%)
- ✅ Code quality ≥ 85/100
- ✅ Test coverage ≥ 80%
- ✅ Zero critical security issues
- ✅ Zero high-severity bugs
- ✅ Performance within SLAs
- ✅ Documentation complete
- ✅ Rollback plan documented
Input Contract
input:
target_path: string (directory to validate, required)
environment: enum[staging, production] (default: production)
skip_performance: boolean (default: false)
strict_mode: boolean (default: true)
Output Contract
output:
ready_for_deployment: boolean
quality_gates: object
tests_passing: boolean
code_quality: number
test_coverage: number
security_clean: boolean
performance_ok: boolean
docs_complete: boolean
blocking_issues: array[issue]
warnings: array[warning]
deployment_checklist: array[task]
rollback_plan: markdown
Execution Flow
#!/bin/bash
set -e
TARGET_PATH="${1:-./}"
ENVIRONMENT="${2:-production}"
SKIP_PERFORMANCE="${3:-false}"
READINESS_DIR="production-readiness-$(date +%s)"
mkdir -p "$READINESS_DIR"
echo "================================================================"
echo "Production Readiness Check"
echo "Environment: $ENVIRONMENT"
echo "================================================================"
# Initialize quality gates
declare -A GATES
GATES[tests]=0
GATES[quality]=0
GATES[coverage]=0
GATES[security]=0
GATES[performance]=0
GATES[docs]=0
# GATE 1: Complete Quality Audit
echo "[1/10] Running complete quality audit..."
npx claude-flow audit-pipeline "$TARGET_PATH" \
--phase all \
--model codex-auto \
--output "$READINESS_DIR/quality-audit.json"
# Check tests
TESTS_PASSED=$(cat "$READINESS_DIR/quality-audit.json" | jq '.functionality_audit.all_passed')
if [ "$TESTS_PASSED" = "true" ]; then
GATES[tests]=1
echo "✅ GATE 1: Tests passing"
else
echo "❌ GATE 1: Tests failing"
fi
# Check code quality
QUALITY_SCORE=$(cat "$READINESS_DIR/quality-audit.json" | jq '.style_audit.quality_score')
if [ "$QUALITY_SCORE" -ge 85 ]; then
GATES[quality]=1
echo "✅ GATE 2: Code quality $QUALITY_SCORE/100"
else
echo "❌ GATE 2: Code quality too low: $QUALITY_SCORE/100 (need ≥85)"
fi
# Check test coverage
TEST_COVERAGE=$(cat "$READINESS_DIR/quality-audit.json" | jq '.functionality_audit.coverage_percent')
if [ "$TEST_COVERAGE" -ge 80 ]; then
GATES[coverage]=1
echo "✅ GATE 3: Test coverage $TEST_COVERAGE%"
else
echo "❌ GATE 3: Test coverage too low: $TEST_COVERAGE% (need ≥80%)"
fi
# GATE 2: Security Deep-Dive
echo "[2/10] Running security deep-dive..."
npx claude-flow security-scan "$TARGET_PATH" \
--deep true \
--check-secrets true \
--check-dependencies true \
--output "$READINESS_DIR/security-scan.json"
CRITICAL_SECURITY=$(cat "$READINESS_DIR/security-scan.json" | jq '.critical_issues')
HIGH_SECURITY=$(cat "$READINESS_DIR/security-scan.json" | jq '.high_issues')
if [ "$CRITICAL_SECURITY" -eq 0 ] && [ "$HIGH_SECURITY" -eq 0 ]; then
GATES[security]=1
echo "✅ GATE 4: Security scan clean"
else
echo "❌ GATE 4: Security issues found (Critical: $CRITICAL_SECURITY, High: $HIGH_SECURITY)"
fi
# GATE 3: Performance Benchmarking
if [ "$SKIP_PERFORMANCE" != "true" ]; then
echo "[3/10] Running performance benchmarks..."
# Baseline performance
npx claude-flow analysis performance-report \
--detailed true \
--export "$READINESS_DIR/performance-baseline.json"
# Bottleneck detection
npx claude-flow bottleneck detect \
--threshold 10 \
--export "$READINESS_DIR/bottlenecks.json"
# Check SLA compliance
AVG_RESPONSE_TIME=$(cat "$READINESS_DIR/performance-baseline.json" | jq '.avg_response_time')
P95_RESPONSE_TIME=$(cat "$READINESS_DIR/performance-baseline.json" | jq '.p95_response_time')
# SLAs: avg < 200ms, p95 < 500ms
if [ "$AVG_RESPONSE_TIME" -lt 200 ] && [ "$P95_RESPONSE_TIME" -lt 500 ]; then
GATES[performance]=1
echo "✅ GATE 5: Performance within SLAs"
else
echo "❌ GATE 5: Performance exceeds SLAs (avg: ${AVG_RESPONSE_TIME}ms, p95: ${P95_RESPONSE_TIME}ms)"
fi
else
echo "[3/10] Skipping performance benchmarks (--skip-performance)"
GATES[performance]=1 # Pass if skipped
fi
# GATE 4: Documentation Validation
echo "[4/10] Validating documentation..."
# Check for required docs
DOCS_COMPLETE=true
if [ ! -f "README.md" ]; then
echo "⚠️ Missing README.md"
DOCS_COMPLETE=false
fi
if [ ! -f "docs/deployment.md" ] && [ ! -f "DEPLOYMENT.md" ]; then
echo "⚠️ Missing deployment documentation"
DOCS_COMPLETE=false
fi
if [ "$ENVIRONMENT" = "production" ]; then
if [ ! -f "docs/rollback.md" ] && [ ! -f "ROLLBACK.md" ]; then
echo "⚠️ Missing rollback plan"
DOCS_COMPLETE=false
fi
fi
if [ "$DOCS_COMPLETE" = "true" ]; then
GATES[docs]=1
echo "✅ GATE 6: Documentation complete"
else
echo "❌ GATE 6: Documentation incomplete"
fi
# GATE 5: Dependency Audit
echo "[5/10] Auditing dependencies..."
if command -v npm &> /dev/null && [ -f "package.json" ]; then
npm audit --json > "$READINESS_DIR/npm-audit.json" 2>&1 || true
VULNERABLE_DEPS=$(cat "$READINESS_DIR/npm-audit.json" | jq '.metadata.vulnerabilities.high + .metadata.vulnerabilities.critical')
if [ "$VULNERABLE_DEPS" -gt 0 ]; then
echo "⚠️ Found $VULNERABLE_DEPS vulnerable dependencies"
else
echo "✅ No vulnerable dependencies"
fi
fi
# GATE 6: Configuration Check
echo "[6/10] Checking configuration..."
# Check for .env.example
if [ ! -f ".env.example" ] && [ -f ".env" ]; then
echo "⚠️ Missing .env.example file"
fi
# Check for hardcoded secrets
echo "Scanning for hardcoded secrets..."
grep -r "api_key\|password\|secret\|token" "$TARGET_PATH" --include="*.js" --include="*.ts" \
| grep -v "test" | grep -v "example" || echo "✅ No obvious hardcoded secrets"
# GATE 7: Monitoring Setup
echo "[7/10] Validating monitoring setup..."
# Check for logging
if grep -r "logger\|console.log\|winston\|pino" "$TARGET_PATH" --include="*.js" --include="*.ts" > /dev/null; then
echo "✅ Logging detected"
else
echo "⚠️ No logging framework detected"
fi
# GATE 8: Error Handling
echo "[8/10] Checking error handling..."
# Check for try-catch blocks
TRYCATCH_COUNT=$(grep -r "try {" "$TARGET_PATH" --include="*.js" --include="*.ts" | wc -l)
echo "Found $TRYCATCH_COUNT try-catch blocks"
# GATE 9: Load Testing (if not skipped)
if [ "$SKIP_PERFORMANCE" != "true" ] && [ "$ENVIRONMENT" = "production" ]; then
echo "[9/10] Running load tests..."
# Placeholder for load testing
echo "⚠️ Manual load testing required"
else
echo "[9/10] Skipping load tests"
fi
# GATE 10: Generate Deployment Checklist
echo "[10/10] Generating deployment checklist..."
cat > "$READINESS_DIR/DEPLOYMENT-CHECKLIST.md" <<EOF
# Deployment Checklist: $ENVIRONMENT
**Generated**: $(date -Iseconds)
## Quality Gates Status
| Gate | Status | Score/Details |
|------|--------|---------------|
| Tests Passing | $([ ${GATES[tests]} -eq 1 ] && echo "✅" || echo "❌") | $([ "$TESTS_PASSED" = "true" ] && echo "All tests passing" || echo "Tests failing") |
| Code Quality | $([ ${GATES[quality]} -eq 1 ] && echo "✅" || echo "❌") | $QUALITY_SCORE/100 (need ≥85) |
| Test Coverage | $([ ${GATES[coverage]} -eq 1 ] && echo "✅" || echo "❌") | $TEST_COVERAGE% (need ≥80%) |
| Security | $([ ${GATES[security]} -eq 1 ] && echo "✅" || echo "❌") | Critical: $CRITICAL_SECURITY, High: $HIGH_SECURITY |
| Performance | $([ ${GATES[performance]} -eq 1 ] && echo "✅" || echo "❌") | SLA compliance |
| Documentation | $([ ${GATES[docs]} -eq 1 ] && echo "✅" || echo "❌") | All required docs present |
## Pre-Deployment Checklist
### Code Quality
- [ ] All tests passing (100%)
- [ ] Code quality ≥ 85/100
- [ ] Test coverage ≥ 80%
- [ ] No linting errors
- [ ] No TypeScript errors
### Security
- [ ] No critical or high-severity vulnerabilities
- [ ] Dependencies up to date
- [ ] Secrets in environment variables (not hardcoded)
- [ ] Security headers configured
- [ ] Authentication/authorization tested
### Performance
- [ ] Response times within SLAs
- [ ] No performance bottlenecks
- [ ] Database queries optimized
- [ ] Caching configured
- [ ] Load tested
### Documentation
- [ ] README.md up to date
- [ ] API documentation complete
- [ ] Deployment guide available
- [ ] Rollback plan documented
- [ ] Environment variables documented
### Monitoring & Observability
- [ ] Logging configured
- [ ] Error tracking setup
- [ ] Metrics collection enabled
- [ ] Alerts configured
- [ ] Dashboard created
### Infrastructure
- [ ] Environment variables configured
- [ ] Database migrations ready
- [ ] Backup strategy verified
- [ ] Scaling configuration reviewed
- [ ] SSL certificates valid
### Rollback Plan
- [ ] Rollback procedure documented
- [ ] Previous version backed up
- [ ] Rollback tested
- [ ] Rollback SLA defined
## Deployment Steps
1. **Pre-deployment**
- Create deployment branch
- Final code review
- Merge to main/master
2. **Staging Deployment**
- Deploy to staging
- Run smoke tests
- Verify functionality
3. **Production Deployment**
- Create database backup
- Deploy to production
- Run health checks
- Monitor for errors
4. **Post-deployment**
- Verify functionality
- Monitor metrics
- Check error rates
- Document any issues
## Rollback Procedure
If deployment fails:
1. Stop deployment immediately
2. Execute rollback: \`./scripts/rollback.sh\`
3. Verify previous version restored
4. Investigate root cause
5. Fix issues before retry
## Sign-off
- [ ] **Development Lead**: Code review approved
- [ ] **QA Lead**: Testing complete
- [ ] **Security Team**: Security review approved
- [ ] **DevOps**: Infrastructure ready
- [ ] **Product Owner**: Features approved
---
🤖 Generated by Claude Code Production Readiness Check
EOF
# Calculate overall readiness
GATES_PASSED=$((${GATES[tests]} + ${GATES[quality]} + ${GATES[coverage]} + ${GATES[security]} + ${GATES[performance]} + ${GATES[docs]}))
TOTAL_GATES=6
READY_FOR_DEPLOYMENT="false"
if [ "$GATES_PASSED" -eq "$TOTAL_GATES" ]; then
READY_FOR_DEPLOYMENT="true"
fi
# Generate summary
echo ""
echo "================================================================"
echo "Production Readiness Assessment"
echo "================================================================"
echo ""
echo "Environment: $ENVIRONMENT"
echo "Gates Passed: $GATES_PASSED/$TOTAL_GATES"
echo ""
echo "Quality Gates:"
echo " Tests: $([ ${GATES[tests]} -eq 1 ] && echo "✅" || echo "❌")"
echo " Quality: $([ ${GATES[quality]} -eq 1 ] && echo "✅" || echo "❌") ($QUALITY_SCORE/100)"
echo " Coverage: $([ ${GATES[coverage]} -eq 1 ] && echo "✅" || echo "❌") ($TEST_COVERAGE%)"
echo " Security: $([ ${GATES[security]} -eq 1 ] && echo "✅" || echo "❌") (Critical: $CRITICAL_SECURITY, High: $HIGH_SECURITY)"
echo " Performance: $([ ${GATES[performance]} -eq 1 ] && echo "✅" || echo "❌")"
echo " Documentation: $([ ${GATES[docs]} -eq 1 ] && echo "✅" || echo "❌")"
echo ""
if [ "$READY_FOR_DEPLOYMENT" = "true" ]; then
echo "🚀 READY FOR DEPLOYMENT!"
echo ""
echo "Next steps:"
echo "1. Review deployment checklist: $READINESS_DIR/DEPLOYMENT-CHECKLIST.md"
echo "2. Get required sign-offs"
echo "3. Schedule deployment window"
echo "4. Execute deployment"
else
echo "🚫 NOT READY FOR DEPLOYMENT"
echo ""
echo "Blocking issues must be resolved before deployment."
echo "See detailed reports in: $READINESS_DIR/"
exit 1
fi
Integration Points
Cascades
- Final stage in
/feature-dev-complete cascade
- Part of
/release-preparation cascade
- Used by
/deploy-to-production cascade
Commands
- Uses:
/audit-pipeline, /security-scan, /performance-report
- Uses:
/bottleneck-detect, /test-coverage
Other Skills
- Invokes:
quick-quality-check, code-review-assistant
- Output to:
deployment-automation, rollback-planner
Usage Example
# Check production readiness
production-readiness . production
# Staging environment
production-readiness ./dist staging
# Skip performance tests
production-readiness . production --skip-performance
Failure Modes
- Tests failing: Block deployment, fix tests
- Security issues: Block deployment, fix vulnerabilities
- Poor quality: Block deployment, improve code
- Missing docs: Warning, but can proceed with approval
- Performance issues: Warning for staging, blocking for production
1---
2name: production-readiness
3description: Comprehensive pre-deployment validation ensuring code is production-ready. Runs complete audit pipeline, performance benchmarks, security scan, documentation check, and generates deployment checklist.
4tags: [deployment, production, validation, essential, tier-1]
5version: 1.0.0
6metadata:
7 source: https://skillmd.com/skills/aibot88/production-readiness
8---
9
10# Production Readiness
11
12## Purpose
13
14Comprehensive pre-deployment validation to ensure code is production-ready.
15
16## Specialist Agent
17
18I am a production readiness specialist ensuring deployment safety.
19
20**Methodology** (Deployment Gate Pattern):
211. Complete quality audit (theater → functionality → style)
222. Security deep-dive (vulnerabilities, secrets, unsafe patterns)
233. Performance benchmarking (load testing, bottlenecks)
244. Documentation validation (README, API docs, deployment docs)
255. Dependency audit (outdated, vulnerable packages)
266. Configuration check (environment variables, secrets management)
277. Monitoring setup (logging, metrics, alerts)
288. Rollback plan verification
299. Generate deployment checklist
3010. Final go/no-go decision
31
32**Quality Gates** (all must pass):
33- ✅ All tests passing (100%)
34- ✅ Code quality ≥ 85/100
35- ✅ Test coverage ≥ 80%
36- ✅ Zero critical security issues
37- ✅ Zero high-severity bugs
38- ✅ Performance within SLAs
39- ✅ Documentation complete
40- ✅ Rollback plan documented
41
42## Input Contract
43
44```yaml
45input:
46 target_path: string (directory to validate, required)
47 environment: enum[staging, production] (default: production)
48 skip_performance: boolean (default: false)
49 strict_mode: boolean (default: true)
50```
51
52## Output Contract
53
54```yaml
55output:
56 ready_for_deployment: boolean
57 quality_gates: object
58 tests_passing: boolean
59 code_quality: number
60 test_coverage: number
61 security_clean: boolean
62 performance_ok: boolean
63 docs_complete: boolean
64 blocking_issues: array[issue]
65 warnings: array[warning]
66 deployment_checklist: array[task]
67 rollback_plan: markdown
68```
69
70## Execution Flow
71
72```bash
73#!/bin/bash
74set -e
75
76TARGET_PATH="${1:-./}"
77ENVIRONMENT="${2:-production}"
78SKIP_PERFORMANCE="${3:-false}"
79
80READINESS_DIR="production-readiness-$(date +%s)"
81mkdir -p "$READINESS_DIR"
82
83echo "================================================================"
84echo "Production Readiness Check"
85echo "Environment: $ENVIRONMENT"
86echo "================================================================"
87
88# Initialize quality gates
89declare -A GATES
90GATES[tests]=0
91GATES[quality]=0
92GATES[coverage]=0
93GATES[security]=0
94GATES[performance]=0
95GATES[docs]=0
96
97# GATE 1: Complete Quality Audit
98echo "[1/10] Running complete quality audit..."
99npx claude-flow audit-pipeline "$TARGET_PATH" \
100 --phase all \
101 --model codex-auto \
102 --output "$READINESS_DIR/quality-audit.json"
103
104# Check tests
105TESTS_PASSED=$(cat "$READINESS_DIR/quality-audit.json" | jq '.functionality_audit.all_passed')
106if [ "$TESTS_PASSED" = "true" ]; then
107 GATES[tests]=1
108 echo "✅ GATE 1: Tests passing"
109else
110 echo "❌ GATE 1: Tests failing"
111fi
112
113# Check code quality
114QUALITY_SCORE=$(cat "$READINESS_DIR/quality-audit.json" | jq '.style_audit.quality_score')
115if [ "$QUALITY_SCORE" -ge 85 ]; then
116 GATES[quality]=1
117 echo "✅ GATE 2: Code quality $QUALITY_SCORE/100"
118else
119 echo "❌ GATE 2: Code quality too low: $QUALITY_SCORE/100 (need ≥85)"
120fi
121
122# Check test coverage
123TEST_COVERAGE=$(cat "$READINESS_DIR/quality-audit.json" | jq '.functionality_audit.coverage_percent')
124if [ "$TEST_COVERAGE" -ge 80 ]; then
125 GATES[coverage]=1
126 echo "✅ GATE 3: Test coverage $TEST_COVERAGE%"
127else
128 echo "❌ GATE 3: Test coverage too low: $TEST_COVERAGE% (need ≥80%)"
129fi
130
131# GATE 2: Security Deep-Dive
132echo "[2/10] Running security deep-dive..."
133npx claude-flow security-scan "$TARGET_PATH" \
134 --deep true \
135 --check-secrets true \
136 --check-dependencies true \
137 --output "$READINESS_DIR/security-scan.json"
138
139CRITICAL_SECURITY=$(cat "$READINESS_DIR/security-scan.json" | jq '.critical_issues')
140HIGH_SECURITY=$(cat "$READINESS_DIR/security-scan.json" | jq '.high_issues')
141
142if [ "$CRITICAL_SECURITY" -eq 0 ] && [ "$HIGH_SECURITY" -eq 0 ]; then
143 GATES[security]=1
144 echo "✅ GATE 4: Security scan clean"
145else
146 echo "❌ GATE 4: Security issues found (Critical: $CRITICAL_SECURITY, High: $HIGH_SECURITY)"
147fi
148
149# GATE 3: Performance Benchmarking
150if [ "$SKIP_PERFORMANCE" != "true" ]; then
151 echo "[3/10] Running performance benchmarks..."
152
153 # Baseline performance
154 npx claude-flow analysis performance-report \
155 --detailed true \
156 --export "$READINESS_DIR/performance-baseline.json"
157
158 # Bottleneck detection
159 npx claude-flow bottleneck detect \
160 --threshold 10 \
161 --export "$READINESS_DIR/bottlenecks.json"
162
163 # Check SLA compliance
164 AVG_RESPONSE_TIME=$(cat "$READINESS_DIR/performance-baseline.json" | jq '.avg_response_time')
165 P95_RESPONSE_TIME=$(cat "$READINESS_DIR/performance-baseline.json" | jq '.p95_response_time')
166
167 # SLAs: avg < 200ms, p95 < 500ms
168 if [ "$AVG_RESPONSE_TIME" -lt 200 ] && [ "$P95_RESPONSE_TIME" -lt 500 ]; then
169 GATES[performance]=1
170 echo "✅ GATE 5: Performance within SLAs"
171 else
172 echo "❌ GATE 5: Performance exceeds SLAs (avg: ${AVG_RESPONSE_TIME}ms, p95: ${P95_RESPONSE_TIME}ms)"
173 fi
174else
175 echo "[3/10] Skipping performance benchmarks (--skip-performance)"
176 GATES[performance]=1 # Pass if skipped
177fi
178
179# GATE 4: Documentation Validation
180echo "[4/10] Validating documentation..."
181
182# Check for required docs
183DOCS_COMPLETE=true
184
185if [ ! -f "README.md" ]; then
186 echo "⚠️ Missing README.md"
187 DOCS_COMPLETE=false
188fi
189
190if [ ! -f "docs/deployment.md" ] && [ ! -f "DEPLOYMENT.md" ]; then
191 echo "⚠️ Missing deployment documentation"
192 DOCS_COMPLETE=false
193fi
194
195if [ "$ENVIRONMENT" = "production" ]; then
196 if [ ! -f "docs/rollback.md" ] && [ ! -f "ROLLBACK.md" ]; then
197 echo "⚠️ Missing rollback plan"
198 DOCS_COMPLETE=false
199 fi
200fi
201
202if [ "$DOCS_COMPLETE" = "true" ]; then
203 GATES[docs]=1
204 echo "✅ GATE 6: Documentation complete"
205else
206 echo "❌ GATE 6: Documentation incomplete"
207fi
208
209# GATE 5: Dependency Audit
210echo "[5/10] Auditing dependencies..."
211if command -v npm &> /dev/null && [ -f "package.json" ]; then
212 npm audit --json > "$READINESS_DIR/npm-audit.json" 2>&1 || true
213
214 VULNERABLE_DEPS=$(cat "$READINESS_DIR/npm-audit.json" | jq '.metadata.vulnerabilities.high + .metadata.vulnerabilities.critical')
215 if [ "$VULNERABLE_DEPS" -gt 0 ]; then
216 echo "⚠️ Found $VULNERABLE_DEPS vulnerable dependencies"
217 else
218 echo "✅ No vulnerable dependencies"
219 fi
220fi
221
222# GATE 6: Configuration Check
223echo "[6/10] Checking configuration..."
224
225# Check for .env.example
226if [ ! -f ".env.example" ] && [ -f ".env" ]; then
227 echo "⚠️ Missing .env.example file"
228fi
229
230# Check for hardcoded secrets
231echo "Scanning for hardcoded secrets..."
232grep -r "api_key\|password\|secret\|token" "$TARGET_PATH" --include="*.js" --include="*.ts" \
233 | grep -v "test" | grep -v "example" || echo "✅ No obvious hardcoded secrets"
234
235# GATE 7: Monitoring Setup
236echo "[7/10] Validating monitoring setup..."
237
238# Check for logging
239if grep -r "logger\|console.log\|winston\|pino" "$TARGET_PATH" --include="*.js" --include="*.ts" > /dev/null; then
240 echo "✅ Logging detected"
241else
242 echo "⚠️ No logging framework detected"
243fi
244
245# GATE 8: Error Handling
246echo "[8/10] Checking error handling..."
247
248# Check for try-catch blocks
249TRYCATCH_COUNT=$(grep -r "try {" "$TARGET_PATH" --include="*.js" --include="*.ts" | wc -l)
250echo "Found $TRYCATCH_COUNT try-catch blocks"
251
252# GATE 9: Load Testing (if not skipped)
253if [ "$SKIP_PERFORMANCE" != "true" ] && [ "$ENVIRONMENT" = "production" ]; then
254 echo "[9/10] Running load tests..."
255 # Placeholder for load testing
256 echo "⚠️ Manual load testing required"
257else
258 echo "[9/10] Skipping load tests"
259fi
260
261# GATE 10: Generate Deployment Checklist
262echo "[10/10] Generating deployment checklist..."
263
264cat > "$READINESS_DIR/DEPLOYMENT-CHECKLIST.md" <<EOF
265# Deployment Checklist: $ENVIRONMENT
266
267**Generated**: $(date -Iseconds)
268
269## Quality Gates Status
270
271| Gate | Status | Score/Details |
272|------|--------|---------------|
273| Tests Passing | $([ ${GATES[tests]} -eq 1 ] && echo "✅" || echo "❌") | $([ "$TESTS_PASSED" = "true" ] && echo "All tests passing" || echo "Tests failing") |
274| Code Quality | $([ ${GATES[quality]} -eq 1 ] && echo "✅" || echo "❌") | $QUALITY_SCORE/100 (need ≥85) |
275| Test Coverage | $([ ${GATES[coverage]} -eq 1 ] && echo "✅" || echo "❌") | $TEST_COVERAGE% (need ≥80%) |
276| Security | $([ ${GATES[security]} -eq 1 ] && echo "✅" || echo "❌") | Critical: $CRITICAL_SECURITY, High: $HIGH_SECURITY |
277| Performance | $([ ${GATES[performance]} -eq 1 ] && echo "✅" || echo "❌") | SLA compliance |
278| Documentation | $([ ${GATES[docs]} -eq 1 ] && echo "✅" || echo "❌") | All required docs present |
279
280## Pre-Deployment Checklist
281
282### Code Quality
283- [ ] All tests passing (100%)
284- [ ] Code quality ≥ 85/100
285- [ ] Test coverage ≥ 80%
286- [ ] No linting errors
287- [ ] No TypeScript errors
288
289### Security
290- [ ] No critical or high-severity vulnerabilities
291- [ ] Dependencies up to date
292- [ ] Secrets in environment variables (not hardcoded)
293- [ ] Security headers configured
294- [ ] Authentication/authorization tested
295
296### Performance
297- [ ] Response times within SLAs
298- [ ] No performance bottlenecks
299- [ ] Database queries optimized
300- [ ] Caching configured
301- [ ] Load tested
302
303### Documentation
304- [ ] README.md up to date
305- [ ] API documentation complete
306- [ ] Deployment guide available
307- [ ] Rollback plan documented
308- [ ] Environment variables documented
309
310### Monitoring & Observability
311- [ ] Logging configured
312- [ ] Error tracking setup
313- [ ] Metrics collection enabled
314- [ ] Alerts configured
315- [ ] Dashboard created
316
317### Infrastructure
318- [ ] Environment variables configured
319- [ ] Database migrations ready
320- [ ] Backup strategy verified
321- [ ] Scaling configuration reviewed
322- [ ] SSL certificates valid
323
324### Rollback Plan
325- [ ] Rollback procedure documented
326- [ ] Previous version backed up
327- [ ] Rollback tested
328- [ ] Rollback SLA defined
329
330## Deployment Steps
331
3321. **Pre-deployment**
333 - Create deployment branch
334 - Final code review
335 - Merge to main/master
336
3372. **Staging Deployment**
338 - Deploy to staging
339 - Run smoke tests
340 - Verify functionality
341
3423. **Production Deployment**
343 - Create database backup
344 - Deploy to production
345 - Run health checks
346 - Monitor for errors
347
3484. **Post-deployment**
349 - Verify functionality
350 - Monitor metrics
351 - Check error rates
352 - Document any issues
353
354## Rollback Procedure
355
356If deployment fails:
357
3581. Stop deployment immediately
3592. Execute rollback: \`./scripts/rollback.sh\`
3603. Verify previous version restored
3614. Investigate root cause
3625. Fix issues before retry
363
364## Sign-off
365
366- [ ] **Development Lead**: Code review approved
367- [ ] **QA Lead**: Testing complete
368- [ ] **Security Team**: Security review approved
369- [ ] **DevOps**: Infrastructure ready
370- [ ] **Product Owner**: Features approved
371
372---
373
374🤖 Generated by Claude Code Production Readiness Check
375EOF
376
377# Calculate overall readiness
378GATES_PASSED=$((${GATES[tests]} + ${GATES[quality]} + ${GATES[coverage]} + ${GATES[security]} + ${GATES[performance]} + ${GATES[docs]}))
379TOTAL_GATES=6
380
381READY_FOR_DEPLOYMENT="false"
382if [ "$GATES_PASSED" -eq "$TOTAL_GATES" ]; then
383 READY_FOR_DEPLOYMENT="true"
384fi
385
386# Generate summary
387echo ""
388echo "================================================================"
389echo "Production Readiness Assessment"
390echo "================================================================"
391echo ""
392echo "Environment: $ENVIRONMENT"
393echo "Gates Passed: $GATES_PASSED/$TOTAL_GATES"
394echo ""
395echo "Quality Gates:"
396echo " Tests: $([ ${GATES[tests]} -eq 1 ] && echo "✅" || echo "❌")"
397echo " Quality: $([ ${GATES[quality]} -eq 1 ] && echo "✅" || echo "❌") ($QUALITY_SCORE/100)"
398echo " Coverage: $([ ${GATES[coverage]} -eq 1 ] && echo "✅" || echo "❌") ($TEST_COVERAGE%)"
399echo " Security: $([ ${GATES[security]} -eq 1 ] && echo "✅" || echo "❌") (Critical: $CRITICAL_SECURITY, High: $HIGH_SECURITY)"
400echo " Performance: $([ ${GATES[performance]} -eq 1 ] && echo "✅" || echo "❌")"
401echo " Documentation: $([ ${GATES[docs]} -eq 1 ] && echo "✅" || echo "❌")"
402echo ""
403
404if [ "$READY_FOR_DEPLOYMENT" = "true" ]; then
405 echo "🚀 READY FOR DEPLOYMENT!"
406 echo ""
407 echo "Next steps:"
408 echo "1. Review deployment checklist: $READINESS_DIR/DEPLOYMENT-CHECKLIST.md"
409 echo "2. Get required sign-offs"
410 echo "3. Schedule deployment window"
411 echo "4. Execute deployment"
412else
413 echo "🚫 NOT READY FOR DEPLOYMENT"
414 echo ""
415 echo "Blocking issues must be resolved before deployment."
416 echo "See detailed reports in: $READINESS_DIR/"
417 exit 1
418fi
419```
420
421## Integration Points
422
423### Cascades
424- Final stage in `/feature-dev-complete` cascade
425- Part of `/release-preparation` cascade
426- Used by `/deploy-to-production` cascade
427
428### Commands
429- Uses: `/audit-pipeline`, `/security-scan`, `/performance-report`
430- Uses: `/bottleneck-detect`, `/test-coverage`
431
432### Other Skills
433- Invokes: `quick-quality-check`, `code-review-assistant`
434- Output to: `deployment-automation`, `rollback-planner`
435
436## Usage Example
437
438```bash
439# Check production readiness
440production-readiness . production
441
442# Staging environment
443production-readiness ./dist staging
444
445# Skip performance tests
446production-readiness . production --skip-performance
447```
448
449## Failure Modes
450
451- **Tests failing**: Block deployment, fix tests
452- **Security issues**: Block deployment, fix vulnerabilities
453- **Poor quality**: Block deployment, improve code
454- **Missing docs**: Warning, but can proceed with approval
455- **Performance issues**: Warning for staging, blocking for production