Master Prompt Engineering for Coding Tasks with a Playbook
Job to be done: Learn and apply prompt engineering techniques for coding tasks
🇳🇬 Ways to use this in Nigeria
Ideas to get you started, adapt to your situation.
- Student
A computer science student at UNILAG uses prompt engineering to get more accurate Python code snippets or debugging help from Gemini for their CSC301 assignment.
- Entrepreneur
A tech entrepreneur building an MVP for their e-commerce startup uses prompt engineering to generate more functional Python backend code or React components from ChatGPT, accelerating their product development.
- 9-5 employee
A junior developer at a Lagos tech firm applies prompt engineering to generate precise SQL queries for database tasks or debug complex JavaScript errors in their project using Copilot, improving their daily workflow.
What you’ll get
A short, practical “playbook” of prompting habits that get noticeably better code out of any AI. The difference between a vague request and a well-shaped one is the difference between code you fight with and code that just works. These are the core, widely-proven techniques (inspired by vinhnx’s programmer’s prompt-engineering playbook), with ready-to-use prompt patterns.
Tools you need
- Any AI chatbot (freemium): ChatGPT, Gemini, Claude, or Copilot. Free tiers handle all of this.
Steps
-
Give context before the request: tell the AI what you are building and the constraints, not just “write a function”. Context steers everything.
I'm building a simple to-do list web app for beginners, plain HTML, CSS, and JavaScript, no frameworks. Write a function that adds a task to a list on the page and explain it. -
State your level: ask for the explanation depth you actually want, so the code matches your understanding.
I'm new to JavaScript. Write a function that adds two numbers, and explain each line so I can learn. -
Name the exact languages and tools: stop the AI guessing or using something you do not have.
Using Python 3 and the FastAPI framework, write an API endpoint that returns a list of users as JSON. -
Show an example of what you want: a tiny sample of the input and the desired output beats a long description.
Write a function that turns a date like "2026-06-24" into "24 June 2026". Example: format_date("2026-01-05") should return "5 January 2026". -
Always ask for an explanation and how to test it: this catches mistakes and teaches you at the same time.
Write a function that checks if a password is at least 8 characters and has a number. Explain how it works, and show me how to test it with a few example passwords. -
Iterate with the error, not “it broke”: when something fails, paste the exact error and the relevant code.
I got this error running the function: [paste the full error]. Here is the code: [paste it]. What is wrong and how do I fix it?
Original source
Inspired by “Prompt engineering playbook for programmers” by vinhnx, shared on Hacker News, on writing structured prompts that get better results for coding tasks. The techniques above are the common, proven principles; see the original playbook for the author’s full version.
Notes & variations
- Any model works: these habits transfer across ChatGPT, Gemini, Claude, and Copilot. Their free tiers are fine for practicing.
- Common pitfall: trusting AI code without reading it. Always review and test what it gives you; treat it as a strong draft.
- Tip for better results: stack the techniques, context plus exact language plus an example plus “explain and test it” in one prompt gets the best first answer.