Guides18 min read24 May 2026

150 Prompts to Level Up Your Coding

A complete reference of ready-to-use AI prompts for every coding task — debugging, code review, refactoring, testing, architecture, security, and more. Copy, adapt, and go.

These are prompt templates — replace anything in [square brackets] with your specific code, error, or context. The more detail you give the AI, the more targeted the response.

150 prompts organised by coding task. Whether you're stuck on a bug, reviewing a PR, designing a system, or learning a new language — find the right prompt, adapt it to your situation, and get a useful answer in seconds.

Jump to any section: Debugging · Code Review · Refactoring · Testing · Documentation · Learning Languages · Architecture · Security · Performance · SQL & Databases

1. Debugging & Error Fixing — Prompts 1–15

The key to getting good debugging help is giving enough context: the full error, the relevant code, and what you expected to happen. A vague "it's broken" prompt produces a vague answer.

Always paste the full error message, not just the last line. The most useful diagnostic information is often in the middle of a stack trace.
Prompts 1–5
1. "Here is my error: [paste error]. Here is the relevant code: [paste code]. Explain what is causing this error step by step, then give me the exact fix."

2. "I'm getting a [error type] in [language]. List every possible cause of this error and a diagnostic step for each one so I can identify which applies to my situation."

3. "My function is returning [wrong result] instead of [expected result]. Trace through this code line by line and tell me exactly where it goes wrong: [paste code]"

4. "Act as a rubber duck debugger. I have a bug I can't solve. Ask me one question at a time to help me narrow it down. Bug: [describe in one sentence]"

5. "Explain every line of this stack trace in plain English. Where should I start looking? [paste full stack trace]"
Prompts 6–10
6. "This bug only happens in production, not locally. Here's what I know: [describe the bug, environment, and any recent changes]. What are the most likely causes and how would I add logging to catch it?"

7. "This code works on my machine but fails on the server with this error: [paste error]. What environment-specific differences should I check?"

8. "My API call is failing. Here's the request code and the error response: [paste both]. What should I investigate first and how do I add proper error handling?"

9. "I fixed this bug last week and it's back. Original fix: [describe]. Current failure: [describe]. What did I miss — what's the root cause I keep patching over?"

10. "Write a set of unit tests that would expose the bug in this function. I want tests that fail with the current code: [paste function + describe what's wrong]"
Prompts 11–15
11. "I have a race condition in this code. Explain where it occurs and give me the safest fix: [paste code]"

12. "This regex isn't matching what I expect. Pattern: [paste]. Input: [paste]. Expected match: [describe]. Walk me through what it's actually matching and rewrite it correctly."

13. "My application has a memory leak. Here's the relevant code: [paste]. What are the most likely causes and how do I track down the exact source?"

14. "This async/Promise code is resolving in the wrong order. Walk me through the execution order step by step, then fix it: [paste code]"

15. "I'm getting CORS errors. Here's my frontend request code, my backend CORS config, and the browser error: [paste all three]. What's wrong and what's the fix?"

2. Code Review — Prompts 16–30

Use these prompts before code goes to production. The best results come from being specific about what you care about — performance, readability, security — rather than asking for a "general review." The more context you give about what the code does and who uses it, the more useful the feedback.

Tell the AI what kind of application this is and the expected scale. Review criteria for a weekend project differ from production code serving thousands of users.
Prompts 16–20
16. "Act as a senior software engineer doing a pre-production review. Be critical. Point out anything that could cause bugs, performance issues, security vulnerabilities, or maintenance problems: [paste code]"

17. "List every edge case this function doesn't handle. I want an exhaustive list, not just the obvious ones: [paste function]"

18. "This code works but I don't think it's idiomatic [language]. Rewrite it the idiomatic way and explain every change you made: [paste code]"

19. "What would a strict linting audit flag in this file? List every issue with its severity and the fix: [paste code]"

20. "Would a developer joining this project understand this code without asking questions? What specifically is unclear and how would you improve it? [paste code]"
Prompts 21–25
21. "This function is doing too many things. List every responsibility it has, then tell me how you'd split it into focused functions: [paste code]"

22. "Compare these two implementations of the same feature. Which is better, why, and what are the real-world tradeoffs? [paste both implementations]"

23. "What happens to this code if someone passes in null, undefined, an empty array, 0, or a very large number? Will any of these break it? [paste function]"

24. "Review the error handling in this code. Is anything being silently swallowed? Are errors specific enough? What would a developer see when this fails in production? [paste code]"

25. "Find every magic number and magic string in this code and suggest a named constant for each: [paste code]"
Prompts 26–30
26. "Does this code have any security vulnerabilities? Check for SQL injection, XSS, insecure data handling, and exposed secrets: [paste code]"

27. "This code is hard to test. What makes it untestable and how would you refactor it to be testable without changing the public interface? [paste code]"

28. "Review this API endpoint for correctness. Does it validate all inputs? Is the response shape consistent? Could it be abused? [paste code]"

29. "What parts of this code would be hardest to change if requirements changed? Where is the coupling too tight? [paste code]"

30. "This code was written 2 years ago. What patterns or approaches here are now outdated and what would you replace them with? [paste code]"

3. Refactoring & Clean Code — Prompts 31–45

Refactoring prompts work best when you state your constraints clearly: don't change the external behaviour, keep the same function signature, don't introduce new dependencies. Without guardrails you'll get a full rewrite rather than a refactor.

Always ask the AI to explain each change it makes. Applying a refactor you don't understand leads to bugs you can't diagnose later.
Prompts 31–35
31. "Refactor this function to be more readable. Do not change its external behaviour. Explain every change you make: [paste code]"

32. "This function is too long. Split it into smaller, single-responsibility functions without changing the external interface: [paste code]"

33. "Replace all the nested if/else chains in this code with a cleaner approach. Explain the pattern you chose and why it's better: [paste code]"

34. "I have duplicated logic in 4 places. Identify the pattern and extract it into a shared utility without over-engineering it: [paste code from all locations]"

35. "Refactor this callback hell into async/await. Make sure the error handling stays correct throughout: [paste code]"
Prompts 36–40
36. "This code mutates state in many places and it's causing bugs. Refactor it to be more functional and immutable where practical: [paste code]"

37. "Apply the Single Responsibility Principle to this class. What should be extracted into its own class or module? [paste code]"

38. "This code is tightly coupled to [library/framework]. Refactor it so the dependency could be swapped without touching the surrounding code: [paste code]"

39. "Convert these imperative loops into a declarative style using map, filter, and reduce. Explain each transformation: [paste code]"

40. "This conditional logic is deeply nested and hard to follow. Flatten it using early returns and guard clauses: [paste code]"
Prompts 41–45
41. "There's a repeated pattern across these 5 functions. Extract it into a reusable abstraction — but don't over-engineer it: [paste all functions]"

42. "Rename every variable and function in this code to be more descriptive. Show me before and after, and explain your naming choices: [paste code]"

43. "This React component is doing too much. Split it into smaller components, each with one clear responsibility: [paste component]"

44. "Remove every comment in this code that just describes what the code does rather than why. Tell me which ones you removed and which you kept: [paste code]"

45. "Migrate this class-based React component to a functional component with hooks. Preserve all existing behaviour: [paste component]"

4. Writing Tests — Prompts 46–60

Testing prompts work best when you're specific about what kind of tests you want. Unit vs integration, mocked vs real dependencies, coverage targets — specify these upfront and you'll get tests you can actually use.

Ask for tests that fail with the current code, then pass after the fix. This proves the tests actually cover the behaviour you care about.
Prompts 46–50
46. "Write a complete test suite for this function. Include: the happy path, all edge cases, boundary values, and all error paths: [paste function]"

47. "I'm new to testing in [language]. Show me how to write my first test for this function using [testing framework]. Explain every part: [paste function]"

48. "I already have these tests: [list them]. What am I missing? Here's the full function: [paste code]"

49. "Write integration tests for this API endpoint that cover all success responses, all validation errors, and all server errors: [paste route]"

50. "Write tests for this function that test real behaviour — no mocking unless testing external I/O is unavoidable: [paste function]"
Prompts 51–55
51. "I want to add tests to this legacy untested code. What's the safest order to add coverage without breaking anything? [paste code]"

52. "This function is hard to test because of side effects and external dependencies. Show me how to refactor it to be testable first, then write the tests: [paste code]"

53. "Write property-based tests for this function. What properties should always hold regardless of the input? [paste function]"

54. "Write snapshot tests for this React component. Explain what they're actually testing and what their limitations are: [paste component]"

55. "These tests are slow. Diagnose what's making them slow and suggest specific fixes: [paste test suite]"
Prompts 56–60
56. "These tests pass sometimes and fail other times. Here's the code: [paste]. What's causing the flakiness and how do I fix it?"

57. "Write tests that verify the side effects of this async function, not just its return value: [paste function]"

58. "What's the minimum number of tests needed to get meaningful coverage of this module? Write them: [paste module]"

59. "Write a test that verifies this function fails gracefully with invalid input and produces a useful error message: [paste function]"

60. "I wrote this test and I'm not sure it's testing what I think. Explain what it's actually testing and whether it's a good test: [paste test]"

5. Documentation — Prompts 61–70

Good documentation prompts are specific about audience and format. A JSDoc for a public API is different from a comment explaining a gnarly algorithm to a future maintainer. Tell the AI who will read this and what they need to know.

Ask for comments that explain WHY, not WHAT. If the comment just restates what the code does, the code should do that job instead. Comments that explain why survive refactors. Comments that describe what don't.
Prompts 61–65
61. "Write a JSDoc/docstring for this function. Include: what it does, each parameter with its type, the return value, any errors it throws, and a usage example: [paste function]"

62. "Write a README for this project. Cover: what it does, prerequisites, installation, running locally, running tests, and how to contribute: [describe the project]"

63. "Add inline comments to this code — only for the non-obvious parts. Comment the WHY, not the WHAT. Flag anything that would surprise a developer reading it cold: [paste code]"

64. "Write API documentation for these endpoints in the style of Stripe's API docs — clear, specific, with example requests and responses for every endpoint: [paste routes]"

65. "Explain this code to a junior developer who knows basic [language] but hasn't seen [pattern] before. Walk them through it step by step: [paste code]"
Prompts 66–70
66. "Write an Architecture Decision Record (ADR) for this decision. Include: the context, the options considered, the decision made, and why: [describe the decision]"

67. "Generate a practical usage guide for this library with 5 real-world examples from simple to complex: [paste the API surface]"

68. "This documentation no longer matches the code. Here's the current code and the old docs. Rewrite the docs to accurately describe what the code does now: [paste both]"

69. "Write helpful error messages for each of these error cases — specific, actionable, and with enough context for the developer to fix the problem: [paste error scenarios]"

70. "Create a CHANGELOG entry for these changes following Keep a Changelog format (Added / Changed / Fixed / Removed): [describe what changed]"

6. Learning New Languages & Frameworks — Prompts 71–85

The most effective way to learn a new language is to anchor it to what you already know — don't learn from scratch, translate. These prompts are built around that approach.

Ask for the mental model first, then the syntax. If you understand why something works the way it does, the syntax becomes obvious. If you learn the syntax first, you'll keep reaching for the wrong tools.
Prompts 71–75
71. "I know [language A] well. Teach me the [language B] equivalent of [concept/pattern]. Show both side by side with explanations of the key differences."

72. "I'm switching from [language A] to [language B]. What are the 10 most common mistakes developers make when switching and why do they happen?"

73. "Explain [concept] in [language] to someone who understands programming well but has never used this language before."

74. "Show me how [language] handles [concept] differently from [language I already know]. Give me 3 progressively complex examples with explanations."

75. "Give me the 20 standard library functions I'll use most often in [language]. One-line description and one example for each."
Prompts 76–80
76. "I'm reading this [language] code but don't understand this pattern: [paste snippet]. Explain it from first principles."

77. "Show me idiomatic error handling in [language] — from the most common wrong approach to the correct idiomatic way, with examples."

78. "I keep hearing about [concept] in [language/ecosystem]. Explain it from first principles and show me a real example of when and why to use it."

79. "Explain memory management in [language] to someone coming from a garbage-collected language. What do I need to think about that I never had to before?"

80. "Create a syntax cheat sheet for [language] aimed at an experienced developer: variables, functions, loops, conditionals, classes/structs, error handling, imports."
Prompts 81–85
81. "I wrote this in [language A]. Translate it to idiomatic [language B] and explain every significant decision you made in the translation: [paste code]"

82. "What are the most common performance pitfalls in [language] for developers coming from [language I know]? What assumptions are wrong?"

83. "Explain how package management works in [language] compared to [npm/pip/cargo] that I already use. What's equivalent to what?"

84. "I want to build [type of project] in [language]. What are the standard tools, frameworks, and libraries I should use and why are they the community default?"

85. "Quiz me on [language] fundamentals. 10 questions of increasing difficulty. Ask one at a time and tell me if I'm right before moving on."

7. Architecture & System Design — Prompts 86–100

Architecture questions benefit most from context about your constraints — team size, expected traffic, budget, existing tech stack. The "best" architecture for a solo project is very different from the best architecture for a 20-person engineering team.

State your priorities upfront: "I care most about [X]. I have [Y] budget/team/time. I'm already using [Z]." Architecture advice without constraints produces generic answers that don't apply to your situation.
Prompts 86–90
86. "I'm building [describe system]. Walk me through at least 2 architecture options with their tradeoffs, then recommend one given these constraints: [describe constraints]"

87. "Review this system design for single points of failure, scalability bottlenecks, and security risks: [describe or paste architecture]"

88. "Design a database schema for [describe requirements]. Give me tables, relationships, constraints, and indexes — with reasoning for every decision."

89. "What design patterns apply to this problem? Explain each one and which you'd recommend: [describe the problem]"

90. "My monolith is getting too large to manage. What's the safest step-by-step process to extract [feature] into a separate service without breaking anything?"
Prompts 91–95
91. "Help me think through [option A] vs [option B] for [use case]. My priorities are [list them]. Walk me through the decision."

92. "My application needs to handle [N] requests per second. Design a scalable architecture starting from my current setup: [describe current setup]"

93. "Design a caching strategy for this system. What to cache, for how long, and how should cache invalidation work? [describe data access patterns]"

94. "Review this proposed API design for REST principle violations, inconsistencies, and developer experience issues: [paste API design]"

95. "What would a 12-factor app version of my current application look like? What would I need to change? [describe current setup]"
Prompts 96–100
96. "I need to add authentication to this application. Walk me through every decision I need to make and the tradeoffs of each option."

97. "Design the events for an event-driven version of this currently synchronous system: [describe the system]"

98. "What are all the failure modes of this architecture and how would I make it more resilient? [describe the system]"

99. "Help me choose between a relational and document database for [use case]. Walk me through the decision criteria and give me a recommendation."

100. "Design the folder structure and module boundaries for a [type] application in [language/framework]. I want it to scale as the codebase and team grow."

8. Security Reviews — Prompts 101–115

Security prompts are most valuable before you ship. Use them as a pre-release checklist. The earlier you find a vulnerability, the cheaper it is to fix — a code review comment costs nothing; a production incident costs a lot.

AI security reviews catch obvious issues but aren't a replacement for dedicated security tooling or a human review for applications handling sensitive data. Use these to find the low-hanging fruit — then go deeper.
Prompts 101–105
101. "Review this code for SQL injection vulnerabilities. Show me every vulnerable line and the parameterised fix for each: [paste code]"

102. "Is this authentication implementation secure? What would an attacker look for first and what's the most likely way to break in? [paste code]"

103. "Review these API routes for broken access control. Could a user access or modify another user's data anywhere here? [paste routes]"

104. "I'm storing [type of sensitive data]. What exactly should I encrypt, what should I hash (with what algorithm), and what's the correct implementation?"

105. "Is this input validation sufficient? What inputs could bypass it? Give me specific examples that would get through: [paste validation code]"
Prompts 106–110
106. "Review how I'm handling environment variables and secrets. Am I exposing anything I shouldn't? [paste config handling code]"

107. "What are the top 5 OWASP vulnerabilities most likely to affect a [type] application? For each: how do I check if I'm vulnerable and what's the fix?"

108. "Is this JWT implementation secure? What attacks does it protect against and what does it leave open? [paste code]"

109. "How do I test this frontend for XSS vulnerabilities? What should I look for in the code and how do I test it manually? [paste code]"

110. "Review this file upload handling for security issues — file type validation, path traversal, size limits, and storage location: [paste code]"
Prompts 111–115
111. "I'm using [library name]. What are the known security risks I should be aware of and how do I mitigate them?"

112. "Write a pre-release security review checklist for a [type of application] that my team can run through before every release."

113. "Review this session management code for security issues. What could an attacker exploit and what's the fix? [paste code]"

114. "What information is my application logging that it shouldn't be? Look for passwords, tokens, PII, or other sensitive data: [paste logging code]"

115. "Harden this [framework] server configuration. What security headers, rate limiting, CORS policy, and other protections should I add? [paste current config]"

9. Performance Optimisation — Prompts 116–130

Performance prompts work best when you give the AI real numbers to work with. "This is slow" produces generic advice. "This endpoint takes 800ms and profiling shows 90% is in this database query" produces a targeted fix.

Include approximate data volumes in your prompts. An optimisation that's perfect for 10,000 rows might be the wrong approach for 10 million rows.
Prompts 116–120
116. "This function is slow on large inputs. Read the code and identify the bottleneck, then give me a faster version: [paste code + describe input size]"

117. "What is the time and space complexity of this algorithm? How would you improve it? Show me the better version with the new complexity: [paste code]"

118. "This database query is too slow. Here's the query, the schema, and approximate row counts per table: [paste all three]. How do I optimise it?"

119. "What are the most common performance bottlenecks in [framework] applications and how do I diagnose each one?"

120. "My list rendering is sluggish with [N] items. Here's the component: [paste]. Give me all the optimisation options from most to least impactful."
Prompts 121–125
121. "Rewrite this O(n²) algorithm to be more efficient. Show your reasoning step by step and give me the new time complexity: [paste code]"

122. "My API response time is high under load. Here's the endpoint: [paste code]. What should I measure first and what are the most likely bottlenecks?"

123. "Where in this code would caching have the biggest impact? Design a caching layer for the highest-value data: [paste code]"

124. "I'm making too many database queries per request. Here's my data access code: [paste]. Show me how to reduce the query count."

125. "My JavaScript bundle is too large. Here are my main dependencies: [list]. What should I investigate first and what are my options?"
Prompts 126–130
126. "Explain code splitting and lazy loading in [framework] and show me exactly how to apply them to this code: [paste code]"

127. "This WebSocket server struggles under [N] concurrent connections. What architecture changes would help most and what should I measure first?"

128. "Write a benchmark for this function so I can measure the before and after of my optimisation: [paste function]"

129. "Estimate the memory footprint of this code. Where are the biggest allocations and where could I reduce them? [paste code]"

130. "I need to process [N million] records. My current approach: [describe]. Give me faster alternatives with their tradeoffs."

10. SQL & Databases — Prompts 131–150

Database prompts work best when you include the schema. Paste the relevant table structures and row counts — the AI can't suggest the right indexes or join strategy without knowing what exists.

For slow query help, run EXPLAIN ANALYZE on your query in Postgres and paste the output. The AI can read a query plan and tell you exactly where the time is going.
Prompts 131–135
131. "Write a SQL query to [describe exactly what you need]. Here's my schema: [paste relevant CREATE TABLE statements]"

132. "Explain this SQL query in plain English. Then tell me if it's efficient and how I'd improve it: [paste query]"

133. "This query is slow. Here's the query, the schema, and approximate row counts per table: [paste all]. How do I optimise it?"

134. "What indexes should I add to speed up these queries? Give me the CREATE INDEX statements with an explanation for each: [paste queries + schema]"

135. "Rewrite this subquery as a JOIN. Then tell me which version will perform better and why: [paste query]"
Prompts 136–140
136. "I need to run this migration: [describe the change]. Write the migration SQL and the rollback SQL in case something goes wrong."

137. "Explain INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN using concrete examples from my actual schema: [paste schema]"

138. "Write a query using a window function to [describe requirement]. Then show me the equivalent without window functions so I understand the difference: [paste schema]"

139. "My ORM is generating this SQL: [paste]. Is it efficient? How would I rewrite the underlying query to perform better?"

140. "Design a database schema for [describe requirements]. Give me tables, data types, constraints, and indexes — with your reasoning for every decision."
Prompts 141–145
141. "I'm confused about when to use WHERE vs HAVING. Explain the difference and give me a concrete example using my actual tables: [paste schema + use case]"

142. "I need to paginate this query efficiently for a table with [N million] rows. My current approach: [paste]. What's the right way?"

143. "Explain database transactions and rewrite this sequence of operations as a safe transaction with proper error handling: [paste code]"

144. "Explain what this EXPLAIN ANALYZE output means. Is my query efficient and what should I change? [paste query plan output]"

145. "I need to aggregate this data: [describe]. Write the SQL and tell me whether GROUP BY or a window function is the right tool here and why."
Prompts 146–150
146. "My database schema has grown organically and has some problems. Review it and suggest concrete improvements: [paste current schema]"

147. "Write a query to detect and remove duplicate rows in this table, keeping the most recently created one: [paste table structure]"

148. "I need full-text search on this table. Show me how to set it up and write an efficient search query: [paste schema]"

149. "What's the difference between a clustered and non-clustered index and which should I use for this query? [paste query + schema]"

150. "My application does a lot of [describe read/write pattern]. What database configuration changes and schema choices would help performance most?"

Getting the Most Out of These Prompts

The prompts above are starting points, not magic spells. How well you fill in the placeholders matters more than the template itself. Here's what separates prompts that get immediately useful answers from ones that get generic responses.

  • Always include the actual code — not "here's a sorting function" but the real function with its real variable names
  • Add your constraints upfront: language version, framework, team size, performance requirements, what you've already tried
  • Describe what you expected to happen alongside what actually happened — this context is often the key to a good answer
  • If you get a mediocre first response, tell the AI specifically what was wrong and ask it to try again with that feedback
  • For complex problems, break them into steps rather than asking for everything in one shot
  • Tell the AI your experience level in the relevant area so it calibrates its explanation appropriately
The best use of AI for coding isn't replacing your thinking — it's eliminating the blank page and the "where do I start?" paralysis. You still make the decisions. The AI handles the grunt work.
promptingcodingdeveloper toolsAI
🎓Interactive Courses

Ready to go further?

Take the interactive course — daily lessons, real exercises, XP and streaks. Turn reading into lasting skills.

Daily streaksXP & levels
Start a course