Takeaways: Which Prompting Technique Should I Use? An Empirical Investigation of Prompting Techniques for Software Engineering Tasks
Strategy
Decomposition
A strategy of breaking complex engineering problems into smaller, sequential subtasks. It helps models handle software architecture without losing context and logic.
"Instead of asking for the whole application to be written, ask first for the database structure, in the next step for the API, and finally for the user interface."
Strategy
Thought Generation
Forcing the model to analyze and describe the business logic before it generates the final code or bug fix. This significantly improves effectiveness on tasks that require intensive reasoning.
"Before you write the code for this algorithm in Python, describe step by step how you intend to optimize its memory complexity."
Strategy
Self-Criticism
Making the model analyze its own initially generated solution, find errors in it and propose an improved, final version before presenting it to the user.
"Write a login function. Then act as an auditor, analyze this code for security vulnerabilities, fix them and return the final, secure code."
Strategy
Ensembling (combining answers)
Having the AI generate several different approaches to solving one problem and choosing the most optimal one, e.g. in terms of performance or code cleanliness.
"Generate three completely different approaches to fixing this authorization bug, and then point out the solution that is the most optimal."
Good practice
Matching the technique to the specific task
The report indicates that for tasks requiring complex logic (e.g. bug hunting) "Thought Generation" works best, whereas for template-based tasks (e.g. code formatting, writing tests) example-based "Few-Shot" techniques give much better results.
"To generate repeatable unit tests, paste 3 examples of your coding style (Few-Shot). To look for a security vulnerability, use the prompt 'Let's analyze this file step by step'."
Good practice
Awareness of time and token costs
Always keep resources in mind. Complicated techniques such as Ensembling or Self-Criticism significantly increase token usage and waiting time for a response, so they should not be used for trivial tasks.
"To generate a simple comment documenting code, use basic Zero-Shot to save tokens, instead of applying advanced reasoning chains."
Good practice
Optimizing the linguistic features of the prompt
The authors note a strong correlation between the precision of the language used and the quality of the generated code. Specific technical vocabulary helps steer the model toward the right solution.
"Instead of writing 'Write something that fetches data from a page', use: 'Write an asynchronous Python function using aiohttp that fetches data from the given REST API endpoint'."
Avoid
Using one complicated template for everything (One-size-fits-all)
Not every prompt engineering technique works equally well on every programming task. Imposing heavy reasoning techniques on simple problems only lowers efficiency and lengthens working time.
"Forcing long 'step by step thinking' when asking to rename a variable in a single line of code is a waste of resources and computing time."
Avoid
Demanding the solution to a huge system all at once
Overly large and complex software engineering requests sent in a single prompt (without using decomposition) drastically increase the risk of "hallucinations" and of generating code that does not work.
"Build a full e-commerce system with authorization, a cart, payment integration and an admin panel in one response."
Avoid
Ignoring the context around the code
Using Zero-Shot mode (without giving examples or broader context) when editing complicated software projects leads to code that does not integrate with the rest of the related application.
"The request 'Fix the bug in user_service.py' without providing the database models, error logs and related file dependencies."
Done!
You went through 10 takeaways.
Keep reading
Evaluating AGENTS.md: Are Repository-Level Context Files Helpful for Coding Agents?Sometimes the best example is no example at all
A Systematic Survey of Prompt Engineering in Large Language Models: Techniques and ApplicationsWhat must you record about your prompt, and what is just nice to have?
Reporting LLM Prompting in Automated Software Engineering: A Guideline Based on Current Practices and Expectations



