|
| 1 | +--- |
| 2 | +name: fix-bug |
| 3 | +description: Fix a reported bug in React Router from a GitHub issue. Use when the user provides a GitHub issue URL and asks to fix a bug, investigate an issue, or reproduce a problem. Handles the full workflow: fetching the issue, finding the reproduction, writing a failing test, and implementing the fix. |
| 4 | +disable-model-invocation: true |
| 5 | +--- |
| 6 | + |
| 7 | +# Fix React Router Bug |
| 8 | + |
| 9 | +Fix the bug reported in the following GitHub issue: $ARGUMENTS |
| 10 | + |
| 11 | +## Branching |
| 12 | + |
| 13 | +Bug fixes should start from a clean working tree. If there are changes, prompt me to resolve them before continuing. |
| 14 | + |
| 15 | +Bugs should be fixed from the `dev` branch in in a new branch using the format `{author}/{semantic-branch-name}` (i.e., `brophdawg11/fix-navigation`): |
| 16 | + |
| 17 | +```sh |
| 18 | +git branch {author}/{semantic-branch-name} dev |
| 19 | +git checkout {author}/{semantic-branch-name} |
| 20 | +``` |
| 21 | + |
| 22 | +## Workflow |
| 23 | + |
| 24 | +### 1. Fetch and Understand the Issue |
| 25 | + |
| 26 | +Use `gh issue view <number> --repo remix-run/react-router` or `WebFetch` to read the full issue. |
| 27 | + |
| 28 | +Extract: |
| 29 | + |
| 30 | +- Bug description and expected vs actual behavior |
| 31 | +- React Router version and mode (Declarative / Data / Framework / RSC) |
| 32 | +- Any code snippets in the issue |
| 33 | +- Links to reproductions (StackBlitz, CodeSandbox, GitHub repo, etc.) |
| 34 | + |
| 35 | +### 2. Validate the Reproduction |
| 36 | + |
| 37 | +**If there's a StackBlitz/CodeSandbox/online sandbox link:** |
| 38 | + |
| 39 | +- Use `WebFetch` to read the sandbox URL and extract the relevant code |
| 40 | +- Identify the exact sequence of events that triggers the bug |
| 41 | + |
| 42 | +**If there's a GitHub repository link:** |
| 43 | + |
| 44 | +- Use `WebFetch` to read key files (`package.json`, relevant source files) from the raw GitHub URL |
| 45 | +- Identify the route configuration, loaders, actions, or components involved |
| 46 | + |
| 47 | +**If no reproduction link exists:** |
| 48 | + |
| 49 | +- Search the issue comments with `gh issue view <number> --repo remix-run/react-router --comments` |
| 50 | +- Look for code snippets in comments |
| 51 | +- Ask the user: "No reproduction was provided. Can you share a minimal reproduction or paste the relevant code?" |
| 52 | + |
| 53 | +### 3. Identify the Affected Code |
| 54 | + |
| 55 | +Based on the bug, locate the relevant source files. Consult the key file map: |
| 56 | + |
| 57 | +| Area | Files | |
| 58 | +| ---------------------- | ----------------------------------------------------------- | |
| 59 | +| Core router logic | `packages/react-router/lib/router/router.ts` | |
| 60 | +| React components/hooks | `packages/react-router/lib/components.tsx`, `lib/hooks.tsx` | |
| 61 | +| DOM utilities | `packages/react-router/lib/dom/` | |
| 62 | +| Vite/Framework plugin | `packages/react-router-dev/vite/plugin.ts` | |
| 63 | +| RSC | `packages/react-router/lib/rsc/` | |
| 64 | + |
| 65 | +Use `Grep` and `Glob` to trace the relevant code paths. |
| 66 | + |
| 67 | +### 4. Write a Failing Test |
| 68 | + |
| 69 | +**Unit test** (for router logic, hooks, pure component behavior — no build needed): |
| 70 | + |
| 71 | +- Location: `packages/react-router/__tests__/` |
| 72 | +- Use Jest; run with: `pnpm test packages/react-router/__tests__/<file>` |
| 73 | +- Match the style of nearby test files (describe/it blocks, `createStaticHandler`, `createMemoryRouter`, `render`, `screen`, etc.) |
| 74 | + |
| 75 | +**Integration test** (for Vite plugin, SSR, hydration, Framework Mode): |
| 76 | + |
| 77 | +- Location: `integration/` |
| 78 | +- Use Playwright with `createFixture()` → `createAppFixture()` → `PlaywrightFixture` |
| 79 | +- Run with: `pnpm test:integration:run --project chromium integration/<file>` |
| 80 | +- Build first if needed: `pnpm test:integration --project chromium` |
| 81 | + |
| 82 | +Write the test to **reproduce the bug exactly** — it must fail before the fix. |
| 83 | + |
| 84 | +Run it and confirm it fails: |
| 85 | + |
| 86 | +```bash |
| 87 | +pnpm test packages/react-router/__tests__/<file> # unit |
| 88 | +# or |
| 89 | +pnpm test:integration:run --project chromium integration/<file> # integration |
| 90 | +``` |
| 91 | + |
| 92 | +### 5. Implement the Fix |
| 93 | + |
| 94 | +- Make the minimal change needed to fix the bug |
| 95 | +- Do not refactor unrelated code |
| 96 | +- Confirm the fix addresses the root cause, not just the symptom |
| 97 | +- Consider all five modes: does this fix break anything in Declarative / Data / Framework / RSC? |
| 98 | + |
| 99 | +Run the failing test again — it must now pass: |
| 100 | + |
| 101 | +```bash |
| 102 | +pnpm test packages/react-router/__tests__/<file> |
| 103 | +``` |
| 104 | + |
| 105 | +Run the broader test suite to check for regressions: |
| 106 | + |
| 107 | +```bash |
| 108 | +pnpm test packages/react-router/ |
| 109 | +``` |
| 110 | + |
| 111 | +If the fix touches Framework/Vite code, run integration tests too: |
| 112 | + |
| 113 | +```bash |
| 114 | +pnpm test:integration:run --project chromium |
| 115 | +``` |
| 116 | + |
| 117 | +Confirm linting and typechecking pass: |
| 118 | + |
| 119 | +```bash |
| 120 | +pnpm lint |
| 121 | +pnpm typecheck |
| 122 | +``` |
| 123 | + |
| 124 | +### 6. Create a Changeset |
| 125 | + |
| 126 | +Create `.changeset/<descriptive-name>.md`: |
| 127 | + |
| 128 | +```markdown |
| 129 | +--- |
| 130 | +"react-router": patch |
| 131 | +--- |
| 132 | + |
| 133 | +fix: <brief description of what was fixed> |
| 134 | +``` |
| 135 | + |
| 136 | +Use `patch` for bug fixes. Only include packages in the frontmatter that were actually changed. |
| 137 | + |
| 138 | +### 7. Report Results |
| 139 | + |
| 140 | +Summarize: |
| 141 | + |
| 142 | +- What the bug was and why it happened |
| 143 | +- What code was changed and why |
| 144 | +- That the test now passes |
| 145 | +- Any edge cases or related issues noticed |
| 146 | + |
| 147 | +Ask me to review the changes and iterate based on any feedback. |
| 148 | + |
| 149 | +### 8. Open PR |
| 150 | + |
| 151 | +Once I approve the fix, commit the changes and open a PR to `dev`. Include a `Closes #NNNN` in the description to link the PR to the original issue. Also link the issue in the `Development` sidebar |
0 commit comments