Prompt file imported from databayt/hogwarts (
.claude/commands/ship.md). Copyright stays with the author.
Ship Command - Smart Deployment
Execute complete deployment pipeline with comprehensive validation, testing, and deployment.
Usage
/ship [environment]
Environments
staging- Deploy to staging environment (default)production- Deploy to production (requires confirmation)preview- Deploy to preview branch
Process
- Pre-Flight Checks: Validate readiness
- Test Suite: Run all tests
- Security Scan: Check for vulnerabilities
- Build: Production build with optimization
- Deploy: Push to target environment
- Verify: Health checks and monitoring
- Notify: Update team and stakeholders
Examples
# Deploy to staging (default)
/ship
/ship staging
# Deploy to production with confirmation
/ship production
# Deploy to preview environment
/ship preview
# Dry run without deploying
/ship staging --dry-run
Pre-Flight Checks
1. Code Quality
- ✅ No uncommitted changes
- ✅ Branch up to date
- ✅ No merge conflicts
2. Tests
- ✅ Unit tests passing
- ✅ Integration tests passing
- ✅ E2E tests passing
- ✅ Coverage ≥ 95%
3. Build
- ✅ TypeScript compilation
- ✅ No build errors
- ✅ Bundle size acceptable
4. Security
- ✅ No vulnerable dependencies
- ✅ No security violations
- ✅ Secrets not exposed
Deployment Pipeline
Stage 1: Validation
# Check git status
git status
# Verify branch
git branch --show-current
# Check for updates
git fetch
git status -uno
Stage 2: Test Execution
# Run tests suite
pnpm tests
# Run E2E tests
pnpm tests:e2e
# Check coverage
pnpm tests --coverage
Stage 3: Security Scan
# Dependency audit
pnpm audit
# Security scan
/security-scan
# Secret scanning
git secrets --scan
Stage 4: Build
# Production build
pnpm build
# Analyze bundle
ANALYZE=true pnpm build
# Verify build output
ls -la .next
Stage 5: Deploy
# Staging deployment
vercel --env=staging
# Production deployment
vercel --prod
# With environment variables
vercel --prod --build-env KEY=value
Stage 6: Verification
# Health check
curl https://app.domain.com/api/health
# Smoke tests
pnpm tests:smoke
# Performance check
lighthouse https://app.domain.com
Stage 7: Notification
# Update GitHub deployment
gh deployment create production
# Notify Slack
curl -X POST $SLACK_WEBHOOK -d '{
"text": "Deployment successful to production"
}'
# Update issue tracker
gh issue comment 123 --body "Deployed to production"
Environment-Specific Config
Staging
{
"staging": {
"url": "https://staging.databayt.org",
"branch": "develop",
"tests": ["unit", "integration"],
"requireApproval": false
}
}
Production
{
"production": {
"url": "https://ed.databayt.org",
"branch": "main",
"tests": ["unit", "integration", "e2e", "smoke"],
"requireApproval": true,
"notifications": ["slack", "email"]
}
}
Rollback Process
If deployment fails or issues detected:
# Quick rollback
vercel rollback
# Git-based rollback
git revert HEAD
git push
/ship production
# Database rollback
pnpm prisma migrate resolve --rolled-back
Progress Display
═══════════════════════════════════════
🚢 DEPLOYMENT PIPELINE
═══════════════════════════════════════
Environment: Production
Branch: main
Version: v2.1.0
✅ Pre-flight checks
✅ Tests (1,234 passing)
✅ Security scan (0 vulnerabilities)
⏳ Building... (2/4 steps)
⏸️ Deploy
⏸️ Verify
⏸️ Notify
Progress: ████████░░░░░░░░░░░░ 40%
Time: 3m 45s
═══════════════════════════════════════
Deployment Checklist
Before Deployment
- All stories in epic completed
- Code reviewed and approved
- Tests passing with good coverage
- No security vulnerabilities
- Performance benchmarks met
- Documentation updated
- Changelog updated
- Database migrations ready
During Deployment
- Monitor deployment logs
- Watch error rates
- Check performance metrics
- Verify functionality
- Run smoke tests
After Deployment
- Verify application health
- Check user-facing features
- Monitor error tracking
- Review performance metrics
- Update status page
- Notify stakeholders
Error Handling
Build Failures
- Check TypeScript errors
- Verify dependencies
- Clear cache and rebuild
- Check environment variables
Deployment Failures
- Check deployment logs
- Verify credentials
- Check network connectivity
- Review platform status
Post-Deploy Issues
- Check error monitoring
- Review application logs
- Verify database connectivity
- Check external services
Implementation
// Complete deployment pipeline
await invokeAgent("/agents/workflow/git", {
task: "ensure-clean-state",
})
await invokeAgent("/agents/quality/tests", {
task: "run-all-tests",
})
await invokeAgent("/agents/quality/secure", {
task: "security-audit",
})
await invokeAgent("/agents/devtools/build", {
task: "production-build",
})
await deployToEnvironment(environment)
await verifyDeployment(environment)
await notifyStakeholders(environment)
Metrics Tracked
Deployment Metrics
- Deployment frequency
- Lead time for changes
- Mean time to recovery
- Change failure rate
- Deployment duration
Quality Metrics
- Test pass rate
- Coverage percentage
- Build success rate
- Security score
- Performance score
Configuration
{
"ship": {
"environments": {
"staging": {
"autoApprove": true,
"runE2E": false,
"notifySlack": false
},
"production": {
"autoApprove": false,
"runE2E": true,
"notifySlack": true,
"requireTwoFactorAuth": true
}
},
"checks": {
"minCoverage": 95,
"maxBundleSize": "500KB",
"allowedVulnerabilities": 0
},
"rollback": {
"automatic": true,
"errorThreshold": 0.01
}
}
}
Success Criteria
✅ All pre-flight checks pass ✅ Test suite passes (100%) ✅ Security scan clean ✅ Build successful ✅ Deployment successful ✅ Health checks pass ✅ Stakeholders notified
Tips
- Always deploy to staging first
- Use feature flags for gradual rollout
- Monitor metrics after deployment
- Have rollback plan ready
- Document deployment process
- Automate everything possible
