AI prompts / coding
5 AI prompts for coding
Coding assistants are best at narrow, well-described jobs. These prompts work in an AI code editor's chat, or in a general chat assistant if you paste the code in. Give the assistant the file, the error and what 'done' looks like, and always review the change before you keep it.
Fill in the [square brackets], copy and paste. Each prompt says when to use it, what you'll get and what to check before you rely on the answer. Written by Toolfitr, updated 2026-10-20.
Where to run them
Paste them into a coding tool. Our top-ranked coding tools:
- Cursor: From $8/mo (Plus, Grok models only); $30/mo (Premium) · Free tier available · #1 for coding
- GitHub Copilot: From $10/user/mo (Pro) · Free tier available · #2 for coding
- Windsurf: From $20/mo (Pro) · Free tier available · #3 for coding
1Explain this code before I change it
Use it when: You've inherited code (or forgotten your own) and need to understand it first.
Explain what this code does, step by step, for someone who knows [language] at a [beginner / intermediate] level. Then list: its inputs and outputs, anything it changes outside itself (files, database, network), and the 3 places a change is most likely to break something. Don't suggest changes yet. [paste code or name the file]
You get: A plain walkthrough and a list of the risky spots.
Check before you use it: Run the code or its tests if anything in the explanation surprises you.
2Write tests for one function
Use it when: You want to change a function safely and there are no tests.
Write unit tests for this function using [test framework]. Cover normal input, edge cases (empty, very large, wrong type) and the error paths. Don't change the function itself. Explain in one line what each test checks. [paste function]
You get: A set of tests with a one-line reason for each.
Check before you use it: Run them. A test that passes against broken code isn't testing anything.
3Find the bug from the error
Use it when: Something is broken and you have an error message or a stack trace.
I get this error when I [what you did]. Expected: [what should happen]. Actual: [what happens]. Here's the error and the relevant code. List the 3 most likely causes, most likely first, and how to confirm each one. Then suggest the smallest fix for the most likely cause. Error: [paste error] Code: [paste code]
You get: Ranked likely causes, how to confirm each, and a minimal fix.
Check before you use it: Confirm the cause before applying the fix. The first guess isn't always right.
4Plan the change before editing
Use it when: The change touches several files and you don't want the assistant rewriting everything.
I want to [describe the change]. Before writing any code, give me a plan: which files you'd change, what you'd change in each, what could break, and how we'll test it. Keep it to the smallest change that works. Wait for me to approve the plan before editing.
You get: A step-by-step plan you approve before any code is written.
Check before you use it: That the plan doesn't touch files it doesn't need to.
5Review a change for risks
Use it when: You (or the AI) wrote a change and want a second pair of eyes before you ship it.
Review this diff as a careful senior developer. List any bugs, security issues (secrets, injection, unchecked input), performance problems and missing error handling, most serious first. For each, quote the line and suggest the fix. Say 'looks fine' for parts that are fine. Don't restyle the code. [paste diff]
You get: A prioritised review with line-level fixes.
Check before you use it: Security items especially. Get a human review for anything handling payments or personal data.
The AI Stack Audit picks the right tool for each of your tasks and includes ready-to-use prompts written around your own work, with real costs and a 30-day plan, delivered within 24 hours.
Questions people ask
How do I use these coding prompts?
Copy a prompt, replace everything in [square brackets] with your own details, and paste it into a coding tool such as Cursor or GitHub Copilot or Windsurf. Read the answer before you use it, starting with the "check" line under each prompt.
Which AI tool is best for coding?
In our coding ranking, Cursor comes first (fit score 92/100). AI-first code editor for building whole features by prompt.
Are these prompts free to use?
Yes. They're original Toolfitr templates and you can use and adapt them for your own work. If you want prompts written around your own business and tools, that's part of the £29 AI Stack Audit.
More AI prompts
AI answers can be wrong or out of date, so check facts, numbers and names before you use them. Make a coding tool? Get an in-depth review or submit it free.
One email a week: the new AI tools worth trying.
Last 7 days: 21 new releases tracked · 12 real workflows found. The best go in the email.
Free · unsubscribe in one click. Want the shortlist now? Grab the free AI Starter Stack →