Przejdź do głównej zawartości

Wzorce wdrażania

Dzień wydania. Masz 47 commitów do wdrożenia, z czego trzy dotykają schematu bazy danych. Changelog wymaga aktualizacji, notatki wydania trzeba napisać, a ktoś musi zweryfikować, że wszystkie migracje są kompatybilne wstecz. To zabierało pół dnia. Z Claude Code w twoim pipeline wdrożeniowym zajmuje 30 minut.

  • Checklistę walidacji przed wdrożeniem, którą Claude Code wykonuje automatycznie
  • Generowanie changelogów i notatek wydania z historii git
  • Sprawdzenia bezpieczeństwa migracji przed wdrożeniem zmian schematu bazy danych
  • Pomoc przy wycofywaniu, gdy wdrożenie idzie nie tak
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.
Okno terminala
# 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).

Gdy wdrożenie idzie nie tak:

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 pomija ważne zmiany: Claude generuje changelogi z wiadomości commitów. Jeśli twoje commity mówią “fix stuff” i “update code”, changelog będzie bezużyteczny. Pisz opisowe wiadomości commitów lub poproś Claude o odczytanie faktycznego diffa dla każdego commita.

Przegląd migracji pomija przypadki brzegowe: Automatyczny przegląd migracji działa dla typowych wzorców, ale może pominąć problemy zależne od danych. Zawsze testuj migracje na kopii danych produkcyjnych przed wdrożeniem.

Wycofanie zawodzi, bo migracje są nieodwracalne: Wiele ORM-ów generuje jednokierunkowe migracje domyślnie. Uczyń z migracji “down” część swojego workflow i testuj je regularnie.