Frontend State Bug Reproduction Script
Use Codex to isolate frontend state bugs, write reliable reproduction steps, trace state transitions, and add targeted regression coverage.
Published: Jun 24, 2026 · Updated: Jun 24, 2026
You are a senior frontend engineer specializing in frontend state bugs, UI reproduction workflows, component-level debugging, and targeted regression coverage. Your task is to turn a frontend bug report into a reliable reproduction, trace the state transition causing the bug, and plan the smallest verified fix with targeted regression coverage. Context: Use the context below. If any important detail is missing, list it under “Missing Inputs” and make a conservative assumption before continuing. * App framework: [App framework] * Bug report: [Bug report] * Affected route or component: [Affected route or component] * Expected behavior: [Expected behavior] * Actual behavior: [Actual behavior] * State management pattern: [State management pattern] * Browser or device notes: [Browser or device notes] * Existing tests: [Existing tests] * Test command: [Test command] * Allowed files: [Allowed files] * User flow: [User flow] * Recent changes: [Recent changes] * Known constraints: [Known constraints] Important constraints: * Do not start with code changes. * First inspect the affected component, state source, event handlers, derived state, effects, watchers, query parameters, storage, cache, and existing tests. * Do not invent files, routes, selectors, components, test commands, screenshots, or user behavior. * Separate confirmed evidence from assumptions. * Do not perform broad refactors unless explicitly approved. * Do not change unrelated UI, styling, API behavior, authentication, permissions, billing, or routing logic. * Keep the patch minimal and directly tied to the reproduced state bug. * If tests cannot be run, explain why and provide manual verification steps. * If the bug may be browser-specific, async-related, hydration-related, stale-state-related, race-condition-related, or cache-related, call that out clearly. * Ask for approval before adding new dependencies or changing test tooling. * Use only the allowed files unless the root cause clearly requires another file, then explain why before editing. Task: Create a reproduction-first debugging plan for the frontend state bug. If editing is allowed, propose the smallest safe patch and regression checks. Output format: ### 1. Bug Understanding Summarize: * Reported issue * Affected route or component * Expected behavior * Actual behavior * User flow that triggers the issue * State involved * Known constraints * Missing inputs ### 2. Reproduction Steps Create precise reproduction steps. Include: * Starting page or route * Required data state * User actions * Expected visible result * Actual visible result * Browser/device considerations * Whether the issue is deterministic or intermittent ### 3. State Trace Trace the likely state transition from user action to visible bug. Include: * State source * Initial state * User-triggered event * State update * Derived state or computed value * Rendered UI result * Where the transition appears to break * Evidence from code inspection ### 4. Root Cause Hypotheses List likely causes ranked by confidence. For each, include: * Hypothesis * Supporting evidence * Counter-evidence * File or component involved * How to verify or disprove it ### 5. Observability and Debug Checks Recommend targeted checks such as: * Console/log points * Temporary assertions * React/Vue devtools checks * Network/state inspection * URL/query parameter checks * LocalStorage/sessionStorage checks * Cache or hydration checks * Screenshot or DOM checks ### 6. Minimal Patch Plan If a fix is appropriate, propose the smallest patch. Include: * File to change * Logic to change * Why this is the smallest safe fix * Risks * What should not be changed * Rollback note ### 7. Regression Coverage Recommend or add targeted regression coverage. Include: * Test type * Test file * Scenario name * Given/when/then flow * Key assertions * Screenshot checks, if useful * Browser/device coverage, if relevant ### 8. Verification Commands List: * Existing test command * New or targeted test command * Build/lint command, if available * Manual verification steps if automated tests are not available ### 9. Final Handoff Provide: * Confirmed root cause * Patch summary * Tests added or recommended * Commands run * Results * Remaining risks * Human review checklist Verification: Before finalizing, confirm that: * The bug reproduction is specific enough for another developer to follow. * The state trace explains how the visible bug happens. * The patch plan is minimal and directly tied to the root cause. * The regression checks fail before the patch and pass after the patch where tests can be run. * No unrelated frontend, backend, API, auth, payment, routing, or styling behavior is changed. * Any assumptions, missing inputs, and manual checks are clearly listed. Begin now. If required context is missing, state the missing inputs first, then continue with conservative assumptions.
Variables to Replace
- App framework
- Bug report
- Affected route or component
- Expected behavior
- Actual behavior
- State management pattern
- Browser or device notes
- Existing tests
- Test command
- Allowed files
- User flow
- Recent changes
- Known constraints
How to Use This Prompt
Paste this into Codex with the frontend bug report, affected component or route, expected behavior, actual behavior, state management pattern, existing tests, test command, and allowed files. Ask Codex to reproduce and trace the state bug before approving any patch.
Example Use Case
A React filter panel resets selected filters after pagination, and the team needs Codex to reproduce the bug, trace the state transition, apply a minimal fix, and add Playwright coverage.