Skip to content

Deployment Patterns

It is release day. You have 47 commits to deploy, three of which touched the database schema. The changelog needs updating, release notes need writing, and someone has to verify that all migrations are backward-compatible. This used to take half a day. With Claude Code in your deployment pipeline, it takes 30 minutes.

  • A pre-deployment validation checklist that Claude Code executes automatically
  • Changelog and release note generation from git history
  • Migration safety checks before database schema changes deploy
  • Rollback assistance when deployments go wrong
Run the following pre-deployment checks and report results:
1. TypeScript: npx tsc --noEmit (must pass with zero errors)
2. Linting: npm run lint (must pass)
3. Tests: npm run test (must pass, report coverage)
4. Build: npm run build (must succeed)
5. Migrations: Check if there are pending database migrations
6. Dependencies: npm audit --production (flag critical vulnerabilities)
7. Environment: Verify all required env vars are documented
For each check: PASS/FAIL with details if failed.
Stop at the first FAIL -- do not continue if earlier checks fail.
Terminal window
# Generate changelog since last tag
git log --oneline "$(git describe --tags --abbrev=0)..HEAD" | \
claude -p "Generate a CHANGELOG.md entry from these commits. \
Format: \
## [$(git describe --tags --abbrev=0 | awk -F. '{print \$1\".\"(\$2+1)\".0\"}' )] - $(date +%Y-%m-%d) \
\
Group by: \
### Added (new features) \
### Changed (changes to existing features) \
### Fixed (bug fixes) \
### Removed (removed features) \
\
Rules: \
- Write in past tense \
- One line per change \
- Skip merge commits and version bumps \
- Link to PR numbers if present in commit messages" \
--output-format text
Generate release notes for version 2.5.0 from these changes:
[paste git log or changelog]
Format for:
1. A GitHub release (markdown, user-facing, highlight breaking changes)
2. An internal Slack post (brief, bullet points, mention impacted teams)
3. A customer-facing email (non-technical, focus on benefits)
Review the pending database migrations in db/migrations/.
For each migration:
1. Is it backward-compatible? (can the old code run against the new schema?)
2. Is there a rollback migration?
3. Will it lock tables for an extended period?
4. Are there data transformations that could fail on existing data?
5. Is it idempotent? (safe to run multiple times?)
Flag any migration that requires a maintenance window.
We deploy with zero downtime using rolling updates. Review the current changes
to verify they are safe for rolling deployment:
1. Are all API changes backward-compatible?
2. Are database migrations safe to run while old code is still serving traffic?
3. Are there any new required environment variables that old pods would not have?
4. Do the changes assume all instances are on the same version simultaneously?
If any check fails, describe the required deployment strategy (blue-green, maintenance window, feature flag).

When a deployment goes wrong:

The deploy of commit abc123 is causing 500 errors on the /api/orders endpoint.
Help me execute a rollback:
1. What is the last known good commit? Check deploy logs or tags.
2. Are there database migrations between the current and rollback commit?
3. If yes, are the migrations reversible? Can the old code work with the new schema?
4. Generate the rollback commands (git, deploy tool, and migration rollback)
5. What monitoring should I check after rollback to verify recovery?

Changelog misses important changes: Claude generates changelogs from commit messages. If your commits say “fix stuff” and “update code,” the changelog will be useless. Write descriptive commit messages, or ask Claude to read the actual diff for each commit.

Migration review misses edge cases: Automated migration review works for common patterns but may miss data-dependent issues. Always test migrations against a copy of production data before deploying.

Rollback fails because migrations are not reversible: Many ORMs generate one-way migrations by default. Make down migrations part of your workflow and test them regularly.