Prompt Engineering
Definition. The discipline of designing the instructions, context, examples and output constraints that steer a language model toward reliable behaviour. It is not a trick but a specification activity: a good prompt is a precise contract stating role, task, inputs, constraints, output format, edge-case handling and refusal conditions. Because the model has no other channel for requirements, the prompt is the program.
How it works. Structure prompts in fixed sections: role and scope, task definition, input data delimited clearly, rules and constraints, output schema, and examples. Put the most important instructions at the start and repeat critical constraints at the end. Use delimiters such as XML tags to separate instructions from data. Version prompts in source control, evaluate every change against a fixed test set, and never edit a production prompt without a measurable comparison.
Example. A classification prompt initially reads: categorise this ticket. Accuracy is 71 percent. The rewritten version specifies twelve categories with one-line definitions, requires a JSON object with category, confidence and rationale, instructs the model to choose other when no category fits, and includes three worked examples including one ambiguous case. Accuracy rises to 89 percent and the confidence field lets the system route low-confidence items to humans.
Use case. Prompt engineering is the first and cheapest lever for any LLM feature. It is where you encode business rules, tone, compliance constraints and output contracts. It is also how you make a system auditable, because a readable prompt can be reviewed by legal and compliance in a way that weights cannot.
Warnings. Prompts are not security boundaries. A prompt that says do not reveal the system message will be defeated by a determined user. Never put secrets, credentials or access-control decisions in a prompt, and never rely on instructions alone to prevent an agent from taking a destructive action.
Limitations. Prompt engineering is brittle across model versions, languages and input distributions. It consumes context and therefore money. It cannot add knowledge the model lacks, cannot guarantee determinism, and its effects are often non-monotonic: adding more instructions can reduce compliance with earlier ones.
| Pros | Cons |
|---|---|
| Lets teams test and revise instructions before changing model weights. | Prompts can behave differently across models, languages, and inputs. |