safe-deploy
The safe-deploy command automates application deployment with mandatory safety validations including test execution, uncommitted change verification, and branch confirmation. Use this to deploy to staging or production environments while preventing unsafe deployments, such as pushing production changes from non-main branches or skipping test requirements. The command enforces pre-deployment checks and provides detailed deployment status reporting.
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/huangjia2019/claude-code-engineering/HEAD/05-Commands/projects/02-advanced-commands/.claude/commands/safe-deploy.md -o ~/.claude/commands/safe-deploy.mdsafe-deploy.md
Deploy the application to: $ARGUMENTS ## Pre-deployment Checks Before deploying, verify: 1. All tests pass (`npm test`) 2. No uncommitted changes (`git status`) 3. On correct branch (main/master for production) ## Deployment Steps ### For Staging ($ARGUMENTS = "staging") 1. Run tests 2. Build the application 3. Deploy to staging environment 4. Verify deployment health ### For Production ($ARGUMENTS = "production") 1. Run full test suite 2. Check that staging is healthy 3. Create a git tag for the release 4. Build and deploy 5. Verify production health 6. Notify team ## Safety Rules - NEVER deploy to production from a non-main branch - ALWAYS run tests before deploying - If tests fail, STOP and report ## Output ``` ## Deployment Report Environment: [staging/production] Status: [success/failed] Time: [duration] ### Steps Completed ✓ Tests passed ✓ Build successful ✓ Deployed ✓ Health check passed ### Next Steps [Any follow-up actions needed] ```
Review code changes for quality, security, and best practices. Proactively use this after code modifications.
Run tests and report results concisely. Use this after code changes to verify everything works.
Analyze log files and extract actionable insights. Use when troubleshooting issues or investigating incidents.
Explore and analyze API-related code. Use when investigating endpoints, routing, or HTTP handling.
Explore and analyze authentication-related code. Use when investigating auth flows, session management, or security.
Explore and analyze database-related code. Use when investigating data models, queries, or persistence.
Analyze root cause of bugs after location is identified. Second step in bug investigation.
Implement bug fixes after analysis is complete. Third step in bug fix pipeline.