name: regression-prevention
description: Use for planning and executing code changes with strict regression controls, including risk scoring, test impact analysis, compatibility checks, release gates, and rollback readiness.
Regression Prevention
Quick Index (Action-Routed)
Read First (All Actions)
MissionCore PrinciplesTrigger ExamplesRegression Taxonomy
Action Modules (Read As Needed)
- Planning and risk setup:
Required Workflow Step 1-5Dependency Update RulesDatabase and Migration Safety
- Validation execution:
Required Workflow Step 6-10Frontend Regression ControlsBackend Regression Controls
- Evidence and release decisions:
PR/Change Checklist TemplateMinimum Evidence StandardDeliverable Format
Failure & Escalation
Escalation ConditionsAnti-Patterns to Avoid
Mission
Ship changes without breaking existing behavior, data integrity, performance, or operational stability.
Use this skill for any non-trivial change (features, refactors, upgrades, schema/API/runtime/tooling changes).
Core Principles
- Preserve existing behavior unless change is explicitly requested.
- Detect breakage early with layered checks (static, unit, integration, E2E, runtime).
- Require proof before confidence: every assumption must be validated by a check or a test.
- Prefer reversible changes over hard-to-undo changes.
- Never rely on "it should be fine" for risky updates.
Trigger Examples
Apply when users ask for changes that must preserve existing behavior and reliability.
Non-Goals
Does not replace product decision-making, incident response, or dedicated security review.
Regression Taxonomy
Classify risk before implementation:
- Functional regressions:
- existing user flows fail
- outputs differ unexpectedly
- state transitions break
- Data regressions:
- schema mismatches
- lost/duplicated records
- incorrect migrations
- serialization/deserialization breakage
- Contract regressions:
- API request/response incompatibility
- changed status codes
- header/cookie/session contract changes
- event payload changes
- UX regressions:
- navigation breaks
- accessibility regressions
- mobile layout breakage
- broken forms/interactions
- Performance regressions:
- slower endpoint/page latency
- increased memory/CPU usage
- larger bundle/build artifacts
- Operational regressions:
- deploy/startup failures
- missing env/runtime dependencies
- broken jobs/workers/webhooks
- logging/observability blind spots
For small/low-risk changes, this taxonomy can be captured in compact form (affected categories only).
Required Workflow
Follow in order.
Step 1: Baseline Capture (Before Changes)
Record current behavior first.
Minimum baseline:
- Current branch status and uncommitted work.
- Existing test results (or explicit gaps if tests unavailable).
- Key runtime smoke checks for core flows.
- Current API/CLI/UI behaviors that must remain stable.
- Current performance snapshots for high-risk paths (if relevant).
Output required:
- A short "baseline checkpoint" note listing:
- what was checked
- what passed
- what is untested and risky
Step 2: Change Impact Mapping
For each touched module:
- Identify direct callers.
- Identify transitive dependencies.
- Identify contracts (API, schema, events, files, env vars).
- Identify user-visible surfaces.
- Identify jobs/background tasks/webhooks impacted.
Mandatory artifact:
- Impact map with:
- touched files
- affected flows
- required validation scope
Step 3: Risk Scoring
Assign a risk level before editing.
Low risk:
- isolated text/style copy change
- no contract/data impact
Medium risk:
- logic changes in non-critical path
- small dependency update
- internal refactor
High risk:
- auth/session changes
- payment/order/financial logic
- DB schema/migrations
- API contract changes
- large dependency/runtime upgrades
- concurrency/state management changes
Risk gates:
- Low: unit/smoke checks required.
- Medium: unit + integration + targeted E2E required.
- High: full regression pass + rollback plan required.
If tests are missing in a required layer:
- create temporary targeted checks (scripted smoke/contract checks),
- record the gap explicitly,
- mark residual risk as elevated,
- avoid claiming regression-safe coverage.
Blocking rule:
- high-risk changes with missing critical validation layers must not be marked release-ready
- proceed only with explicit risk acceptance and remediation plan
Step 4: Guardrail Design (Before Coding)
Define safeguards before edits.
Possible safeguards:
- feature flags
- backward-compatible adapters
- dual-write/dual-read strategies
- deprecation windows
- schema expand-then-contract approach
- kill switches for risky behavior
For high-risk changes, require at least one explicit rollback mechanism.
Step 5: Implement in Small, Verifiable Slices
Do not batch unrelated risky changes.
Rules:
- Keep changes scoped.
- Validate after each slice.
- Avoid mixed refactor + behavior changes in one step when possible.
- Preserve interfaces until migration path is complete.
Step 6: Regression Test Matrix
Use layered validation; do not rely on one test type.
Required matrix:
- Static checks:
- type checks/lint/format consistency checks
- Unit tests:
- pure logic and edge cases
- Integration tests:
- service boundaries (DB/API/external mocks)
- E2E/smoke:
- user-critical flows
- happy path + at least one failure path
- Contract checks:
- response shape/status invariants
- backward compatibility checks
- Data checks:
- migration up/down where possible
- integrity assertions for modified models
- Operational checks:
- app starts cleanly
- key routes/commands work
- no missing env vars/runtime errors
Step 6A: Unit Tests vs Playwright
Use Effective Testing Methods for detailed patterns when amending or adding unit and Playwright tests.
Use both; they protect different failure modes.
Unit tests are for:
- pure business logic
- edge-case branching
- deterministic fast feedback
- preventing localized logic regressions
Playwright tests are for:
- real browser rendering and interaction regressions
- route/navigation/form flows
- auth/session/cookie behavior from user perspective
- integration issues between frontend/backend at runtime boundaries
Rules:
- Unit tests do not replace Playwright for user-flow validation.
- Playwright does not replace unit tests for exhaustive logic branching.
- Run fast layers first (static + unit + integration), then Playwright.
- Fail early: do not spend E2E time if foundational checks are red.
Recommended sequence:
- static/type/lint
- unit tests
- integration/contract tests
- Playwright targeted regression tests
- Playwright full suite for high-risk or broad-impact changes
Playwright execution scope policy:
- UI-only low-risk change: targeted route test set
- medium-risk frontend logic change: targeted + neighboring route tests
- auth/navigation/session change: full critical-flow Playwright pass
- high-risk release candidate: full Playwright matrix (desktop/mobile where applicable)
Artifact policy for Playwright:
- persist trace/video/screenshot artifacts on failure
- include failing URL, selector context, and test name in evidence
- treat flaky tests as unresolved risk until triaged
Flake handling:
- allow one controlled retry for diagnostics
- if retry passes, mark as flaky-suspect and log
- if retry fails again, treat as hard failure
Step 6C: Constrained-Environment Adaptation
If a required layer cannot run because of host/runtime constraints:
- capture blocker evidence:
- command
- exact error
- missing dependency/runtime constraint
- execute fallback checks:
- static/type/lint
- test discovery/listing for blocked suites
- available non-blocked regression checks
- update impacted tests/specs anyway (do not defer test updates solely because execution is blocked)
- classify residual risk as elevated for blocked critical layers
- provide exact rerun command for full validation once dependency is available
Reference:
skills/docs/verification/constrained-environment-verification.md
Step 6B: Coverage Mapping Artifact (Required for Medium/High Risk)
Create a change-to-test map:
- changed module/route
- impacted behavior
- unit tests covering logic
- integration/contract tests covering boundaries
- Playwright specs covering user flow
- remaining untested risk
Step 7: Negative and Edge-Case Validation
Minimum edge-case checks:
- invalid inputs
- unauthorized access
- empty/null/absent data
- duplicate/retry behavior
- timeout/external service failure behavior
Step 8: Compatibility Rules
For APIs, data, and events, preserve compatibility unless explicitly approved.
Rules:
- Additive changes preferred over destructive changes.
- Do not silently rename/remove fields without migration path.
- Keep old consumers functioning during transition.
- Document compatibility breaks with explicit dates and mitigation.
Step 9: Release Readiness Gate
Before considering complete, verify:
- Risk-tier checks passed.
- Critical flows pass.
- Observability is sufficient (errors/logging/metrics for changed paths).
- Rollback plan is documented and actionable.
- Known residual risks are listed explicitly.
Step 10: Post-Change Verification
After merge/deploy (or local equivalent), run:
- immediate smoke checks
- targeted regression checks for changed flows
- quick scan of logs/errors for new anomalies
- document observed deviations and owner for follow-up
Dependency Update Rules
Checklist:
- Read release notes/changelogs for breaking changes.
- Upgrade smallest necessary scope first.
- Avoid simultaneous major upgrades unless required.
- Re-run full affected test matrix after upgrade.
- Validate runtime startup and critical paths.
- Document behavior changes introduced by dependency updates.
For major version upgrades:
- create a compatibility checklist
- identify removed APIs/features
- patch incrementally
- run full regression suite
Database and Migration Safety
For any schema/data updates:
- Prefer expand-then-contract migration strategy.
- Never assume data shape quality; validate existing rows.
- Add default/backfill strategy for new required columns.
- Ensure read paths handle both old/new states during rollout.
- Test migration with representative data volume when possible.
- Verify rollback path (or explicit non-reversible documentation).
Frontend Regression Controls
When UI is changed:
- Validate desktop/mobile layout, keyboard/focus, and route transitions.
- Validate loading/error/empty states.
- Re-run E2E route smoke checks.
- Ensure unit/component and Playwright coverage for impacted flows.
Backend Regression Controls
When backend is changed:
- Validate auth boundaries, status/error contracts, and idempotency.
- Validate external failure handling and serialization/deserialization.
- Ensure behavior changes are reflected in integration/contract tests used by frontend flows.
PR/Change Checklist Template
Use this checklist for every non-trivial update:
- [ ] Baseline captured
- [ ] Impact map created
- [ ] Risk tier assigned
- [ ] Guardrails selected (feature flag/rollback/adapter)
- [ ] Tests added/updated for changed behavior
- [ ] Edge/failure paths validated
- [ ] Compatibility verified
- [ ] Release gate passed
- [ ] Post-change verification plan documented
Minimum Evidence Standard
Do not claim "no regression" without evidence.
Evidence must include:
- commands/checks run
- key pass/fail outcomes
- any skipped checks and why
- residual risk statement
Escalation Conditions
Stop and escalate if:
- baseline cannot be established
- high-risk change lacks rollback
- critical tests cannot run
- compatibility impact is unknown
- behavior differences appear without clear explanation
Anti-Patterns to Avoid
- Large multi-domain refactors without intermediate validation.
- Changing behavior and contracts in same step without compatibility layer.
- Upgrading many dependencies at once with no isolation.
- Assuming test coverage equals regression safety.
- Skipping negative-path validation.
Compact-mode note:
- keep evidence compact, but never omit risk tier, validation scope, or release recommendation.
When using this skill, produce outputs in this order:
- Risk summary
- Impact map
- Validation plan
- Changes made
- Evidence from checks/tests
- Residual risks + rollback notes
- explicit release recommendation (
go, go-with-risk, no-go)
Validation plan must explicitly list:
- unit-test scope
- integration/contract scope
- Playwright scope (targeted vs full)
- rationale for any omitted layer