FrontierAI.Engineer
AI Engineering Foundations

Prompting Fundamentals

8 min read

Core prompting patterns every AI engineer needs — system prompts, few-shot examples, chain-of-thought, and role framing.

A prompt is the complete input you hand to a language model — not just the user's message, but every instruction, example, and constraint you include. Getting prompting right is often the difference between a useful system and a frustrating one.

System prompts set the frame

The system prompt is your chance to define the model's role, tone, output format, and hard constraints before the user says anything. Keep it focused: each sentence should earn its place by ruling out a specific failure mode.

system = """
You are a support agent for Acme Cloud Storage.
Answer only questions about Acme products.
When you do not know something, say so plainly — do not guess.
Respond in plain English, no jargon.
"""

Few-shot examples

Showing the model two or three input/output pairs dramatically improves format adherence and task accuracy. Place examples in the system prompt or before the user turn. Choose examples that cover edge cases, not just the happy path.

Chain-of-thought

For tasks that require multi-step reasoning — math, logic, planning — appending 'Think step by step' or providing a scratchpad section leads the model to decompose the problem before committing to an answer. This reduces errors on hard reasoning tasks.

tip

For structured outputs, tell the model exactly what format you want before it starts: 'Return a JSON object with keys: summary, severity, affected_team.' Placing format instructions near the end of the prompt is effective.

Common failure modes

  • Vague instructions — the model fills gaps with its own defaults, which may not match yours
  • Conflicting constraints — the model will silently pick one; make instructions consistent
  • Sycophancy — the model agrees with the user even when wrong; instruct it to prioritize accuracy over agreeableness
  • Prompt injection — user input overriding system instructions; sanitize or delimit user content
warning

Never put secrets (API keys, PII) directly in a prompt. Prompts are logged and may be visible in traces, evals, and fine-tuning datasets.