Skip to content
Tech Interview Prep
Technical interview guide

Prompt Engineering & Prompt Management

Designing reliable prompts and treating them as versioned, tested production artifacts rather than one-off strings.

Minutes to read
4
Practice MCQs
25
Interview Q&A
25
Edition
v5
Editorial status
Reviewed

Scope: GPT-3 few-shot prompting, chain-of-thought, self-consistency, ReAct, PAL, PromptSource, DSPy, indirect prompt injection, HELM, Model Cards, JSON Schema 2020-12, NIST GenAI, and OWASP Prompt Injection references reviewed 2026-09-06.

Overview

Curated: · Written: · Reviewed:

Prompt Engineering & Prompt Management

In one line

A prompt is a versioned, typed template that runs on a nondeterministic model, so you design it like software: immutable versions, typed variables that fail closed, tests on held-out data, attributable rollouts and rollback. Reach for it when a prompt change must ship without a code deploy but still be traceable and reversible. If the fact or permission comes from elsewhere, the lever is retrieval, a tool, or deterministic code, not wording.

Key definitions

  • Prompt version: an immutable registry record (template bytes, variable schema, model revision it was validated against). Every log line carries its ID.
  • Typed template: messages built as a list of role-tagged objects with validated variables, never by concatenating role markers into strings.
  • Fail closed: a missing, null, oversized or delimiter-like variable raises a typed error before any model call. Never render None or "undefined".
  • Untrusted data: retrieved pages, emails, ticket bodies and tool output. Delimiters separate it from instructions but do not create a security boundary.
  • Held-out set: cases never used to tune the prompt. Only held-out results support a ship decision.
  • Behavior contract: the task, output schema, acceptable error rate and forbidden behavior written before any prompt text.

Formulas and complexity

The token budget you check before every call:

input tokens+max_tokens≤context window\text{input tokens} + \text{max\_tokens} \le \text{context window}

Self-consistency cost scales linearly with the sample count:

cost≈k×cost of one completion,k=20⇒20×\text{cost} \approx k \times \text{cost of one completion}, \quad k = 20 \Rightarrow 20\times

For a canary, a 5% arm on 200,000 requests is 10,000 requests per day. Compare arms on their own numbers, not the fleet dashboard.

How it works

The request path is a fixed pipeline. Every step that can fail names the version it used.

Pinned prompt version Validate variables, fail closed Render typed messages Model call with pinned model Validate schema and business rules Tool layer checks identity and scope Log version, model, schema IDs

The model proposes. The application validates syntax and meaning, then the tool layer enforces authorization. The log records the exact prompt version and model that produced the output, so a bad response can be traced and replayed.

When to use and when not to

SituationPrompt wordingUse something else
Output style, format, decision boundariesYes, tested on held-out data
Fact that changes (refund policy, prices)NoRetrieval or lookup tool
Exact arithmetic or totalsNoDeterministic code
Permission to act on an accountNoAuthorization in the tool executor
Secret or credentialNeverTool execution layer
Multi-step task needing a verified answerPartlyBounded tools, cross-checks

Traps interviewers probe

  1. String concatenation of untrusted text. Ticket bodies pasted into the system message can become instructions. Fix: keep roles structural and pass untrusted fields as validated user or data content.
  2. Tuning on the test set. A 94% dev score followed by 86% holdout, then a patch that reaches 97% on the same 100 cases, shows overfitting to the holdout. Fix: fix a new holdout or report the first holdout result only.
  3. Trusting a canary that is inside noise. A 0.7-point gap against a 0.3-point band can be real, but the canary arm's own numbers decide. Fix: compare the arms, check cost and latency, and gate on predeclared thresholds.
  4. Shared cache keys. Keying on the query text alone serves old prompt output and other tenants' answers. Fix: include prompt version, model version and tenant or authorization scope in the key.
  5. Majority vote over free text. Self-consistency over the whole JSON string never agrees, because the reasoning differs each time. Fix: vote only on the extracted answer field, and never use the vote as authorization.

Interview tips

Open by naming the lever: "This failure needs a deterministic lookup, so the prompt is not the fix." Then describe the registry, the validation and the rollout.

Expected follow-ups:

  • How do you test it? Frozen suites, held-out gates, critical non-regression thresholds.
  • How do you know a model upgrade broke it? Pin the model, rerun the baseline, compare held-out slices.
  • What if a user pastes "ignore previous instructions"? The tool layer rejects the action, whatever the model says.
  • Where do secrets live? In the tool execution layer, never in the prompt.

30-second answer outline:

  1. The prompt is a versioned program at a probabilistic boundary.
  2. Write the behavior contract, then choose the lever.
  3. Typed template, fail-closed rendering, structured messages.
  4. Validate outputs, enforce authorization in tools.
  5. Gate changes on held-out results, canary with predeclared stops, log the version on every request, roll back atomically.

Feedback on this overview

Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.