Accueil / Articles / Ten Prompt Engineering Mistakes Developers Make, With Fixes

Cet article est publié en anglais.

Ten Prompt Engineering Mistakes Developers Make, With Fixes

Ten common prompting errors, from vague requests and missing context to blind trust in output, each paired with a concrete before-and-after prompt you can reuse.

1148 mots

Weak output from Copilot, ChatGPT and similar assistants usually has less to do with the model than with the request typed into it. Plenty of developers expect the tool to guess what they mean, then get something wrong or half-finished and blame the AI. Treat it like a bright but very literal junior colleague. Hand over vague requirements and you'll get vague code back. Give it detail, context, constraints and expectations, and the results improve a lot. Ten mistakes show up again and again, and each one has a quick fix.

Too little context

The classic version is a one-line request:

Create a login API.

That leaves the model guessing about the language, the framework, security requirements, the database and the authentication method. Spell those out instead:

Create a Spring Boot REST API for user login using JWT authentication.
Use MySQL as the database.
Follow industry security practices and include exception handling.

Output quality tracks the quality of the context you supply.

Treating the model as if it knows your project

Questions often come in the middle of a session with no description of the existing code:

Add caching to this application.

Where should the cache go? The service layer, the database layer, API responses? Redis or something local? The model can't read your mind, so describe where things stand before asking for a change:

I have a Spring Boot microservice that retrieves customer information from MySQL.
The customer records rarely change.
Suggest a Redis caching implementation to reduce database calls.

Piling everything into one request

A long wish list in a single message tends to get shallow treatment:

Create APIs, add authentication, optimize performance,
write unit tests, review security, and deploy to AWS.

Cut it into stages and take them one by one:

Step 1: Design the API architecture.

Step 2: Implement authentication.

Step 3: Generate unit tests.

Step 4: Review security concerns.

Handle the conversation like an engineering process, not a magic spell.

Leaving out constraints

When no limits are given, the model fills in its own assumptions. Take this request:

Optimize this code.

Optimize for speed, memory, readability or cost? Say which one, and say what's off the table:

Optimize this Java code for readability while maintaining the same functionality.
Avoid introducing additional libraries.

Define what success means before you ask.

Skipping the role

Assigning a persona is a powerful technique that many people never use. Compare a bare request:

Review this code.

with one that names who is reviewing and what to look for:

Act as a Senior Software Architect.

Review the following code for:
- Performance issues
- Security vulnerabilities
- Scalability concerns
- Maintainability

Say who the model should act as before you ask the question.

Taking the first reply as final

Experienced engineers iterate, and prompting works the same way. Follow-ups like these push a draft toward something usable:

Can you simplify this solution?

What are the drawbacks?

Can you improve performance?

Show a production-ready version.

Real value comes from the refinement loop. Consider the first answer a draft.

Not showing an example

Models do much better when you include a sample. Without one you get a guess at the format:

Generate a JSON response.

With a target structure in the request, the model knows precisely what shape you want:

Generate a JSON response matching this structure:

{
  "userId": 101,
  "name": "John Doe",
  "status": "Active"
}

Examples cut ambiguity and make results more consistent.

Trusting the output blindly

This may be the most dangerous mistake. Generated code can be outdated, can invent APIs, can misread the requirements and can be insecure. Never assume it's ready for production. Make a habit of reviewing the code, running tests, checking security, verifying dependencies and comparing against the documentation. The assistant supports your judgment and doesn't replace it.

Asking only for code

If you request nothing but a solution, you learn nothing from it. Ask for the reasoning too:

Generate the solution and explain:

1. Why you chose this approach.
2. Alternative approaches.
3. Potential limitations.

That turns a code generator into a learning tool, so you build knowledge as well as speed.

Giving up after one weak prompt

A poor first prompt gives a poor result, and the right move is to improve it. Here's how one request can evolve. Version 1:

Build a dashboard.

Version 2:

Build an Angular dashboard.

Version 3:

Build an Angular dashboard for monitoring application health.
Include charts, KPI cards, dark mode support, and responsive design.
Use ApexCharts.

Each pass narrows the target and improves what comes back.

A reusable template

A simple structure covers most cases:

Role:
Who should the AI act as?

Context:
What project/problem are you working on?

Task:
What exactly needs to be done?

Constraints:
What rules must be followed?

Output Format:
What should the final response look like?

Filled in for a real task, it looks like this:

Act as a Senior Angular Developer.

I am building an enterprise dashboard application.

Create a reusable KPI card component.

Use Angular 19 and TypeScript.

Follow clean coding practices.

Return code with explanations.

Prompt engineering is turning into a basic skill for software engineers, and the point is not clever tricks or elaborate formulas. It's stating requirements plainly, supplying context and iterating sensibly. The people who get the most from AI usually aren't the ones with the fanciest tools. They ask the best questions.