Technique
Prompt engineering
Writing instructions and examples that get reliable output from a model.
Prompt engineering explained
Prompt engineering is writing the instructions, context and examples you give a language model so it produces reliable, useful output. A good prompt says clearly what the task is, gives the model the information it needs, shows the format you want, and is tested against real inputs, the same way you would test code.
What a strong prompt contains
- The task and the goal: what to do, for whom and why. "Summarise this incident report for an on-call engineer who needs the next action" beats "Summarise this".
- Context: the documents, data or facts it should use, clearly separated from the instructions, for example inside tags or a fenced block.
- Constraints: length, tone, what to do when information is missing ("say you don't know").
- Examples (few-shot): two or three input–output pairs that show the pattern, covering edge cases.
- Output format: a JSON schema, headings or a table, so code can use the result.
You are reviewing pull requests for a payments service.
Task: list security problems in the diff below. For each, give the line,
the risk and a fix. If there are none, reply exactly "No issues found".
<diff>
...
</diff>
Techniques that help
- Ask for reasoning before the answer on multi-step problems, or use a model built for reasoning.
- Split big jobs into steps (extract, then analyse, then write), each with its own prompt.
- Give it a way out: allowing "unknown" reduces made-up answers.
- Use structured output features when the result feeds into code.
Common mistakes
- Vague instructions, then blaming the model for guessing.
- Mixing instructions and untrusted input, which opens the door to prompt injection. Treat user-supplied text as data, not commands.
- Changing a prompt based on one example instead of a small test set.
What interviewers ask about prompt engineering
- "Zero-shot or few-shot?" Few-shot when the format or judgement is hard to describe in words.
- "How do you evaluate a prompt?" A fixed set of real inputs, expected outputs or a rubric, and a score you track across versions.
- "When is prompting not enough?" When the model lacks knowledge (use retrieval) or needs a consistent new behaviour (consider fine-tuning).
What should you learn before Prompt engineering?
- Deep learningMachine learning with many-layered neural networks.
- Tokens and tokenizationSplitting text into the units a language model reads and is billed by.
- TransformersThe attention-based neural network architecture behind modern language models.
- Large language models (LLMs)Transformer models trained on large amounts of text to predict the next token.
What to learn after Prompt engineering
- Context engineeringChoosing what goes into a model's context window and in what order.
- Structured outputGetting a model to return JSON or another fixed format reliably.
Practise Prompt engineering
- Generative AI Interview Questions for Freshers6 questions on Prompt engineering
- Intermediate Generative AI Interview Questions2 questions on Prompt engineering