Turn a broken interaction into a small experiment, identify the cause, and verify a focused repair.
45-75 min · estimate / Web Development
Before You Begin
Complete the Build with AI guide or bring a small local JavaScript project you understand.
Know how to open the browser console and locate the function responsible for an interaction.
Save a working baseline in version control and choose a reproducible practice bug.
What You Will Make
A focused bug fix supported by a reproducible failure, a cause-and-effect explanation, and a regression check that fails before the repair and passes afterwards.
STEP 01
Capture the Failure Precisely
Choose a harmless bug in a local practice project, such as a filter that loses items after switching categories. Record the starting state, exact actions, expected result, and actual result. Include a relevant console message if one exists, preserving its wording while removing private paths or data. Confirm that the failure happens more than once. Ask the assistant to restate the problem before proposing changes. A reproducible description creates a shared object of investigation and prevents the conversation from drifting into unrelated refactoring. Keep the working baseline in version control so experiments can be compared safely.
Restate this bug using preconditions, actions, expected result, and actual result. Ask for missing information that would affect diagnosis. Do not propose a rewrite yet. I will provide a small local reproduction and the exact console output, with private data removed.
STEP 02
Choose a Check That Distinguishes Causes
Ask for a short ranked list of possible causes supported by the code you supplied. For each cause, identify an observation that would make it more or less likely. Inspect the relevant variable, event, or function boundary using a debugger or a temporary local log. Run one check at a time. If an assistant suggests changing several things together, reduce the experiment so its result is interpretable. Keep a small notebook of hypothesis, check, observation, and conclusion. The purpose is to locate the failure mechanism, not to collect plausible explanations until one happens to work.
List at most three causes grounded in this code. For each, propose one small observation that distinguishes it from the others. Mark assumptions. Do not edit code yet. After I report the first result, update the hypotheses instead of repeating the original list.
STEP 03
Make the Smallest Supported Repair
Once evidence points to a cause, ask for a focused change and an explanation of why it addresses that cause. Review the diff for removed behaviour, new dependencies, and unrelated formatting changes. Apply the repair in your practice branch and repeat the original reproduction. Also try a normal interaction that shares the changed function. If the failure remains, keep the new observation and reconsider the hypothesis rather than stacking another unexplained patch on top. A successful repair should fit the evidence and leave you able to explain why the previous implementation failed.
The observation supports this cause: [describe it]. Propose the smallest repair and explain the before-and-after data flow. Include one regression risk and how to check it. Preserve existing behaviour outside the failing case and do not add a dependency without a concrete need.
STEP 04
Keep a Check That Would Catch It Again
Turn the original reproduction into a small repeatable test or a clear manual checklist when automation is not worthwhile. Confirm that the check fails against the broken version and passes after the repair. Add a boundary case that targets the same assumption, such as an empty resource collection or a filter with no matches. Remove temporary debug output that no longer helps. Write a short commit message describing the resulting behaviour and update the README if the user-facing contract changed. The final explanation should connect the symptom, cause, repair, and regression check.
Help me design one meaningful regression check for this bug and one boundary case targeting the same assumption. Avoid tests that merely repeat the implementation. Review my evidence that the check fails before the repair and passes afterwards; do not claim you executed it.