AI CodingThrive Editorial

30 AI Prompts for Debugging Code

Debugging starts with a reproducible symptom. These prompts ask for hypotheses, a narrow test and the smallest change that explains the failure.

16 min read
Developer inspecting a software problem on a laptop in a focused workspace.

The short version

  • Debugging starts with a reproducible symptom. These prompts ask for hypotheses, a narrow test and the smallest change that explains the failure.
  • 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.

Debugging starts with a reproducible symptom. These prompts ask for hypotheses, a narrow test and the smallest change that explains the failure.

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 null value crashing a page

Copy prompt

Help with a null value crashing a page 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 timezone conversion off by one day

Copy prompt

Help with a timezone conversion off by one day 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. An intermittent 401 response

Copy prompt

Help with an intermittent 401 response 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. A race between two saves

Copy prompt

Help with a race between two saves 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. A missing list item after filtering

Copy prompt

Help with a missing list item after filtering 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 slow page under load

Copy prompt

Help with a slow page under load 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 broken deep link

Copy prompt

Help with a broken deep link 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. A parser rejecting valid input

Copy prompt

Help with a parser rejecting valid input 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. A stale cached response

Copy prompt

Help with a stale cached response 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 upload that works only locally

Copy prompt

Help with an upload that works only locally 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.

Developer investigating a timezone bug with two clocks and a date test.

Implement prompts

This set focuses on implement. Supply your real code and test command before accepting the answer.

11. A null value crashing a page

Copy prompt

Help with a null value crashing a page 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 timezone conversion off by one day

Copy prompt

Help with a timezone conversion off by one day 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. An intermittent 401 response

Copy prompt

Help with an intermittent 401 response 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. A race between two saves

Copy prompt

Help with a race between two saves 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. A missing list item after filtering

Copy prompt

Help with a missing list item after filtering 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 slow page under load

Copy prompt

Help with a slow page under load 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 broken deep link

Copy prompt

Help with a broken deep link 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. A parser rejecting valid input

Copy prompt

Help with a parser rejecting valid input 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. A stale cached response

Copy prompt

Help with a stale cached response 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 upload that works only locally

Copy prompt

Help with an upload that works only locally 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.

Three-step code workflow: brief the work, inspect the result, edit and verify.

Test boundaries prompts

This set focuses on test boundaries. Supply your real code and test command before accepting the answer.

21. A null value crashing a page

Copy prompt

Help with a null value crashing a page 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 timezone conversion off by one day

Copy prompt

Help with a timezone conversion off by one day 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. An intermittent 401 response

Copy prompt

Help with an intermittent 401 response 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. A race between two saves

Copy prompt

Help with a race between two saves 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. A missing list item after filtering

Copy prompt

Help with a missing list item after filtering 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.

26. A slow page under load

Copy prompt

Help with a slow page under load 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.

27. A broken deep link

Copy prompt

Help with a broken deep link 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.

28. A parser rejecting valid input

Copy prompt

Help with a parser rejecting valid input 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.

29. A stale cached response

Copy prompt

Help with a stale cached response 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.

30. An upload that works only locally

Copy prompt

Help with an upload that works only locally 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

Keep reading

More from the journal

All articles