Apply prompt engineering techniques (zero-shot, few-shot, chain-of-thought)
Choose and combine zero-shot, few-shot and chain-of-thought prompting, plus structure and long-context techniques, according to the task's difficulty, format needs and latency budget.
Key points
- 1
Zero-shot is the cheapest and fastest: clear, direct instructions with no examples. It is the right default for simple tasks and latency-bound features, and it is where you start before adding anything else.
- 2
Few-shot (multishot) examples are the most reliable way to steer format, tone, naming conventions and consistency. Use about three to five that are relevant to the real inputs, diverse across classes and edge cases, and wrapped in
<example>tags inside<examples>. - 3
Examples steer towards whatever they show: a skewed set (one source, one label) biases outputs. Adding more of the same makes it worse; removing them and writing 'be unbiased' loses the format guidance.
- 4
Chain-of-thought helps when the task needs multi-step reasoning: interacting conditions, policy application, analysis across documents. It costs latency and output tokens, so remove it from simple, latency-bound tasks and confirm the benefit with an A/B measurement.
- 5
Reasoning must come before the answer to help; asking for the answer first and a justification after does not improve accuracy. Separate reasoning and answer with tags such as
<reasoning>and<answer>so code can extract the decision. - 6
On current models the built-in mechanism is adaptive thinking with
effortcontrolling depth; explicit 'think step by step' prompting is the fallback when thinking is off. Few-shot examples can include<thinking>sections to show the reasoning pattern. - 7
Long-context prompting: put longform documents at the top and the query and instructions at the end; wrap each document in
<document>tags with<source>and other metadata; ask the model to extract relevant quotes before answering so it grounds the response and ignores the rest. - 8
XML tags reduce misinterpretation whenever a prompt mixes instructions, context, examples and variable inputs; use consistent tag names and refer to them in the instructions.
- 9
Give Claude a role in the system prompt to focus behaviour and tone; a single sentence is enough to matter.
- 10
Prefill of the last assistant turn is no longer supported. For JSON or schema-bound output use structured outputs or a strict tool schema; for skipping preamble use a direct instruction or output tags; examples and instructions shape content but do not guarantee structure.
- 11
Prompt chaining (sequential calls) is still worth it when you need to inspect intermediate outputs or enforce a pipeline; otherwise adaptive thinking handles most multi-step reasoning inside one call.
- 12
Current models follow instructions literally, so remove aggressive language written for older models and state what you want rather than shouting it. Measure every prompting change against an eval rather than trusting intuition.
Read the source
Test yourself on Apply prompt engineering techniques (zero-shot, few-shot, chain-of-thought)
Ten questions, with the answer and explanation after each one.