---
description: Step-by-step bug fix workflow with root-cause-first implementation and regression checks
alwaysApply: true
---

# Fix Bugs Rule (Step-by-Step)

Use this for any defect fix (UI bug, logic bug, API bug, state bug).

## Project location guide

- Screen bug -> `components/pages/<flow>/<ScreenName>/...`
- UI component bug -> `components/atoms|molecules|organisms/...`
- API bug -> `apis/**` + `apis/@types/**`
- State bug -> `redux/**` + related hooks/components

## 1) Reproduce first

- Reproduce from exact screen/flow (`app/**` route -> `components/pages/**`).
- Identify deterministic trigger (inputs, state, API response, language, platform).

## 2) Find root cause

- Trace data flow from source to render/action.
- Confirm why it fails (not just where it fails).
- Do not patch symptoms before confirming root cause.

## 3) Apply minimal safe fix

- Change the smallest set of files required.
- Keep architecture/layer boundaries aligned with Atomic Design.
- Reuse existing shared components/utilities where possible.

## 4) Verify regression safety

- Validate original failing scenario.
- Validate one nearby happy path.
- Validate one edge path around the same feature.

## 5) Contract safety

- If API/state is touched, preserve existing contracts unless change is requested.
- If contract changes are required, update all call sites in same change.

## 6) Final checks

- Run formatter/lint on touched files.
- Ensure no unrelated files were modified.

## Summary requirement

- Provide in final summary:
  - root cause (1 sentence)
  - fix scope (what changed)
  - regression checks performed
