Prompt Engineering
Prompt engineering is the practice of carefully crafting the text instructions you give to an AI language model in order to reliably get the response you want. It matters because the same AI model can produce wildly different outputs depending on how a question is phrased — making it less like programming a computer and more like communicating skillfully with a very well-read but literally-minded colleague. The counterintuitive fact: a single extra sentence in your prompt can sometimes improve an AI's accuracy by 30% or more, with no changes to the model itself.
The "aha moment" is this: an AI language model is not a search engine you query, nor a calculator you program — it is a pattern-completing machine that you steer through language. The words you choose, the examples you include, the role you assign, and even the order you present information all shape which pattern the model completes. Prompt engineering is simply the craft of learning which steering moves work reliably, and why. Once you see prompts as a steering wheel rather than a command line, everything about how to write them changes.
How It Works
When you type a prompt into a system like ChatGPT or Claude, the model does not "understand" it the way a person would. Instead, it reads your words as a sequence of tokens — small chunks of text — and predicts, one piece at a time, what text should come next based on everything it learned during training. Your prompt is essentially the opening of a story, and the model completes it. This means every element of your prompt is a clue about which kind of completion should follow. There are several core mechanisms at play:
Context Setting is the practice of telling the model who it is and what situation it is in before asking anything. If you begin with "You are a friendly doctor explaining things to a patient," the model's completions will be drawn from a very different pool of patterns than if you begin with "You are a lawyer writing a formal brief." The role you assign acts like a costume that shapes every word that follows.
Instruction Clarity means giving the model an unambiguous task. Vague instructions like "help me with this email" activate a wide fan of possible completions. Specific instructions like "rewrite this email to be more concise, under 100 words, maintaining a professional tone" narrow the fan dramatically.
Few-Shot Examples are perhaps the most powerful basic technique. Instead of only describing what you want, you show the model two or three examples of input-output pairs before giving it the real input. The model recognizes the pattern of your examples and applies it to the new case — like showing a new employee three completed expense reports before asking them to fill out a fourth.
Chain-of-Thought Prompting asks the model to reason out loud before giving its final answer, typically by adding a phrase like "Think step by step." This works because reasoning through intermediate steps activates patterns associated with careful, accurate problem-solving rather than patterns associated with quick, confident answers that can be wrong.
Output Formatting Instructions tell the model exactly how to structure its response — "give me a numbered list," "respond in JSON," "write exactly three bullet points." Models are extremely responsive to these because formatting is one of the most strongly patterned features in training data.
Jason Wei is a researcher at Google Brain and later OpenAI who co-authored the landmark 2022 paper introducing chain-of-thought prompting — the discovery that asking a model to show its reasoning steps dramatically improves accuracy on complex problems. His work revealed that this capability emerges suddenly in very large models, being nearly absent in smaller ones, which became one of the key examples of what researchers call "emergent abilities." Surprisingly, the phrase "Let's think step by step" — one of the most studied strings in AI research — was not in the original chain-of-thought paper but was popularized in a concurrent paper by Kojima et al., leading to a friendly priority debate in the research community.
Intuition
Think of a large language model as an extraordinarily well-read library intern who has read essentially everything ever published but has no personal memory, no common sense from lived experience, and no way to ask you a follow-up question. When you hand them a note, they will do their absolute best to respond in a way that fits the pattern of notes like yours. If your note is ambiguous, they will pick the most statistically common interpretation — which may not be yours. Prompt engineering is the skill of writing that note well. Here is the most useful analogy: imagine you are directing an actor who has memorized every script ever written and can play any role perfectly — but only if you tell them clearly which role to play and what scene you are in. If you walk up and say "say something funny," they might launch into a Shakespearean comedy monologue when you wanted a one-liner. But if you say "you are a stand-up comedian doing a tight five for a corporate audience, give me three clean office jokes," they will nail it. The few-shot technique has its own analogy: it is like training a new employee not by writing a policy manual, but by showing them three completed examples of the exact kind of work you need. Humans learn by example far faster than by abstract description, and language models work almost identically in this respect. Chain-of-thought prompting is like asking someone to show their work on a math test. The act of writing down intermediate steps forces a more careful, structured process — and the same is true for AI. The model is less likely to jump to a confidently wrong answer when it must narrate the path it took to get there. Finally, think of the system prompt — the invisible instructions many AI products use before you ever type a word — as the costume, set, and director's notes given to the actor before the audience arrives. The user's message is just the first line of dialogue in an already-staged scene.
Historical Development
Origins · 1 minhow this was discovered
Why It Matters
Prerequisites
What This Leads To
See Also
Large Language Models · Retrieval-Augmented Generation · AI Agents · In-Context Learning · Chain-of-Thought Reasoning · Fine-Tuning · System Prompts