openskills.info

Prompt Engineering

itArtificial intelligence and machine learning

Prompt Engineering

Prompt engineering is the discipline of writing instructions that get a language model to produce the output you need. You are not programming the model. You are communicating with it — giving it context, constraints, and examples so it understands your intent and responds usefully.

The skill matters because the same model can produce wildly different results depending on how you ask. A vague instruction gets a vague answer. A precise instruction with the right structure gets a precise answer. The gap between those two outcomes is what prompt engineering closes.

What prompt engineering is

A prompt is the text you send to a language model. Prompt engineering is the process of designing, testing, and refining that text so the model consistently meets your requirements. It sits between your intent and the model output.

The work is empirical. You write a prompt, test it against examples, measure whether the output meets your criteria, and revise. There is no single correct prompt for a task — only prompts that meet your success criteria more or less reliably. Treat it like writing a specification: the clearer and more complete the spec, the closer the output matches what you need.

Why it exists

Language models generate text by predicting what comes next, conditioned on the input you give. They do not read your mind. They respond to what is actually in the prompt — the words, the structure, the order, the examples, and the framing. If critical information is missing, the model fills the gap with its best guess, which may be wrong.

Prompt engineering exists because:

  • Models follow instructions literally. Ambiguity in the prompt becomes ambiguity in the output.
  • Models have no memory of your past intentions unless you include them.
  • The same model can reason carefully or produce garbage depending on how the task is framed.
  • Output quality is often limited by input quality, not model capability.

The core techniques

Six techniques form the backbone of effective prompting across all major models.

Be explicit and specific. State what you want, how you want it, and what format to use. Avoid leaving decisions to the model that you already know the answer to. If you want three bullet points, say three bullet points.

Use structured formatting. Separate instructions from context. Use headers, XML tags, or delimiters to mark where your instructions end and the reference data begins. Models parse structure well — a wall of undifferentiated text is harder to follow.

Provide examples (few-shot prompting). Show the model what good output looks like. Two or three input-output pairs often do more than a paragraph of instructions. Pick examples that cover the range of inputs you expect, including edge cases.

Assign a role or persona. Telling the model to respond as a specific expert (a senior security engineer, a technical writer, a tax accountant) primes it toward the vocabulary, tone, and reasoning patterns of that domain.

Break complex tasks into steps. Instead of one prompt that does everything, chain smaller prompts where each handles one piece. The output of one becomes the input of the next. This reduces errors and makes each step testable.

Ask the model to reason before answering. Requesting step-by-step reasoning (chain-of-thought) improves accuracy on tasks that require logic, math, or multi-step analysis. The reasoning trace lets you verify the path, not just the answer.

Message roles and structure

Modern APIs separate prompts into roles with different authority levels:

  • System or developer messages define the assistant behavior, rules, and constraints. They carry the highest priority.
  • User messages carry the actual request or input data.
  • Assistant messages show the model what its own prior responses look like, useful for multi-turn context or prefilling a response format.

This separation matters. Instructions in the system message are harder for a user input to override. Treat the system message as your configuration layer and the user message as the runtime input.

When prompt engineering is not enough

Prompt engineering works until it does not. Signs you have hit its ceiling:

  • The model reliably gets the right answer on your test cases but is too slow or expensive.
  • You need the model to use knowledge it was not trained on — retrieve it first, then pass it in.
  • Edge cases keep failing no matter how you rephrase — fine-tuning or a different model may help.
  • The task requires deterministic, rule-based logic — write code instead of a prompt.

Where prompt engineering fits in the stack

Prompt engineering is one layer in a system. Above it: the application logic that decides when and how to call the model. Below it: the model itself and its training. Adjacent to it: retrieval systems that feed context, evaluation frameworks that measure quality, and guardrails that constrain output.

The discipline is model-agnostic in principle — the same techniques apply whether you use OpenAI, Anthropic, Google, or open-weight models — but optimal prompts vary per model. A prompt tuned for one model may need revision when you switch providers or upgrade versions. Pin to a model version in production and re-evaluate when you change it.

Relevant careers