Prompt Engineering

Designing the instructions, examples and context given to a language model so it produces accurate, consistent results.

Related terms in this glossary

Good prompts define the task, the format of the answer, the rules to follow and what to do when information is missing. They are tested against real examples, just like code.

How it works

Prompt engineering is writing the instructions, examples and context given to a language model so it produces reliable output. It covers the task description, the format of the answer, worked examples and rules about what to do when information is missing.

What to watch

Prompts should be versioned and tested against a fixed set of real examples, so a change that fixes one case does not quietly break others.

Prompt Engineering in depth

Anatomy of a production prompt

Prompts that hold up in production tend to share a structure. Each part has a job:

  • Role and context: who the assistant serves and what it is for, in a sentence or two.
  • Task: the exact job, with the inputs it will receive marked clearly, for example inside labeled sections or XML-style tags.
  • Rules: what to do and not do, with reasons. Models follow rules better when they understand why.
  • Missing information: what to say or return when the answer is not in the provided material, so the model does not guess.
  • Output format: a schema or template. For software consumers, use structured output rather than describing JSON in words.
  • Examples: a few input and output pairs covering typical and tricky cases.

Put stable parts first and variable parts last; that also helps prompt caching.

Example: improving a ticket classifier

Example: a support team's first prompt says "Classify this ticket into billing, technical or other". Testing on a few hundred labeled tickets shows confusion between billing and technical for payment-gateway errors, and Hinglish tickets often land in "other". The team rewrites the prompt with a definition for each category, a rule that payment failures during checkout are technical while refunds and invoices are billing, and three Hinglish examples. They add an "unclear" category that routes to a person. Accuracy is measured again on the same set, and the confusion table shows which categories improved and whether any got worse. The new prompt is committed with its evaluation results attached to the pull request.

Techniques that help, and when

TechniqueUse when
Few-shot examplesFormat or judgment is hard to describe in words
Step-by-step reasoning or chain of thoughtMulti-step problems on non-reasoning models
Decomposition into several promptsOne prompt is doing classification, extraction and writing at once
Grounding with retrieved passagesAnswers must reflect your own data
Self-check or a separate reviewer promptErrors are costly and can be checked against rules

Reasoning models often need less step-by-step instruction and respond better to clear goals and constraints. Re-test prompts when switching model families, because what works on one may not work on another.

Treating prompts as code

  1. Store prompts in version control, not pasted into a dashboard.
  2. Keep an evaluation set of real inputs with expected outputs or grading rules.
  3. Run the set on every prompt change, and compare with the current version.
  4. Record the prompt version in every trace, so an output can be traced to its prompt.

This is the core of LLMOps, and it is what separates a prompt that works in a demo from one that keeps working.

Common mistakes

Typical problems are long lists of capitalized "NEVER" rules without reasons, contradictory instructions added over time, examples that all look alike so the model overfits to them, and prompt changes judged on two or three hand-picked inputs. Prompts are also not a security boundary: instructions alone cannot stop prompt injection, so permissions must be enforced in code. When prompting reaches its limits, fine-tuning or retrieval may be the next step. Gepton teaches these practices in team training and applies them in AI agents.

Questions about Prompt Engineering

Something else? Send us your question and an engineer replies with next steps.

When should we fine-tune instead of improving the prompt?

Exhaust prompting and retrieval first, because they are faster to change and test. Consider fine-tuning when a well-designed prompt with good examples still misses a consistent style, format or domain judgment, when the prompt has become very long and costly to send on every request, or when you want a smaller model to match a larger one on a narrow task. Fine-tuning needs a quality labeled dataset and its own evaluation.

Should prompts be written in English if users write in Hindi?

Often the instructions can stay in English while the prompt tells the model to reply in the user's language and style, including Hinglish. Most strong models follow English instructions well and answer in Hindi. Include examples in the languages your users actually write, because examples shape output style more than instructions do. Test both approaches on your own messages, since results vary by model and language.

Articles that mention Prompt Engineering

All articles

Jump to

↑↓ to move↵ to open