StackLift
All terms

Glossary

Prompt engineering

Writing and testing the instructions, examples and context you give a model to get reliable output.

Prompt engineering is the practice of designing the instructions, examples, context and output format you give a language model so it produces reliable results for a task. In production it means writing prompts, testing them against real cases and versioning changes like code.

Good prompts state the task, the audience, the constraints and the format, and include a few examples when behavior is hard to describe. Structured output, such as JSON that matches a schema, makes results easier to check and use.

The broader skill is often called context engineering: deciding what the model sees, including retrieved documents, tool results and conversation history. Prompts need an evaluation set, because a change that fixes one case can break another.

Start in 60 seconds

Put this to work on your project.

Get an AI-assisted, architect-reviewed scope, cost range, and timeline. Free, no login.

The complete guide

Prompt engineering: the complete guide

Updated November 18, 2026 ยท Published by , Founder, StackLift AI. Written with AI assistance; how we make content.

Short answer

Prompt engineering is designing the instructions, examples, context and output format you give a language model so it produces reliable results for a task. In production it also means testing prompts against real cases and versioning changes like code. Good prompts are specific, structured and checked, not clever wording.

What is prompt engineering?

A prompt is everything you send to a model: the instructions, any examples, the data it should work on and the format you want back. Prompt engineering is the work of designing and improving that input so the model does the task correctly and consistently.

In a demo, one good answer is enough. In a product, the prompt has to work across thousands of different inputs, including odd ones. That turns prompt writing into an engineering practice: you define what good looks like, write the prompt, test it against a set of real cases, and change it only when the tests show an improvement.

The phrase has a reputation for tricks and magic words. In practice, the biggest gains come from clarity: saying exactly what you want, giving the model the information it needs, and checking the result.

Why does prompt engineering matter for a business?

The same model can produce a useless answer or a dependable one depending on how it is asked. Prompts are often the cheapest and fastest lever to improve an AI feature, because they need no training and can change within hours.

  • Quality: clear prompts reduce vague, off-topic or wrong answers.
  • Consistency: structured prompts and output formats give results other software can use.
  • Cost: tighter prompts use fewer tokens, and stable prefixes qualify for prompt caching.
  • Safety: instructions and limits shape behavior, though they are not a substitute for access controls. See prompt injection.
  • Speed to value: you can improve a feature without waiting for a training cycle.

What makes a good prompt?

Good prompts share a small set of parts. You do not need every part every time, but missing parts are the usual reason for poor results.

Parts of a well-built prompt
PartWhat it doesExample
Role and taskSays what the model is doing and for whomYou summarize support tickets for the billing team.
ContextGives the facts the model needsThe customer's plan, the policy text, the ticket history
ConstraintsSets limits and rulesUse only the policy text; if unsure, say so
ExamplesShows the pattern when words are not enoughTwo sample tickets and the summaries you want
Output formatDefines the shape of the answerJSON with fields category, urgency and summary
InputThe actual item to process, clearly separatedThe ticket text inside delimiters

Write it as you would brief a capable new colleague who knows nothing about your business: state the goal, give the background, say what good looks like and what to do when unsure.

What are the common prompting techniques?

Techniques and when to use them
TechniqueWhat it isUse when
Zero-shotInstructions only, no examplesThe task is common and clear
Few-shotAdds a few worked examplesThe format or judgment is hard to describe
Step-by-step reasoningAsks the model to work through the problem before answeringThe task needs multiple steps of logic
Structured outputRequires JSON or another fixed schemaAnother system will read the answer
Role or personaSets perspective and toneVoice and level of detail matter
Prompt chainingSplits a task into several calls, each with its own promptOne prompt does too much and quality suffers
RetrievalAdds relevant documents to the prompt; see RAGThe model needs facts it was not trained on
Self-checkAsks the model, or a second call, to review the answer against rulesMistakes are costly

Newer reasoning models often do their own step-by-step thinking, so older tricks such as telling the model to think step by step matter less. Check what the model you use already does before adding steps.

How do you develop a production prompt?

  1. Define the task and what a correct answer looks like, in writing.
  2. Collect real examples, including edge cases, and record the expected result for each.
  3. Write a first prompt that is clear and complete, and run it on the examples.
  4. Read the failures. Find the pattern: missing context, unclear rule, wrong format or a hard case.
  5. Change one thing at a time, and rerun the full set to see whether the score moves.
  6. Add structure: delimiters, a schema for output and validation in code.
  7. Test on new examples the prompt has not seen, to avoid fitting only to your test set.
  8. Version the prompt, record what changed and why, and deploy it like any other release.
  9. Monitor live results and feed new failures back into the test set.

The evaluation set is the heart of the practice. Without it, every edit is a guess and a fix for one case can quietly break another.

What is context engineering, and how does it relate?

Context engineering is the broader job of deciding everything the model sees: the instructions, retrieved documents, tool results, memory of earlier turns and the conversation so far. The prompt text is one part. For agents and assistants, what goes into the context window usually matters more than the wording of the instructions.

  • Retrieve only what is relevant; extra text distracts the model and costs tokens.
  • Put the most important instructions where the model will weigh them, usually at the start and again near the end of a long prompt.
  • Summarize or trim long histories at planned points.
  • Describe tools clearly, since the model chooses them from their descriptions. See tool calling.
  • Decide what the system remembers between sessions. See agent memory.

Prompt engineering vs. fine-tuning vs. RAG

These are three ways to adapt a model to your task. Start with the cheapest, and move on only when you can show it falls short.

Ways to adapt a model
ApproachWhat changesBest forEffort
Prompt engineeringThe input you sendBehavior, format, tone, simple rulesLow; changes in hours
RAGThe facts you supply at request timeAnswers from your own, changing documentsMedium; needs retrieval design
Fine-tuningThe model itselfConsistent style or narrow tasks at scaleHigher; needs data and evaluation

See the comparisons of prompt engineering vs. fine-tuning and RAG vs. fine-tuning for how to choose.

What are examples of prompt engineering in business use?

  • Support triage: a prompt reads a ticket and returns a category, urgency and one-line summary as JSON.
  • Contract review: a prompt compares clauses with a checklist and flags differences for a lawyer.
  • Sales research: a prompt turns public company information into a short brief in a fixed format.
  • Document extraction: a prompt pulls invoice fields into a schema, with a rule to return null when a field is absent.
  • Internal helpdesk: a prompt answers from retrieved policy text and says when the answer is not in the sources.
  • Content drafts: a prompt applies a style guide and requires a human editor before publishing.

Each of these benefits from a test set of real inputs and a person reviewing risky outputs. See AI agents for systems that chain such prompts with tools.

Common prompt engineering mistakes

  • Vague instructions such as make it better, instead of saying what better means.
  • No test set, so changes are judged on the one example you remember.
  • Overlong prompts that bury the key rule. Shorter and clearer often wins.
  • Asking for facts the model does not have, which invites hallucination. Supply the source or allow it to say it does not know.
  • Changing many things at once, so you cannot tell what helped.
  • Not setting temperature and other settings deliberately for the task.
  • Putting secrets or sensitive rules in the prompt.
  • Leaving prompts unversioned in a chat tool, where nobody can reproduce a past result.
  • Treating prompts as the only safeguard instead of adding validation in code.

How do you measure prompt quality?

Measure against your own cases. Public leaderboards test general ability, not your task.

  • Correctness against expected answers on a fixed test set.
  • Format validity: how often the output parses and matches the schema.
  • Refusal and fallback behavior: does it say it does not know when it should?
  • Consistency: does the same input give acceptable answers on repeated runs?
  • Latency and token cost per request.
  • Human review scores for qualities that code cannot check, such as tone.
  • Live signals: user corrections, escalations and thumbs-down feedback.

The AI agent evaluation checklist describes how to set this up, and agent evaluation covers multi-step systems.

What does an improved prompt look like?

A weak prompt for ticket triage might read: summarize this ticket. It leaves open the length, the audience, what to do with missing details and how the answer will be used. The result varies from run to run, and another program cannot read it.

A stronger version states the role (you triage tickets for the billing team), the rules (use only the ticket text; if the plan type is missing, set it to unknown), two short examples and the exact output: JSON with category, urgency and a summary of one sentence. The input is placed last inside clear delimiters.

The stronger prompt is longer, but each line removes a guess. Code can then validate the JSON, route the ticket and count how often each category appears. That is the difference prompt engineering makes in practice: output that other systems can rely on.

What does prompt engineering mean for cost and timeline?

Writing the first prompt is quick. The effort sits in building the evaluation set, iterating, handling edge cases and keeping quality steady as models and inputs change. Running cost depends on prompt length, the model you choose and request volume.

  • How varied and messy the inputs are.
  • The accuracy needed and the cost of an error.
  • How many separate prompts and steps the feature has.
  • The size of the evaluation set and who labels it.
  • Ongoing monitoring and updates when models change.

Compare model prices on the LLM pricing page, see the LLM integration cost page, and run the free estimate.

How does StackLift approach prompt engineering?

On LLM integration and AI agent projects, prompts are treated as part of the codebase: reviewed, versioned and tested against an evaluation set, with observability from sprint one.

AI accelerates the work, and engineers own the decisions. A senior architect reviews every estimate, and agents work on feature branches, never on the default branch.

Questions people ask

Is prompt engineering still relevant with newer models?

Yes. Newer models follow instructions better, but they still need clear tasks, the right context and a defined output. The work shifts toward context and evaluation more than clever phrasing.

Do I need a prompt engineer?

You need the skill, not always a separate role. Engineers, product owners and subject experts often share it. What matters is that someone owns the test set and the review of changes.

What is a system prompt?

It is the standing set of instructions given to the model before the user's message, setting its role, rules and format. Users usually do not see it, and it should not hold secrets.

What is few-shot prompting?

Adding a small number of worked examples to the prompt so that the model copies the pattern. It helps when a format or judgment is hard to explain in words.

How is prompt engineering different from fine-tuning?

Prompting changes the input, and fine-tuning changes the model. Prompting is faster and cheaper to try, so most projects start there and fine-tune only when tests show a gap.

Can prompts be tested automatically?

Yes. Keep a set of inputs with expected outputs, run the prompt against it on every change and score the results. Add checks for format and, where useful, a model or person to grade quality.

How long should a prompt be?

As long as it needs to be and no longer. Include the task, context, rules and format, and cut the rest. Very long prompts raise cost and can hide the key instruction.

Should I store prompts in code or in a tool?

Store them where they can be reviewed, versioned and tested alongside the code that uses them. A prompt that lives only in a chat window or a shared note cannot be reproduced, compared or rolled back when a change makes results worse.

Sources

Sources and further reading

The standards, rules, research and official documentation this page draws on.