Back to the blog

How to prompt an AI coding tool well: the method that changes everything

Code5 min read · 27 September 2026

The GetPack team

“Build me a to-do list” and “write an addTask function that adds a task to an array, with a title and a date, and write three tests to check it works” don’t produce the same result, with the same AI, on the same project. The difference isn’t luck; it’s method. Here’s the one Anthropic and GitHub each document, independently, in almost the same words.

Give context, not just a request

Claude’s official documentation offers a useful image: treat the AI like “a brilliant but new employee who lacks context on your norms and workflows.” The more precisely you explain what you want, the better the result. It even suggests a simple test for your own prompt: show it to a colleague with almost no context on the task. If they’d be confused, the AI will be too.

In practice, that means stating the expected output format, the constraints, and giving examples where you can. GitHub Copilot’s documentation recommends the same logic from the other direction: start with a general description of the goal, then add the precise requirements one by one, and avoid vague terms like “that” or “this thing” when several elements could match.

Before: “improve the signup form” After: “the signup form should reject a password under 8 characters and show the error message under the relevant field, not in a popup”

In both cases, ask yourself the same question before you hit send: if you gave this exact prompt to a classmate who’s never seen your project, would they know precisely what to do? If the answer is no, the AI will trip over the same blind spots they would.

Give the AI a role, and say why

Claude’s prompt engineering documentation offers another simple trick: give the AI a role at the start of the conversation. A single sentence already changes the outcome, for example “you are a patient coding tutor: whenever you propose code, explain in two sentences why you made that choice rather than another.” For a student who’s learning at the same time as building, that one setup line turns the AI into something that explains, not just something that produces.

The same documentation adds a principle that pays off every day: explain the why, not just the what. Its own example makes the point well. Instead of writing “never use ellipses,” it’s more effective to write “your response will be read aloud by a text-to-speech engine, so never use ellipses, since the engine won’t know how to pronounce them.” An AI coding tool reacts the same way: if you explain that a given file should never be touched because it’s auto-generated, or that a certain library should be avoided because it’s abandoned, the AI generalizes that reason to cases you didn’t think to spell out, instead of just obeying once.

Break a complex task into small ones

GitHub Copilot’s documentation is direct about this: “if you want Copilot to complete a complex or large task, break the task into multiple simple, small tasks.” One example it gives: instead of asking for “generate a word search puzzle” in one go, ask first for the letter grid, then for finding the words, then for combining the two.

Claude Code’s documentation shows the same idea with a before/after table: instead of “add tests for foo.py,” be specific: “write a test for foo.py covering the edge case where the user is logged out, avoid mocks.” The level of detail changes everything: the first version leaves the AI guessing at what actually matters; the second leaves nothing to chance.

Ask for a plan before any code

A common mistake is asking directly for code on a project you don’t yet know well yourself. The result can look correct without solving the right problem. Claude Code’s documentation recommends a four-step flow: explore (read the project, ask questions, without changing anything), plan (ask for a detailed plan), implement (execute the approved plan), commit (save the result with a clear message).

A prompt that follows this flow:

Explore the src/auth folder and explain how login
currently works.

then, once you’ve read the answer:

I want to add email login. What files need to change?
Propose a plan before touching any code.

Only after reading and approving that plan do you ask for the implementation.

Demand a way to verify the result

An AI coding tool stops when the result “looks” done. Without anything to check that objectively, that impression is the only signal available, and it’s sometimes wrong. Claude Code’s documentation advises always giving it a way to verify: a test, a screenshot to compare, a precise expected result.

Before: “implement a function that validates email addresses” After: “write a validateEmail function. Test cases: user@example.com should be true, invalid should be false, user@.com should be false. Run the tests after implementing.”

The second version gives the AI, and you, a clear criterion for knowing whether it’s actually done, instead of just an impression.

Review, and iterate without losing patience

No official guide claims an AI coding tool is always right. GitHub Copilot’s documentation says so plainly: “while Copilot is powerful, it can make mistakes, so you should always validate the code it suggests and understand suggested code before you implement it.” And if the result isn’t right on the first try, the same documentation simply recommends rephrasing and trying again, rather than pushing harder on a prompt that already failed.

Claude Code’s documentation goes a step further on this exact point: if you’ve corrected the same mistake more than twice in one conversation, the context is probably cluttered with failed attempts. It’s better to clear it (/clear) and start over with a more precise prompt, one that includes what you just learned, than to keep insisting indefinitely. None of this is a sign you’re bad at this; it’s simply what working with these tools looks like in practice, even for the people building them.

Key takeaways

  • Give context as if explaining the task to someone encountering it for the first time: expected format, constraints, examples.
  • Break a complex task into several simple requests instead of asking for everything at once.
  • Ask for a plan before any code as soon as the task touches several files or a project you don’t yet know well.
  • Always give a way to objectively verify the result: a test, a precise case, a reference screenshot.
  • Review what the AI proposes before using it, and if it’s still not working after two corrections, start over with a more precise prompt instead of insisting.

Ready-to-copy prompt templates for each of these steps are available in the prompts-vibe-coding skill.

Sources

  1. Best practices for Claude Code — Claude Code Docs · accessed 27 September 2026
  2. Prompting best practices — Claude Docs · accessed 27 September 2026
  3. Prompt engineering for GitHub Copilot Chat — GitHub Docs · accessed 27 September 2026

Read the next article

Code27 September 2026

Securing a vibe-coded app: 7 mistakes to fix before you publish

Code27 September 2026

Slopsquatting: when AI recommends packages that don't exist

Weekly brief27 September 2026

AI news roundup: the week of September 21–27, 2026

Code27 September 2026

Vibe coding: what it actually means (and how not to mess it up)

AI news27 September 2026

Why Yann LeCun wants AMI: AI beyond LLMs

Tutorial26 September 2026

Connect an MCP connector to Claude without writing a line of code

Degrees26 September 2026

Choosing your program with real MonMaster and InserSup data

Method26 September 2026

APA 7, ISO 690, Vancouver: how to cite your sources properly

Explainer26 September 2026

ChatGPT's 'hidden codes' on TikTok: fact vs. fiction

Health26 September 2026

Medicine: revise for the EDN with France's public drug database

Career26 September 2026

Internship pay and apprentice wages in 2026: the rules

Explainer26 September 2026

AI and academic integrity: what universities actually say

Tutorial26 September 2026

Installing a skill in Claude in 2 minutes

Thesis26 September 2026

Thesis: building your research question and outline with AI

Method26 September 2026

Building your exam study schedule with AI, the right way

Method26 September 2026

Revising with AI, honestly: active recall, Feynman, quizzes

Career26 September 2026

Choosing your apprenticeship with real employment data

Code27 September 2026

Learning to code in the age of AI: what you still need to know how to do yourself

Code27 September 2026

The one-page spec to write before you prompt an AI to code

Thesis27 September 2026

How to cite ChatGPT or Claude in a thesis: APA, MLA, ISO 690

Code27 September 2026

Claude Code for beginners: install, first launch, CLAUDE.md

AI news27 September 2026

Claude Opus 5.5: what really changes (and how to use it to study)

Analysis27 September 2026

The AI race: why some people are scared and others aren't

Code27 September 2026

Building your first MCP server, step by step

Code27 September 2026

Deploying your first site for free: Vercel, Netlify, Cloudflare Pages, or GitHub Pages

Explainer27 September 2026

AI detectors: are Turnitin, GPTZero and Compilatio reliable?

Code27 September 2026

Writing your own Claude skill: structure, SKILL.md, and a description that triggers

Career27 September 2026

France's national student-entrepreneur status (SNEE) and the PEPITE network, explained

Analysis27 September 2026

France in the AI race: Mistral, energy and talent

AI news27 September 2026

French Tech and AI: the French startups to know in 2026

Code27 September 2026

Git without fear: commit, branch, remote explained, then the commands that save you

Explainer27 September 2026

Chinese AI: DeepSeek, Qwen, Kimi… why Europe is wary

Health27 September 2026

AI in medical school: study for PASS, LAS and the EDN safely

Tools27 September 2026

Free AI for students: every offer and discount (2026)

Career27 September 2026

AI on an internship or apprenticeship: what’s allowed, what isn’t

Code27 September 2026

From IDE to ADE: coding with AI agents in 2026

Code27 September 2026

Reading an error without panicking: the anatomy of a stack trace (Python and JavaScript)

Tools27 September 2026

Best AI for students in 2026: the honest comparison

Tools27 September 2026

New AI models in 2026: which one should you study with?

Tools27 September 2026

French AI tools you’ve never heard of: Noota, Moshi, Vibe…

Analysis27 September 2026

Why AI is so expensive (and American AI even more so)

Join GetPack

Already have an account? Sign in