The short version
- JavaScript bugs often hide at boundaries: coercion, async timing and browser state. These prompts focus on one boundary and require a runnable test.
- Never paste credentials, private customer data or entire proprietary repositories into an unapproved assistant. Run suggested commands and tests in your own environment. A plausible patch is not evidence that the change works.
JavaScript bugs often hide at boundaries: coercion, async timing and browser state. These prompts focus on one boundary and require a runnable test.
Never paste credentials, private customer data or entire proprietary repositories into an unapproved assistant. Run suggested commands and tests in your own environment. A plausible patch is not evidence that the change works.
How to use this collection
Pick the task closest to your work. Copy the prompt, replace the generic scene or code context with your own facts, and keep the constraints that help you judge the result. Change one variable at a time so you can tell what improved.
The approach follows the GitHub Copilot prompt engineering guide: provide concrete context and inspect the output rather than assuming a polished first pass is correct.
Diagnose prompts
This set focuses on diagnose. Supply your real code and test command before accepting the answer.
1. A promise rejection path
Help with a promise rejection path in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Run the proposed reproduction before applying a patch.
2. A stale closure in an event handler
Help with a stale closure in an event handler in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Run the proposed reproduction before applying a patch.
3. A debounced search field
Help with a debounced search field in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Run the proposed reproduction before applying a patch.
4. An array mutation bug
Help with an array mutation bug in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Run the proposed reproduction before applying a patch.
5. An incorrect date parse
Help with an incorrect date parse in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Run the proposed reproduction before applying a patch.
6. A fetch timeout
Help with a fetch timeout in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Run the proposed reproduction before applying a patch.
7. A local-storage migration
Help with a local-storage migration in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Run the proposed reproduction before applying a patch.
8. An event listener leak
Help with an event listener leak in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Run the proposed reproduction before applying a patch.
9. An accessibility keyboard handler
Help with an accessibility keyboard handler in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Run the proposed reproduction before applying a patch.

10. An ESM import error
Help with an ESM import error in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Run the proposed reproduction before applying a patch.
Implement prompts
This set focuses on implement. Supply your real code and test command before accepting the answer.
11. A promise rejection path
Help with a promise rejection path in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Review the diff for unrelated changes and unintended data access.
12. A stale closure in an event handler
Help with a stale closure in an event handler in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Review the diff for unrelated changes and unintended data access.
13. A debounced search field
Help with a debounced search field in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Review the diff for unrelated changes and unintended data access.
14. An array mutation bug
Help with an array mutation bug in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Review the diff for unrelated changes and unintended data access.
15. An incorrect date parse
Help with an incorrect date parse in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Review the diff for unrelated changes and unintended data access.
16. A fetch timeout
Help with a fetch timeout in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Review the diff for unrelated changes and unintended data access.
17. A local-storage migration
Help with a local-storage migration in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Review the diff for unrelated changes and unintended data access.

18. An event listener leak
Help with an event listener leak in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Review the diff for unrelated changes and unintended data access.
19. An accessibility keyboard handler
Help with an accessibility keyboard handler in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Review the diff for unrelated changes and unintended data access.
20. An ESM import error
Help with an ESM import error in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Review the diff for unrelated changes and unintended data access.
Test boundaries prompts
This set focuses on test boundaries. Supply your real code and test command before accepting the answer.
21. A promise rejection path
Help with a promise rejection path in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then add unit or integration cases for empty, invalid and concurrent inputs as appropriate. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Run the tests and check that they fail before the fix when feasible.
22. A stale closure in an event handler
Help with a stale closure in an event handler in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then add unit or integration cases for empty, invalid and concurrent inputs as appropriate. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Run the tests and check that they fail before the fix when feasible.
23. A debounced search field
Help with a debounced search field in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then add unit or integration cases for empty, invalid and concurrent inputs as appropriate. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Run the tests and check that they fail before the fix when feasible.
24. An array mutation bug
Help with an array mutation bug in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then add unit or integration cases for empty, invalid and concurrent inputs as appropriate. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Run the tests and check that they fail before the fix when feasible.
25. An incorrect date parse
Help with an incorrect date parse in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then add unit or integration cases for empty, invalid and concurrent inputs as appropriate. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.Review: Run the tests and check that they fail before the fix when feasible.
What to check before you use the result
Never paste credentials, private customer data or entire proprietary repositories into an unapproved assistant. Run suggested commands and tests in your own environment. A plausible patch is not evidence that the change works.
If the output misses the task, shorten the prompt and specify the missing fact or constraint. Keep a record of the version you used so the final asset or code change can be reproduced.
Further reading
Continue with a related guide
Put it into practice
Your next step
Have a question or a correction?
Contact Thrive


