How to Approach Prompt Engineering in Interviews
Prompt engineering is the art of iterating and adjusting prompts to get optimal outputs from AI models. In interviews, you'll be assessed on how you reason about and craft prompts in real-time. This guide assumes you're the one prompting the model and using the output directly, not designing system prompts for end-users on a deployed model.
When an interviewer gives you a prompt engineering task, follow this systematic approach while thinking out loud to demonstrate your expertise.
Step 1: Identify the type of task
Before you start writing your prompt, tell your interviewer what kind of task you're dealing with. This shows you understand that different tasks require different prompting strategies.
Think out loud: "Let me first categorize this task..."
Tasks fall on a spectrum from routine to creative:
- Routine tasks: Data processing, formatting, extraction. These can be done almost algorithmically with clear, repeatable rules.
- Example: "Extract all email addresses from this document and format them as a CSV."
- Middle-ground tasks: Structured creativity with guardrails. These need guidelines but allow for creative execution.
- Example: "Write marketing copy for this product based on the spec and brand voice documentation."
- Creative tasks: Open-ended ideation and generation with minimal constraints.
- Example: "Brainstorm innovative product ideas for our target demographic."
Key insight to articulate: The more routine the task, the more detailed and prescriptive your prompt needs to be. For highly routine tasks with large datasets, consider whether you should even use the AI for execution or instead ask it to generate code to perform the task.
If asked to process a large CSV file by removing password and last name fields, capitalizing the first name column, and converting to JSON, you should say:
"This is a highly routine task with clear, repeatable rules. Given the large dataset, directly processing it through the model risks hallucinations due to context window constraints. Instead, I'd prompt the AI to write a Python script that performs these operations, then execute that script in a controlled environment. This is more reliable and repeatable."
Step 2: Design your prompt structure
Now explain the components you'll include in your prompt and why each matters. Think of prompting like delegating to an intern. You want them to have everything they need without constantly coming back with questions.
Think out loud: "I'm going to structure my prompt with the following components..."
Key components
While it feels natural to put instructions at the top, research shows that placing critical instructions at the end can improve adherence, especially for complex tasks.
Step 3: Apply prompting techniques
As you build your prompt, name the techniques you're using. This demonstrates familiarity with standard terminology.
Shot-based prompting
Refers to how many examples you include:
- Zero-shot. No examples provided. Use for simple, well-understood tasks.
- Example: "Summarize this article in three sentences." (The model understands what a summary is)
- One-shot. One example provided. Use when you want to show a specific style or format.
- Few-shot. Multiple examples (typically 2-5). Use when the model needs to generalize a pattern.
- Example: When asking for brand voice matching without documentation, provide 3-4 samples of approved copy.
Think out loud: "I'm going to use few-shot prompting here because [reason], but I'm limiting it to three examples because more might constrain the context window or cause the model to overgeneralize from superficial patterns."
Few-shot isn't always better. Context window limits, overgeneralization risks, and the possibility of the model fixating on superficial patterns mean you should be intentional about when to use examples.
Role-based prompting
Assigning a role or persona: "You are a [role]..."
Think out loud: "I'm assigning the role of [X] because the model has plenty of training data to generalize this persona's behavior..."
Role-based prompting works best when the role is well-represented in training data. "You are a software engineer" works because the model has seen countless examples. "You are a customer deciding between two products, why would you buy mine?" is problematic because the model lacks specific user research data and can only reason abstractly.
If you catch yourself using an unrealistic role, say: "Actually, this role might not be grounded in enough training data. If we really need customer perspective, we'd be better off conducting actual user research rather than relying on AI simulation."
Chain-of-thought prompting
Breaking complex tasks into multiple sequential prompts, where each step builds on the previous output.
When to use: Tasks requiring multi-step reasoning, complex analysis, or when a single prompt produces confused or incomplete outputs.
"I notice this task requires both data analysis and creative recommendations. I'll use chain-of-thought prompting:
Prompt 1: 'Analyze this dataset and identify the top three trends.'
Prompt 2: 'Based on these trends [paste output], generate five product recommendations with rationale.'"
Step 4: Assess the output
After running your prompt, evaluate the result out loud:
Think out loud: "Looking at this output, I see that..."
- Does it match the requested format?
- Is it the right length/scope?
- Does it follow all instructions?
- Are there hallucinations or unsupported claims?
- Did it handle edge cases appropriately?
- Is the tone/style appropriate?
Step 5: Iterate on the prompt
Based on your assessment, explain what you'll adjust. This demonstrates your iterative problem-solving approach.
Iteration checklist to work through:
- Be more specific: "The output was too verbose. I'll add 'Keep response under 100 words.'"
- Eliminate ambiguity: "The model chose interpretation A when I wanted B. I'll add an explicit instruction or example showing B."
- Rephrase instructions: "The model seemed confused by [phrasing]. Let me reword this more clearly."
- Break down complexity: "This task is too multi-faceted for one prompt. I'll use chain-of-thought prompting to break it into steps."
- Adjust examples: "My examples might have been too similar, causing overfitting. Let me diversify them."
- Reorder components: "Let me move the critical instruction to the end of the prompt to improve adherence."
Final tips
Throughout your prompt engineering demonstration:
- Think out loud constantly: Explain your reasoning at each decision point
- Ground your approach in the company’s context: Frame your prompt around the organization’s domain or problem space (e.g., in healthcare, what information is needed to generate a reliable diagnosis?).
- Use proper terminology: Reference shot-based, role-based, and chain-of-thought techniques by name
- Acknowledge trade-offs: Explain why you're choosing one approach over another
- Show iteration mindset: Treat the first prompt as a draft, not a final solution
- Consider alternatives: Mention when code execution might be better than direct AI processing
- Be realistic about limitations: Call out when AI might not be the right tool or when a role/task doesn't map well to model capabilities
Remember: The interviewer wants to see your thought process, not just the final prompt. Your narration of why you're making each choice is often more valuable than getting a perfect output on the first try.