What Is Prompt Engineering?
Prompt engineering is the practice of structuring instructions to get reliable, accurate output from an LLM. Core techniques and common pitfalls.
Prompt engineering is the practice of designing and structuring the input given to a large language model to reliably get the output you want. It sits somewhere between writing and debugging: the same underlying model can produce a vague, hedging answer or a precise, well-formatted one depending entirely on how the request is framed, what context it’s given, and what constraints it’s told to follow.
Why the same model gives different answers
An LLM generates text by predicting the most probable next token given everything that came before it, including the prompt. That means the prompt isn’t just a question — it’s the entire context the model conditions its output on. Vague prompts leave more of that context to be inferred, and the model fills gaps with its statistically average response, which is often generic. A precise prompt narrows the space of plausible continuations toward the answer you actually need.
This is also why prompt engineering doesn’t require retraining anything. Unlike fine-tuning, which adjusts a model’s weights on new examples, prompt engineering works entirely within a single request — it’s a way of steering a fixed, frozen model, not changing it.
Core techniques
Be specific about format and scope. “Summarize this” invites the model to guess how long, how formal, and for whom. “Summarize this in three bullet points for a non-technical reader” removes three separate ambiguities in one sentence.
Provide examples (few-shot prompting). Showing the model one or two examples of the input-output pattern you want is often more effective than describing the pattern in words. See zero-shot vs few-shot prompting for when each approach is worth the extra prompt length.
Ask for reasoning before the answer. Prompting a model to work through a problem step by step before giving its final answer — chain-of-thought prompting — measurably improves accuracy on multi-step reasoning and arithmetic tasks, because the model’s own intermediate reasoning becomes part of the context it conditions the final answer on.
Separate instructions from data. When a prompt mixes an instruction with content to act on — an email to summarize, code to review — clearly delimiting where the instruction ends and the data begins (with a heading, XML-style tags, or a fenced block) reduces the model conflating the two.
Set the persona and constraints up front. Telling the model what role to adopt and what it must not do — “act as X, do not do Y” — narrows the output distribution before generation starts, which is generally more reliable than fixing an off-target response after the fact.
System prompts vs user prompts
Most production LLM applications separate the prompt into two layers: a system prompt set by the application developer that defines the model’s role, tone, and hard constraints, and a user prompt containing the specific request. The system prompt is typically stable across a whole session or product, while the user prompt varies with every interaction. Getting the split right matters — instructions that belong in the system prompt but leak into user-editable text become inconsistent, and instructions that belong in the user prompt but get hardcoded into the system prompt make the assistant rigid.
Where prompt engineering runs into limits
Prompt engineering can’t fix everything. A model that doesn’t have the underlying knowledge to answer a question correctly will confidently produce a wrong answer no matter how the prompt is phrased — a failure mode covered in more detail in why LLMs hallucinate. When the task genuinely depends on facts outside the model’s training data or a private knowledge base, retrieval-augmented generation is the more reliable fix: it feeds the model actual source documents to work from, rather than relying on prompting alone to summon facts it doesn’t have.
Prompting also can’t reliably prevent a model from being manipulated by instructions embedded in the content it’s processing — see what prompt injection is for why that requires guardrails at the system level, not just careful wording.
Prompt length, cost, and iteration
Longer, more detailed prompts generally produce more reliable output, but every token in the prompt costs money and adds latency — see how LLM sampling and prompt caching affect cost for the economics. Our free LLM token cost calculator is a quick way to estimate the cost impact of a longer, more detailed system prompt across a high request volume before committing to it in production.
In practice, prompt engineering is iterative: write a prompt, test it against a representative set of inputs, look at where it fails, and tighten the instructions or add an example that addresses the specific failure. Teams running this loop at scale typically formalize it with an LLM eval suite, so a prompt change that improves one case doesn’t silently regress another.
The takeaway
Prompt engineering is the craft of shaping an LLM’s input so its output is specific, correctly formatted, and grounded rather than generic. The reliable techniques — specificity, few-shot examples, reasoning-first prompting, clear separation of instructions from data — all work by narrowing the space of plausible completions before generation starts. It’s a powerful, cheap lever, but it can’t substitute for retrieval when the model lacks the underlying facts, and it isn’t a security boundary against adversarial input.
Tagged
Keep reading
Chisato · · 5 min read What Is Catastrophic Forgetting in AI Fine-Tuning?
Catastrophic forgetting is when training a model on new data erases skills it already had. Why it happens during fine-tuning, and how teams work around it.
Chisato · · 4 min read What Is DPO? Direct Preference Optimization Explained
DPO tunes a language model on human preference data directly, without training a separate reward model or running reinforcement learning.
Chisato · · 4 min read What Is Constitutional AI? Training Models on Principles
Constitutional AI trains language models to critique and revise their own outputs against a written set of principles, reducing reliance on human labels.