Prompting AI Coding Assistants
Prompting an AI coding assistant well means giving it a clear, specific request — the goal, the context, and the exact problem — so it can help on the first try instead of guessing. The difference is dramatic: “fix my code” makes the model guess your language and your bug, while “there’s a TypeError on line 15 because total is a string — convert it to a number” points it straight at the fix.
Learn Prompting AI Coding Assistants in our free AI & Machine Learning course — a beginner-friendly interactive lesson with worked examples, a practice…
Part of the free AI & Machine Learning course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
Tools like Claude and ChatGPT are incredibly capable, but they only know what you tell them. This lesson teaches the habits of a great prompt — the same precise, feedback-driven style that platforms like Codecademy use to keep learners unblocked.
An AI assistant produces the most likely helpful answer to the words you give it. Vague words force it to guess; specific words let it solve. Same bug, two prompts:
The model has no code, no error, no goal. It will guess — and probably rewrite something you didn’t want.
Goal, language, the real error, the cause, and the desired output — nothing left to guess.
Strong coding prompts almost always contain these six ingredients. You don’t need all six every time, but the more ambiguous your problem, the more you should include:
Tip: asking for a specific output format (“just the diff”, “explain then code”, “add type hints and a test”) saves you re-prompting.
This is the highest-value habit in the whole lesson. Instead of describing a feeling (“it’s not working”), report the facts the way a good bug report does:
Run this buggy snippet, read the real traceback, then practise turning it into a precise prompt:
The first answer is rarely the last. Treat it as a draft and steer with specific corrections — don’t throw it all away with “still broken”:
Other high-leverage moves: ask the AI to explain its reasoning , to list edge cases it didn’t handle, to write tests for the fix, or to give 2-3 approaches with trade-offs before you pick one.
📋 Copy-paste prompt template
⏱ Test Yourself — Timed Quiz
10 quick questions, 12 seconds each. Instant feedback — beat the clock!
Practice quiz
Your code crashes. What's the MOST useful thing to give the AI?
- A vague 'it's broken'
- Just the file name
- The full error message and the line number
- A screenshot with no text
Answer: The full error message and the line number. The exact exception, message, and line number often point straight at the cause.
Which is the better bug report to an AI assistant?
- 'TypeError on line 7: I'm adding a string to an int; convert with float() first'
- 'the total is wrong, help'
- 'fix my python'
- 'doesn't work'
Answer: 'TypeError on line 7: I'm adding a string to an int; convert with float() first'. Specific facts — what, where, and why — let the model solve instead of guess.
How much context should a coding prompt include?
- Your entire repo
- Nothing — let it guess
- Only the file name
- The smallest reproducible example plus language/version and the goal
Answer: The smallest reproducible example plus language/version and the goal. Enough to remove ambiguity, but the smallest snippet that reproduces the issue.
The AI's first answer fixed one bug but broke something else. You should…
- Start over with 'still broken'
- Reply with the new precise symptom (new error + line)
- Give up
- Paste the whole repo
Answer: Reply with the new precise symptom (new error + line). Iterate with targeted corrections; each specific symptom steers the model closer.
Why do specific prompts get better code?
- The model predicts the most helpful reply to YOUR words — specifics remove the guesswork
- The model charges more for vague ones
- Length is all that matters
- It doesn't matter
Answer: The model predicts the most helpful reply to YOUR words — specifics remove the guesswork. Vague input forces the model to guess your language, intent, and bug.
Which is NOT part of a great coding prompt?
- The goal
- The exact error
- Your astrological sign
- Constraints and desired output format
Answer: Your astrological sign. Goal, context, code, error, constraints, and output format are the six useful ingredients.
What should you do BEFORE shipping AI-written code?
- Nothing, just trust it
- Read and test it, and ask it to explain anything unclear
- Delete the tests
- Push straight to production
Answer: Read and test it, and ask it to explain anything unclear. Always read, test, and understand — the AI can be confidently wrong.
Best way to report a syntax error to an AI?
- 'syntax broken'
- '???'
- Say nothing and re-run
- 'There's a syntax error on line 15: a string is missing its closing quote — please close it'
Answer: 'There's a syntax error on line 15: a string is missing its closing quote — please close it'. Name the line and the precise cause — that's the highest-value habit in the lesson.
Pasting the FULL traceback vs describing it is…
- Worse — too long
- Better — the exact type, message, and line are gold
- The same
- Only for experts
Answer: Better — the exact type, message, and line are gold. Paste it verbatim; never paraphrase an error you could copy exactly.
Asking the AI for a specific OUTPUT FORMAT (e.g. 'just the diff')…
- Confuses it
- Is rude
- Saves you re-prompting and gets a tidier answer
- Has no effect
Answer: Saves you re-prompting and gets a tidier answer. Specifying the format ('explain then code', 'add a test') reduces back-and-forth.