How to Approach Prompt Engineering in Interviews
This is a shorter version of a lesson from the AI Engineering course on Aced. The full lesson goes deeper on each technique. Prompt engineering is the work of getting a language model to do a specific task reliably. Mos
This is a shorter version of a lesson from the AI Engineering course on Aced. The full lesson goes deeper on each technique.
Prompt engineering is the work of getting a language model to do a specific task reliably. Most of that work happens after the first draft, when you test the prompt against the inputs it will actually see and revise it based on what goes wrong, much like debugging code.
We use one running example throughout: a prompt that turns customer support emails into a structured ticket with a category, an urgency level and a one-line summary.
Start with what "good" looks like
Before you write anything, define the task and how you will judge the output. For the ticket example, that means listing the categories, deciding what counts as urgent, setting a length for the summary and choosing an output format, such as JSON with three fields. Then gather 10 to 20 real emails to test against, including the messy ones: a forwarded thread, an angry email with no actual question, an email written in Spanish.
Write a first prompt with the standard parts
- Role and context: who the model is acting as and what the output is used for.
- Instructions: the task stated plainly, including what to do with edge cases.
- Examples: one to three input and output pairs (few-shot examples) that show the format and the judgment calls you expect.
- Output format: an explicit schema, so the code that reads the output can parse it.
Run the loop
Run the prompt on your test set and read every output. When something fails, form a guess about why, change one part of the prompt, and run the whole set again. If you change several things at once, you can't tell which change fixed the problem or which one broke a case that used to work, so keep a short log of each change and its result.
A few failures come up often, and each has a usual fix:
- Vague results: make the instruction specific, for example "urgent means the customer can't log in or was charged twice."
- Inconsistent format: add an example, or use your model provider's structured output feature.
- Mistakes on hard cases: ask the model to reason step by step before it answers, or split the task into two smaller prompts.
- Made-up details: tell the model to say when the email doesn't contain the answer, and give it a field for that.
Know when a better prompt isn't the answer
Some problems can't be fixed with wording. If the model lacks information it needs, such as your current return policy, retrieval is the fix (see What is RAG?). If you need a very consistent style across thousands of outputs, fine-tuning may be worth it, and if cost or latency is the issue, a smaller model with a tighter prompt is often the better trade.
In an interview
If you're asked to write or improve a prompt in an interview, narrate this loop out loud: state the success criteria, write a first version, test it on a few inputs including an edge case, and explain each change you make and why. Interviewers usually learn more from how you diagnose a bad output than from your first draft.
The full lesson on Aced covers these techniques in more depth, and the rest of the AI Engineering course covers RAG, evaluation and AI prototyping.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes โ full credit and traffic to the original publisher.