Key takeaways
- Prompt engineering is the practice of crafting inputs that steer LLMs toward useful, accurate, well-formatted outputs.
- It spans simple wording choices, structural techniques (few-shot examples, chain-of-thought), and system-level patterns (prompt caching, tool definitions, constrained decoding).
- The most reliable single improvement for any prompt is adding clear, concrete examples of desired output.
- Chain-of-thought prompting — asking the model to reason step by step — dramatically improves performance on math and logic tasks.
- Prompt engineering does not replace fine-tuning or RAG, but it should be tried first. Modern models respond so well to good prompts that fewer problems require training.
Why prompts matter
An LLM’s behaviour depends entirely on what you put in its context window. Change the wording, the order, or the formatting and you can get dramatically different outputs from the same model. Prompt engineering is the discipline of learning what kinds of changes help, which don’t, and how to build prompts that hold up under real-world variation.

Two years ago, bad prompting made models look incompetent. Today, models are forgiving enough that even lazy prompts produce reasonable output. But the gap between “reasonable” and “production-ready” is still large, and bridging it is usually prompt work.
The anatomy of a good prompt
A clear instruction
State what you want in direct, specific language. “Summarize this email in two sentences, focusing on the action items” beats “Can you maybe summarize this?” Vague prompts produce vague outputs.
Relevant context
Provide the inputs the model needs — the text to summarize, the code to review, the user’s question. Pastes, retrieved documents (from rag pipelines), tool outputs all go here.
Constraints on output format
“Respond in valid JSON with fields title, summary, and action_items as an array of strings.” Specifying format up front prevents post-hoc parsing pain. Modern models also support structured output modes that enforce a JSON schema.
Role or voice
“You are a senior product manager reviewing a spec” primes the model to weight certain kinds of feedback. Role prompts are not magic, but they do shift tone and priorities.
Examples
If you can show two or three examples of input-output pairs, the model will pattern-match to them far more reliably than it will follow a natural-language description. This is few-shot prompting and it is consistently the single biggest quality lever.
Prompting patterns that work
Zero-shot, one-shot, few-shot
Zero-shot means giving only the instruction and the input. One-shot adds a single example. Few-shot adds several. As a rule of thumb, the more examples of the desired output format and style you can show, the more reliably the model matches them. For narrow, consistent tasks, 3-8 examples often locks in the pattern. Beyond ~8 examples, returns diminish.
Chain of thought
For tasks requiring reasoning — math, multi-step analysis, debugging — ask the model to think step by step. Wei et al. showed that simply adding “Let’s think step by step” to a prompt dramatically improved reasoning benchmarks. Modern reasoning models (o1, Claude with extended thinking, Gemini with thinking) automate this internally, but the principle still applies to standard models.
Structured output
When you need machine-readable outputs, either use a provider’s JSON mode / tool-use interface, or explicitly specify the schema in the prompt and show a filled-in example. Prefer tool-use APIs if available — they are more reliable than hoping the model’s JSON is well-formed.
Role prompting
“You are a careful copy editor” produces different output from “You are a creative writer”. Role prompts shift the model’s implicit priorities. Do not expect them to add capability the model lacks, but they do help with tone and focus.
Prompt chaining
Break complex tasks into a sequence of simpler prompts. Generate an outline first, then write each section. Extract entities first, then categorize them. Chained prompts are easier to debug, more reliable, and often cheaper than one mega-prompt.
Self-consistency and self-check
Ask the model to generate several candidate answers and pick the best. Or generate an answer, then generate a critique of it, then generate an improved version. These techniques trade tokens for quality and can help on high-stakes tasks.
Retrieval augmentation
When the prompt needs specific facts, pull them from a knowledge base at query time and paste them into the prompt. This is retrieval-augmented generation and is covered in our rag primer.
Techniques that often fail
Begging
“Please please be very careful” rarely improves output. Modern models are already trying to be helpful; adding emotional pressure mostly clutters the prompt.
Emphasis by capitalization
“YOU MUST ALWAYS” occasionally helps but often does not. Clear, specific instructions beat shouting.
Excessive hedging
“If possible, maybe consider trying to” weakens instructions. Be direct.
Over-stuffing with instructions
A 3,000-token system prompt with 47 rules often performs worse than a focused 500-token prompt with the 5 rules that actually matter. Prune aggressively.
System-level patterns
Prompt caching
Providers like Anthropic and OpenAI support marking parts of a prompt as cacheable. On repeated calls with the same prefix, you pay a fraction of the input cost. For agents or chatbots that re-use a large system prompt, this reduces costs 70-90%.
Tool use and function calling
Modern models can call predefined tools — search, code execution, database queries — when needed. Tool definitions are themselves prompts, and writing them well is a prompt-engineering skill. Clear tool names, clear parameter descriptions, and explicit guidance about when to use each tool all matter. See our ai agents explainer for the broader agent picture.
Guardrails and output validation
Never trust a single model call in production. Validate structured outputs against a schema; re-prompt or fall back if validation fails. For safety-sensitive tasks, add a second LLM call that checks the first for policy violations.
When to stop iterating on the prompt
Prompts follow diminishing returns. The first hour of iteration might take a prompt from 50% accurate to 85%. The next five hours might push it to 90%. Beyond that, you are often better off with fine-tuning, a better retrieval pipeline, or a stronger base model. Track prompt quality on a real test set, not on impressions. See our large language models coverage for model selection guidance.
Frequently asked questions
Is prompt engineering a real job?
“Prompt engineer” as a distinct role was briefly hyped in 2023 and has largely merged back into existing roles — software engineer, ML engineer, product. The skill matters, but as one tool in a toolbox rather than a standalone career. Teams shipping production AI features all do prompt engineering, usually as part of broader engineering work.
Do I still need to prompt engineer with modern models?
Less than you did in 2023, more than you think. Frontier models (GPT-5, Claude Opus 4.7, Gemini 3) often work well on naive prompts. But hitting production reliability — 99% format compliance, consistent tone, edge-case handling — still takes careful prompt work. As models improve, the baseline rises, but the tail of hard cases remains.
What is the single most effective prompting technique?
Few-shot examples. Across tasks, providers, and model generations, showing 3-5 examples of input-output pairs is the most consistently powerful lever. Write the examples carefully — they should span the diversity of real inputs, not just cover the easy cases. If you cannot include many examples due to token budget, two good examples beat one great one plus a lot of explanation.






