Agentsintro5 min read

Prompt Engineering

Structuring the model's input — system, context, task, format, examples — to get reliable, high-quality outputs.

Preparing spaced-repetition scheduler…

A prompt is not just the user question. A well-shaped prompt has five named parts, and thinking in those parts makes the difference between a flaky demo and a production feature:

  1. System — persona, role, hard constraints, refusal policy, output schema. Sets the rules.
  2. Context — retrieved documents, prior turns, tool results, user data. Grounds the response.
  3. Task — the actual ask, phrased precisely with success criteria.
  4. Format — JSON shape, length, language, bullet vs prose, citation style.
  5. Examples — few-shot demonstrations of the desired behavior, especially for edge cases.

Key techniques:

  • Be explicit about format. "Return a JSON object with keys {summary, references}" beats "summarize this".
  • Show, don't tell. A two-line example of the desired output is more reliable than a paragraph of instructions.
  • Order matters. Place the most important instructions at the start or end of the prompt; the middle is weaker (lost in the middle).
  • Structured reasoning. For difficult multi-step work, provide clear success criteria and either use the model's reasoning controls or split the task into verifiable stages. A long reasoning trace is not proof of correctness.
  • Verification. Ask the model to check the result against explicit criteria, and use external tools or tests when an answer can be measured.

Limits: a prompt can supply new facts for the current context, but it does not persistently update model weights. Retrieval can supply external evidence; fine-tuning changes parameters. Evaluate the simplest approach that meets the task.

Anatomy of a prompt. Every well-shaped prompt has five named parts. Naming them turns 'prompting' into engineering.

Key takeaways

  • A prompt = system + context + task + format + examples.
  • Place key instructions at the start or end; the middle is weaker.
  • Few-shot examples beat long instructions for format-sensitive tasks.

Self-check

  1. Which part of a prompt defines persona, refusal policy, and output schema?

  2. What is the strongest way to improve reliability on a multi-step task?

References

  1. Prompt Engineering Overview — Anthropic

    Techniques for structuring prompts and tools.

  2. Function Calling Guide — OpenAI

    Tool-use protocol for GPT models.

Last verified 2026-09-04.