Prompt Engineering

The most direct way to control a foundation model’s output.

What it is

Prompt engineering is designing the input to a foundation model to get the output you want. It’s the most direct lever over model behavior — no retraining required.

Anatomy of a good prompt

ComponentPurpose
RoleWho the model should act as
TaskWhat to do
ContextBackground information needed
ConstraintsLimits and conditions
Response formatOutput structure
Response styleTone and voice
Success criteriaWhat “good” looks like
ExamplesSample inputs/outputs when helpful

Weak: “Summarize this document.”

Strong: “You are a document analyst. Summarize the content below in at most five key points. Each point is no more than two sentences. Use only information present in the document and do not add facts.”

Which technique when

SituationReach for
The task is common and well-understoodZero-shot — just ask; modern models usually get it
Output format or style keeps driftingFew-shot — 2–5 examples teach the pattern faster than a paragraph of rules
Multi-step logic goes wrongChain-of-thought — ask it to reason step by step (or use a reasoning model)
The task is too big for one promptPrompt chaining — split into sequential prompts and validate between steps
The same prompt shape runs on many inputsPrompt template — one structure, input variables
Every call repeats a long prefixPrompt caching — a cost lever; see Cost & tokens

The pattern behind the table: examples beat instructions for form; reasoning beats both for logic; and decomposition beats bigger prompts.

Strengths & limitations

  • Strengths — the cheapest, fastest lever; no infrastructure; you iterate instantly.
  • Limitations — can’t add knowledge the model lacks (use RAG); sensitive to wording; hits a ceiling on hard or consistency-critical tasks (then consider fine-tuning).

Sources