AI CodingThrive Editorial

50 AI Coding Prompts for Developers

The best coding prompt states the existing behavior, the intended change and how success will be checked. Give the assistant a small slice of the repository and require a testable diff.

24 min read
Developer workspace with a laptop and an orange thread connecting coding tasks.

The short version

  • The best coding prompt states the existing behavior, the intended change and how success will be checked. Give the assistant a small slice of the repository and require a testable diff.
  • 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.

The best coding prompt states the existing behavior, the intended change and how success will be checked. Give the assistant a small slice of the repository and require a testable diff.

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 failing date parser

Copy prompt

Help with a failing date parser 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 slow database query

Copy prompt

Help with a slow database query 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 form with duplicate submissions

Copy prompt

Help with a form with duplicate submissions 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 API with inconsistent errors

Copy prompt

Help with an API with inconsistent errors 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 pagination edge case

Copy prompt

Help with a pagination edge case 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 flaky integration test

Copy prompt

Help with a flaky integration test 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 file upload limit

Copy prompt

Help with a file upload limit 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 cache invalidation bug

Copy prompt

Help with a cache invalidation 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.

9. A queue retry loop

Copy prompt

Help with a queue retry loop 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 authorization check

Copy prompt

Help with an authorization check 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 failing date parser

Copy prompt

Help with a failing date parser 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 slow database query

Copy prompt

Help with a slow database query 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 form with duplicate submissions

Copy prompt

Help with a form with duplicate submissions 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 API with inconsistent errors

Copy prompt

Help with an API with inconsistent errors 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 pagination edge case

Copy prompt

Help with a pagination edge case 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 flaky integration test

Copy prompt

Help with a flaky integration test 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 file upload limit

Copy prompt

Help with a file upload limit 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.

Visual example of a developer isolating a failing parser, making a focused change and running a check.

18. A cache invalidation bug

Copy prompt

Help with a cache invalidation 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.

19. A queue retry loop

Copy prompt

Help with a queue retry loop 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 authorization check

Copy prompt

Help with an authorization check 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 failing date parser

Copy prompt

Help with a failing date parser 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 slow database query

Copy prompt

Help with a slow database query 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 form with duplicate submissions

Copy prompt

Help with a form with duplicate submissions 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 API with inconsistent errors

Copy prompt

Help with an API with inconsistent errors 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 pagination edge case

Copy prompt

Help with a pagination edge case 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 flaky integration test

Copy prompt

Help with a flaky integration test 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 file upload limit

Copy prompt

Help with a file upload limit 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 cache invalidation bug

Copy prompt

Help with a cache invalidation 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.

29. A queue retry loop

Copy prompt

Help with a queue retry loop 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 authorization check

Copy prompt

Help with an authorization check 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.

Review safety prompts

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

31. A failing date parser

Copy prompt

Help with a failing date parser in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then inspect authorization, input validation, error disclosure and rollback behavior. 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: Verify security claims against the actual routes and database policy.

32. A slow database query

Copy prompt

Help with a slow database query in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then inspect authorization, input validation, error disclosure and rollback behavior. 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: Verify security claims against the actual routes and database policy.

33. A form with duplicate submissions

Copy prompt

Help with a form with duplicate submissions in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then inspect authorization, input validation, error disclosure and rollback behavior. 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: Verify security claims against the actual routes and database policy.

34. An API with inconsistent errors

Copy prompt

Help with an API with inconsistent errors in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then inspect authorization, input validation, error disclosure and rollback behavior. 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: Verify security claims against the actual routes and database policy.

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

35. A pagination edge case

Copy prompt

Help with a pagination edge case in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then inspect authorization, input validation, error disclosure and rollback behavior. 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: Verify security claims against the actual routes and database policy.

36. A flaky integration test

Copy prompt

Help with a flaky integration test in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then inspect authorization, input validation, error disclosure and rollback behavior. 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: Verify security claims against the actual routes and database policy.

37. A file upload limit

Copy prompt

Help with a file upload limit in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then inspect authorization, input validation, error disclosure and rollback behavior. 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: Verify security claims against the actual routes and database policy.

38. A cache invalidation bug

Copy prompt

Help with a cache invalidation bug in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then inspect authorization, input validation, error disclosure and rollback behavior. 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: Verify security claims against the actual routes and database policy.

39. A queue retry loop

Copy prompt

Help with a queue retry loop in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then inspect authorization, input validation, error disclosure and rollback behavior. 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: Verify security claims against the actual routes and database policy.

40. An authorization check

Copy prompt

Help with an authorization check in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then inspect authorization, input validation, error disclosure and rollback behavior. 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: Verify security claims against the actual routes and database policy.

Document handoff prompts

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

41. A failing date parser

Copy prompt

Help with a failing date parser in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then write a concise changelog, usage example and rollback note tied to the implementation. 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: Remove claims that were not measured or tested.

42. A slow database query

Copy prompt

Help with a slow database query in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then write a concise changelog, usage example and rollback note tied to the implementation. 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: Remove claims that were not measured or tested.

43. A form with duplicate submissions

Copy prompt

Help with a form with duplicate submissions in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then write a concise changelog, usage example and rollback note tied to the implementation. 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: Remove claims that were not measured or tested.

44. An API with inconsistent errors

Copy prompt

Help with an API with inconsistent errors in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then write a concise changelog, usage example and rollback note tied to the implementation. 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: Remove claims that were not measured or tested.

45. A pagination edge case

Copy prompt

Help with a pagination edge case in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then write a concise changelog, usage example and rollback note tied to the implementation. 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: Remove claims that were not measured or tested.

46. A flaky integration test

Copy prompt

Help with a flaky integration test in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then write a concise changelog, usage example and rollback note tied to the implementation. 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: Remove claims that were not measured or tested.

47. A file upload limit

Copy prompt

Help with a file upload limit in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then write a concise changelog, usage example and rollback note tied to the implementation. 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: Remove claims that were not measured or tested.

48. A cache invalidation bug

Copy prompt

Help with a cache invalidation bug in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then write a concise changelog, usage example and rollback note tied to the implementation. 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: Remove claims that were not measured or tested.

49. A queue retry loop

Copy prompt

Help with a queue retry loop in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then write a concise changelog, usage example and rollback note tied to the implementation. 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: Remove claims that were not measured or tested.

50. An authorization check

Copy prompt

Help with an authorization check in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then write a concise changelog, usage example and rollback note tied to the implementation. 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: Remove claims that were not measured or tested.

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

Have a question or a correction?

Contact Thrive

Keep reading

More from the journal

All articles