What is Prompt Engineering? Techniques and Examples
A plain definition of prompt engineering, six techniques with before-and-after prompts, five worked examples, common mistakes, and how context engineering changes the picture for AI agents.
What is Prompt Engineering?
Prompt engineering is the process of designing, testing and refining the inputs you give a generative AI model so it produces the output you want. It works in plain language. You state the task, add the context the model cannot guess, say what format you need, show an example if the style matters, and then adjust based on what comes back.
The model itself does not change. Only your input does. That is why anyone who can write clearly can get started, and why a vague prompt gets a vague answer.
Strong prompt engineering requires you to provide a detailed context of your desired output and refine your prompts meticulously to achieve your specific and useful result.

The graphic above compares a weak prompt and a strong one for the same job, a 30-day social media calendar for a finance firm. The strong prompt names the business, the audience, the platform, the content mix and the table columns, and asks the model to act as an experienced social media expert. The weak prompt leaves all of that to chance.
What is a prompt?
A prompt is whatever you give an AI model to respond to: a question, an instruction, a few examples, a pasted document, or all of these together. In a chatbot such as ChatGPT, Claude or Gemini it is usually text. Image tools take a text description, and many tools also accept files and screenshots.
Most useful prompts combine a few parts:
- Task: what the model should do, such as summarise, compare or rewrite.
- Context: who the output is for and what the model needs to know.
- Format: the shape of the answer, such as a table, five bullets or 120 words.
- Constraints: tone, length, things to avoid, and what to do if the model is unsure.
- Examples (optional): one to three samples of what good looks like.
You rarely need all five. Treat them as a checklist when an answer comes back wrong.
Prompt Engineering & Generative AI
You do prompt engineering every time you tell a generative AI tool what to produce: ChatGPT rewriting an ATS-friendly resume, Claude summarising a report, Gemini drafting a content calendar, or an image generator such as Midjourney turning a description into a picture. The tools differ. The skill is the same: say what you want clearly enough that the model does not have to guess.
AI engineers use the same skill at a larger scale. They write and test the system prompts that sit inside products built on large language models (LLMs). For the background on how these models work, read our explainer on what a large language model is.
A small example shows why this matters. A clothing brand asks a chatbot for "a few short meme ideas for a clothing brand". The answer is generic, so the user follows up with "make it funnier", then "make it about organic clothing", then "keep each under 15 words". Three follow-ups later the output is usable. Prompt engineering puts the brand, tone, topic and length into the first prompt, so you get there in one step.
What exactly does a prompt engineer do?
A prompt engineer acts as the bridge between human intent and machine execution. Rather than writing code from scratch for every task, prompt engineers craft precise instructions, system prompts, context parameters, and guardrails to guide AI model output.
Key responsibilities include:
- Designing System Prompts: Establishing tone, constraints, persona, and output formats (e.g., JSON, tables, markdown) for AI applications.
- Testing & Evaluation: Running systematic evaluations across edge cases to minimize AI hallucinations and inaccurate responses.
- Workflow Automation: Chaining multiple prompts together or integrating LLMs with APIs and databases (such as Retrieval-Augmented Generation or RAG systems).
- Safety & Security: Testing models against prompt injection attacks, data leaks, and malicious bypasses.
What is a prompt engineer's salary?
There is no single figure worth quoting. "Prompt engineer" is now an uncommon standalone job title. Many employers list prompting as one skill inside broader roles, such as AI engineer, data analyst, product manager or marketer, and pay follows the role and the skills around it, such as Python, retrieval and evaluation. Our guide to prompt engineering jobs and salary in India lists the roles that hire for this skill and realistic pay bands for each.
What are the three types of prompt engineering?
Strictly speaking, prompt engineering has techniques rather than official "types", but three appear in almost every guide and are the ones to learn first:
- Zero-shot prompting: you give a direct instruction with no examples. It works well for common, clearly defined tasks such as summarising, translating or rewriting.
- Few-shot prompting: you include a few worked examples so the model copies the pattern. The idea became widely known through the 2020 paper Language Models are Few-Shot Learners by Brown et al.
- Chain-of-thought (CoT) prompting: you ask the model to work through intermediate steps before the final answer, which helps on multi-step maths, logic and planning. It was described in the 2022 paper Chain-of-Thought Prompting Elicits Reasoning in Large Language Models by Wei et al.
Prompt engineering techniques with before-and-after examples
Beyond those three, these are the techniques you will use most. Each row shows a weak prompt and a better version of the same request.
| Technique | What it does and when to use it | Before and after |
|---|---|---|
| Zero-shot with clear constraints | One direct instruction with the audience, length and priority stated. Use it for common tasks and as the first attempt at anything. | Before: Summarise this report. After: Summarise the report below for a CFO in 3 bullets, under 60 words. Start with the biggest financial risk. |
| Few-shot | Shows the pattern with a few examples so labels, tone or format stay consistent. Anthropic's prompting guide suggests 3 to 5 examples that are relevant and varied. | Before: Label this support ticket: "Refund not received after 10 days." After: Label each ticket as Billing, Delivery or Account. "Charged twice for one order" = Billing. "Parcel stuck in Pune for a week" = Delivery. "Cannot reset my password" = Account. Now label: "Refund not received after 10 days." |
| Chain-of-thought | Asks the model to work through the steps before it answers. Use it for maths, logic and planning, and when you want to check the working. | Before: A Rs 2,000 jacket gets 15% off, then 10% off the reduced price. What does it cost? After: The same question, plus: Work it out step by step, show the price after each discount, then give the final price on its own line. (The steps are 2,000 × 0.85 = 1,700, then 1,700 × 0.90 = 1,530.) |
| Role prompting | Sets a persona so tone and depth match the reader. Anthropic's guide says even one sentence of role in the system prompt makes a difference. | Before: Review my resume. After: You are a hiring manager at a Bengaluru product startup screening freshers for a backend role. Review the resume below. List its 3 weakest bullet points and rewrite each with a measurable result. |
| Prompt chaining | Splits a task into stages and feeds each output into the next. Use it when you want to inspect intermediate results. A common pattern is draft, review against criteria, then refine. | Before: Read these 200 customer reviews and write the final report. After: Step 1: List the features, praise and complaints in each review. Step 2: Group those points into themes and count how often each appears. Step 3: Write a 100-word summary using only those themes. |
| Delimiters and output format | Wraps pasted text in tags so the model can tell your instructions from the material, and states the format you want back. Anthropic and OpenAI both recommend delimiters such as XML tags. | Before: Summarise this email thread: (pasted text) After: Summarise the thread inside the tags in 3 bullets, then list action items as Owner: task (due date). <email_thread>(pasted emails)</email_thread> |
Which one first? Start with a clear zero-shot prompt. If the format or tone is wrong, add examples. If the logic is wrong, ask for steps or split the task into stages. Developers also use self-consistency (sampling several reasoning paths and keeping the most common answer) and tree-of-thought (exploring several paths and backtracking), but most everyday work never needs them.
Do you still need to say "think step by step"?
Often, no. Newer reasoning models work through a problem internally before they answer. OpenAI's guidance for its reasoning models says to avoid chain-of-thought prompts, because the model already reasons on its own and the extra instruction may not help and can sometimes hurt. Anthropic's prompting guide likewise says Claude handles most multi-step reasoning internally, and keeps explicit prompt chaining for cases where you need to inspect intermediate outputs or enforce a fixed pipeline.
A practical rule: with a reasoning model, state the goal and the constraints and let it think. With an older or simpler model, asking for steps is still a cheap way to improve maths and logic answers.
Practical Prompt Engineering Examples
Each example below shows a basic prompt, an engineered version and what changed. Copy the pattern, not the exact words, and swap in your own details.
1. Text Generation (ChatGPT / Claude)
- Basic Prompt (Poor): "Write an email to a client about project delay."
- Engineered Prompt (Optimal): "Act as a Senior Project Manager at an IT agency. Write a polite, professional 150-word email to an enterprise client informing them that Phase 2 deployment is delayed by 3 business days due to security testing. Offer two alternative milestone review dates next week and keep the tone transparent and reassuring."
- What changed: a role, a length, the reason for the delay, a concrete next step and a tone.
2. Image Generation (Midjourney and similar tools)
- Basic Prompt (Poor): "A city at night."
- Engineered Prompt (Optimal): "Wide cinematic shot of a rainy Tokyo street at night, neon signs reflected on wet asphalt, light fog, 35mm lens, moody blue and magenta colour grade --ar 16:9"
- What changed: the subject, setting, lighting, camera and colour are all named, so the tool has far less to invent.
3. Studying a new topic
- Basic Prompt (Poor): "Explain recursion."
- Engineered Prompt (Optimal): "I am a second-year BCA student who knows basic Python loops. Explain recursion in under 200 words using one everyday analogy, then show a 6-line Python example that prints a countdown. End with two practice questions and do not give the answers."
- What changed: the model knows your level, the length, the format and what to leave out.
4. Job search and resumes
- Basic Prompt (Poor): "Improve my resume."
- Engineered Prompt (Optimal): "You are a recruiter hiring freshers for a data analyst role at a Bengaluru fintech. Below are my resume and the job description. List the three skills in the job description that my resume does not show, then rewrite my two weakest bullet points to include a number or a result. Do not invent experience I have not mentioned."
- What changed: a target role, a comparison task, a concrete output and a guardrail against made-up claims.
5. Coding and debugging
- Basic Prompt (Poor): "Fix my code."
- Engineered Prompt (Optimal): "This Python function should return the second-largest number in a list, but it returns the largest. Here is the code and the output for the input 1, 5, 3. Explain the bug in two sentences, then give the corrected function and one test that would have caught the bug."
- What changed: the expected behaviour, the actual behaviour, the evidence and the shape of the answer are all stated.
How to generate smart prompts?
Anyone who can explain a task clearly can write a good prompt. These four habits do most of the work.
1. Be as expressive as possible
A model knows only what you put in the prompt. Think of it as a new intern: capable, but with no idea about your audience, your brand or what "good" means for this task. Anthropic's prompting guide suggests a simple check: show your prompt to a colleague who knows nothing about the task. If they would be confused, the model probably will be too.
Be specific, add the relevant context and skip the fluff. Here is one prompt improving in three steps:
- Vague: "Create a blog headline about data science."
- Better: "Create a blog headline under 60 characters about data science for IT professionals in India."
- Best: "Create 5 blog headline options under 60 characters about data science. The audience is IT professionals in India who are thinking of a career switch. Make each option a different style: a question, a number, a how-to, a bold claim and a plain statement."
2. Keep experimenting
The first prompt is a draft. Run it, read the output critically, then change one thing at a time: the audience, the format, the order of the instructions or the examples. If you change several things at once you cannot tell which change helped.
If you plan to reuse a prompt, test it properly. Databricks describes a simple routine: set a baseline, decide how you will judge the output, compare prompt variants side by side and test edge cases. A handful of saved test inputs is enough to start. Re-test whenever you switch models, because a prompt that works on one model can behave differently on another.
3. Follow up with clear information
Once the core prompt works, use follow-ups to shape the result: cap it at 120 words, turn it into a table, ask for two versions, or change the tone. Say what to keep. "Keep the structure and make it shorter" is clearer than "improve this".
4. Play around with different prompting techniques
If the format is wrong, add examples. If the reasoning is wrong, ask for steps or split the task into stages. If the tone is wrong, set a role or paste a sample of the voice you want. The techniques table above shows a before-and-after prompt for each.
Common prompt engineering mistakes
| Mistake | What goes wrong | Fix |
|---|---|---|
| A vague request, such as "Write about marketing" | The model fills the gaps with generic averages. | State the task, audience, format and length. |
| A rule with no reason | The model cannot tell what the rule is protecting. | Say why. Anthropic's guide contrasts "never use ellipses" with explaining that the text will be read aloud by a speech engine that cannot pronounce them. |
| Adjectives instead of examples | Words like "professional" or "fun" mean different things to different readers. | Paste one or two samples of the tone you mean. |
| One giant prompt for a multi-stage task | You cannot see which step went wrong. | Split it into stages and check each output. |
| Forcing "think step by step" on a reasoning model | OpenAI's guidance says it may not help and can sometimes hurt. | State the goal and constraints, and let the model reason. |
| Never testing the prompt | A prompt that worked once can fail on the next input or the next model. | Save a few test inputs and re-run them after every change. |
| Trusting every fact in the answer | Models can state wrong things fluently. | Check names, numbers and quotes against a source. |
Prompt engineering vs context engineering
If you read about AI agents in 2026 you will meet a second term: context engineering. Anthropic's engineering team describes it as the set of strategies for choosing which information goes into the model's context at each step, and calls it the natural progression of prompt engineering. Wikipedia defines it as the related area of software engineering that manages everything supplied to the model besides the prompt itself, such as system instructions, metadata, tools and tokens.
Prompt engineering is still part of the picture. It covers how an instruction is worded and organised. Context engineering widens the question to: what should the model see right now, and what should be left out?
| Compared on | Prompt engineering | Context engineering |
|---|---|---|
| What you design | The wording and structure of an instruction | Everything the model sees: system prompt, tools, retrieved documents, memory and conversation history |
| The question you ask | How should I phrase this request? | What should be in the context right now, and what should be left out? |
| Where it matters most | Single tasks, chats and reusable prompt templates | Agents and apps that run many steps and carry state |
| Example | Adding the audience and output format to a resume-review prompt | Letting a support agent fetch a customer's last three tickets instead of pasting the whole history |
How to prompt an AI agent
An agent runs for many steps, calls tools and builds up a long history, so one well-worded prompt is not enough. Anthropic's engineering guidance on agents suggests:
- Write the system prompt at the "right altitude": specific enough to guide behaviour, loose enough that you are not hard-coding brittle if-then rules.
- Prefer a few varied, typical examples over a long list of edge-case rules.
- Give each tool a clear job that does not overlap with another tool, so a person could tell which one to use.
- Load information just in time. Keep light references such as file paths or links, and fetch the data when the agent needs it.
- For long tasks, summarise the history so far, or hand sub-tasks to sub-agents that report back with short summaries.
For a plain-English explainer of how such agents work, see our guide to what a Claude AI agent is.
How to Start a Career in Prompt Engineering
You do not need a computer science degree to write effective prompts, but technical skills widen your options. Prompting is now usually listed as a skill inside broader roles, so the strongest profile pairs good prompting with something you can build or measure. If you are not from a tech background, our guide to AI courses for non-tech students compares the options.
- Master natural language and communication: practise stating the task, context, constraints and format in plain text. Clear writing is the core skill.
- Learn the key concepts: system instructions, temperature, top-p, context windows and token limits.
- Pick up Python and API basics: basic Python lets you call model APIs, automate prompts, build retrieval (RAG) pipelines and run systematic evaluations. A structured option is an online AI and ML certification from E&ICT Academy, IIT Roorkee that covers Python, GenAI and LLMs.
- Test the same prompt on several models: run it in ChatGPT, Claude and Gemini to see how they differ in tone, instruction-following and mistakes, and keep notes. Our practical guide to the best AI tools for 2026 shows how the main tools compare.
- Build something small and show your working: a resume reviewer or a study-notes generator, with the prompt, ten test cases and a note on what failed. If you do not code, the AI Residency from Leap by Masai is a residency for building a working AI product for your own work, with no coding needed.
Frequently asked questions
What is prompt engineering in simple words?
It is the skill of writing clear instructions for an AI model so it gives you the answer you actually want. You say what the task is, give the background, set the format, and refine the prompt until the output is reliable.
What are the main prompt engineering techniques?
The core ones are zero-shot prompting (no examples), few-shot prompting (a few examples), chain-of-thought prompting (step-by-step reasoning), role prompting (a persona) and prompt chaining (splitting a task into stages). The table above shows a before-and-after prompt for each.
Is prompt engineering the same as context engineering?
No. Prompt engineering is about how you word and structure an instruction. Context engineering decides everything the model sees, including system instructions, tools, retrieved documents and conversation history. It matters most for AI agents, and prompt engineering is one layer inside it.
Do I need to code to learn prompt engineering?
Not to start. You can learn the core techniques in any chatbot using plain language. Coding, usually Python, becomes useful when you want to call model APIs, automate prompts, build retrieval systems or run evaluations at scale.
Should I still tell the AI to think step by step?
With newer reasoning models, usually not. OpenAI's guidance says these models reason internally and that step-by-step instructions may not help and can sometimes hurt. With older or simpler models, asking for steps can still improve maths and logic answers.
Is prompt engineering still a good career?
As a standalone job title it is now uncommon. As a skill it is useful in many roles, from AI engineering to marketing and analysis. The strongest route is to pair prompting with something you can build or measure, such as Python, retrieval systems or evaluation.