/deploy
/deploy
Section titled “/deploy”Safe, automated deployments with built-in validation, health checks, and rollback capabilities.
Purpose
Section titled “Purpose”Handles deployment workflow including:
- Pre-deployment validation
- Build verification
- Security scanning
- Environment-specific deployment
- Post-deployment health checks
- Monitoring and rollback
Ensures safe deployments with comprehensive checks at every stage.
/deploy [environment]Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
staging | Deploy to staging environment |
production | Deploy to production (requires confirmation) |
preview | Deploy to preview/ephemeral environment |
Workflow
Section titled “Workflow”Pre-Deploy Checks
Section titled “Pre-Deploy Checks”Before any deployment, the command validates:
1. Build Verification
Section titled “1. Build Verification”Python projects:
python -m buildpython -m pytestNode.js projects:
pnpm buildpnpm testValidation:
- Build completes successfully
- No build warnings
- Build artifacts are generated
- Output size is reasonable
2. Run Tests
Section titled “2. Run Tests”Executes full test suite:
# Pythonpytest -v --cov=src --cov-report=term
# Node.jspnpm testpnpm test:e2eRequirements:
- All tests pass
- Coverage meets threshold (80%+)
- No skipped tests
- E2E tests pass
3. Security Scan
Section titled “3. Security Scan”Checks for vulnerabilities:
Node.js:
npm audit --audit-level=highpnpm audit --audit-level=highPython:
pip-auditsafety checkValidation:
- No high/critical vulnerabilities
- Dependencies are up to date
- No known security issues
4. Environment Verification
Section titled “4. Environment Verification”Staging:
- Staging branch is up to date
- No merge conflicts
- Environment variables configured
Production:
- Production branch matches main/master
- All PRs merged and approved
- Release notes prepared
- Rollback plan ready
Deploy Process
Section titled “Deploy Process”Staging Deployment
Section titled “Staging Deployment”Automated deployment to staging:
# Build for stagingpnpm build:staging
# Deploy to staging environment# (Implementation depends on your hosting)Common platforms:
Vercel:
vercel deploy --prod=falseCloudflare Pages:
wrangler pages deploy dist --project-name=app-stagingAWS:
aws deploy create-deployment \ --application-name my-app \ --deployment-group-name stagingHeroku:
git push heroku-staging mainProduction Deployment
Section titled “Production Deployment”Requires explicit confirmation:
⚠️ Production DeploymentThis will deploy to production environment.
Environment: productionVersion: v1.2.3Commits: 15 new commits since last deploy
Continue? (yes/no):After confirmation:
# Tag releasegit tag -a v1.2.3 -m "Release v1.2.3"git push origin v1.2.3
# Build for productionpnpm build:production
# Deploy# (Platform-specific deployment)Post-Deploy Validation
Section titled “Post-Deploy Validation”After deployment, automated checks run:
1. Health Checks
Section titled “1. Health Checks”# Check application healthcurl https://app.example.com/health
# Expected response:{ "status": "healthy", "version": "v1.2.3", "timestamp": "2024-01-15T10:30:00Z"}2. Smoke Tests
Section titled “2. Smoke Tests”Essential functionality tests:
- Homepage loads
- API endpoints respond
- Authentication works
- Database connection active
- Critical features functional
3. Monitor Logs
Section titled “3. Monitor Logs”Watch for errors:
# Check recent logs# (Platform-specific log viewing)
# Look for:# - Error patterns# - Performance issues# - Unexpected warningsExamples
Section titled “Examples”Deploy to Staging
Section titled “Deploy to Staging”/deploy stagingOutput:
## Deployment Started
**Environment**: staging**Version**: main@abc1234**Time**: 2024-01-15 10:30:00 UTC
### Pre-Deploy Checks- [x] Build successful- [x] Tests passing (127 tests)- [x] Security scan clean- [x] Environment variables verified
### Deploying...- [x] Build artifacts created- [x] Uploading to staging- [x] Deployment complete
### Post-Deploy Checks- [x] Health check passed- [x] Smoke tests passed- [x] No errors in logs
## Deployment Complete
**URL**: https://staging.example.com**Status**: Healthy**Response Time**: 234ms
### Next Steps1. Test the staging deployment2. Verify all features work3. Deploy to production when readyDeploy to Production
Section titled “Deploy to Production”/deploy productionInteractive confirmation:
⚠️ Production Deployment
**Environment**: production**Version**: v1.2.3**Branch**: main
### Changes Since Last Deploy- feat(auth): add OAuth2 support (#123)- fix(api): handle null users (#124)- perf(db): optimize queries (#125)
**15 commits** | **5 PRs** | **3 contributors**
### Pre-Deploy Checklist- [x] All tests passing- [x] Security scan clean- [x] Changelog updated- [x] Team notified
Continue with production deployment? (yes/no): yesAfter confirmation:
## Deployment Started
**Environment**: production**Version**: v1.2.3**Time**: 2024-01-15 14:30:00 UTC
### Pre-Deploy Checks- [x] Build successful- [x] Tests passing (127 tests)- [x] Security scan clean- [x] Release tagged
### Deploying...- [x] Build artifacts created- [x] Uploading to production- [x] Deployment complete- [x] Cache invalidated
### Post-Deploy Checks- [x] Health check passed- [x] Smoke tests passed- [x] Performance metrics normal- [x] No errors in logs
## Deployment Complete
**URL**: https://example.com**Version**: v1.2.3**Status**: Healthy**Response Time**: 189ms
### Monitoring- [ ] Watch error rates (5 min)- [ ] Monitor performance (15 min)- [ ] Check user feedback
### Rollback PlanIf issues occur:```bash/deploy rollback v1.2.2### Deploy to Preview
For preview deployments (PR previews):
```bash/deploy previewCreates ephemeral environment for testing:
## Preview Deployment
**Environment**: preview-pr-123**Branch**: feature/new-ui**URL**: https://preview-pr-123.example.com
### Status- [x] Deployed successfully- [x] Ready for testing
**Expires**: 7 daysOutput
Section titled “Output”Standard deployment output includes:
## Deployment Complete
**Environment**: staging**Version**: v1.2.3**URL**: https://staging.example.com
### Checks- [x] Build successful- [x] Tests passing- [x] Security scan clean- [x] Health check passed
### Metrics- **Build Time**: 2m 34s- **Deploy Time**: 1m 12s- **Total Time**: 3m 46s- **Response Time**: 234ms
### Next Steps1. Test deployment2. Monitor logs3. Verify functionalityRollback
Section titled “Rollback”If deployment issues occur:
/deploy rollback [version]Example:
/deploy rollback v1.2.2Reverts to previous version with zero-downtime.
| Flag | Description | Example |
|---|---|---|
--skip-tests | Skip test execution | /deploy staging --skip-tests |
--force | Skip confirmations (dangerous!) | /deploy production --force |
--dry-run | Simulate deployment | /deploy production --dry-run |
--tag=[version] | Specify release tag | /deploy production --tag=v1.3.0 |
Environment Configuration
Section titled “Environment Configuration”Configure deployment settings in CLAUDE.md:
## Deployment
### Staging- **URL**: https://staging.example.com- **Platform**: Vercel- **Branch**: main- **Auto-deploy**: Yes
### Production- **URL**: https://example.com- **Platform**: Vercel- **Branch**: main- **Auto-deploy**: No (manual approval)- **Confirmation**: Required
### Checks- Required: tests, security scan, build- Optional: performance benchmarksRelated Commands
Section titled “Related Commands”- /ship - Commit and create PR
- /test - Run tests
- /changelog - Generate release notes
Test on staging first: Always deploy to staging before production.
Use dry-run: Preview what will happen with --dry-run flag.
Monitor after deploy: Watch logs and metrics for at least 15 minutes after production deploys.
Have a rollback plan: Know how to quickly revert if issues occur.
Automate staging: Let staging deploy automatically, but keep production manual.
Tag releases: Use semantic versioning for production releases.
Update changelog: Keep changelog current with each production deployment.
Notify team: Alert team before production deployments.