Skip to content
← All articles

Prompt Engineering Basics

Practical techniques for writing prompts that get consistent, correct output from language models.

Illustration generated for Neuricon.

Oct 13, 2026 · 4 min read

#guide#ai

Say exactly what you want back

Vague prompts produce vague output. "Summarize this report" leaves the model to guess the length, format, and audience, and it will guess differently every run. Name all three:

```

Summarize this incident report in 5 bullets.

Each bullet under 20 words.

The reader is an on-call engineer who needs the fix, not the backstory.

```

OpenAI's prompting guide frames prompt engineering as writing instructions so the model consistently generates content that meets your requirements. Consistency is the point. If two runs of the same prompt can return a paragraph or a table, the prompt is underspecified, not the model unreliable.

Give the model the context it lacks

A model only knows what you send it. For anything outside its training data (your codebase, your docs, your customer's ticket), paste the relevant material into the prompt or wire up retrieval so it arrives automatically. OpenAI calls this retrieval-augmented generation: query a store, inject the results, and the model answers from your data instead of its memory.

When you do inject documents, point the model at the relevant part. Anthropic's best practices suggest asking the model to quote the relevant passages first, then carry out the task, which keeps long-document answers grounded in the source instead of drifting. Order matters too: put the long, stable material near the top of the prompt and the specific question after it.

Break multi-step tasks into steps

If a task has an order (research, then outline, then draft, then check the draft against requirements), write that order down. Both providers recommend numbered or bulleted steps when completeness and sequence matter. Anthropic's rule of thumb: show the prompt to a colleague with no background on the task. If they could not follow it, the model will struggle too.

```

  1. Read the error log in <log> and identify the failing service.
  2. List the three most likely causes, ordered by probability.
  3. For the top cause, suggest one command that would confirm it.

```

Tell the model what to do

Positive instructions land better than prohibitions. Anthropic's docs give the concrete pair: instead of "Do not use markdown in your response", write "Your response should be composed of smoothly flowing prose paragraphs." The same applies to tone, structure, and scope. Say the behavior you want to see, and describe the output format directly.

This also covers style matching. The formatting of your prompt influences the formatting of the answer, so a prompt written as a checklist tends to return a checklist. If you want prose, write the instruction in prose.

Give the prompt one job

A prompt that classifies, summarizes, and reformats in one pass does all three worse than three focused prompts. Split compound tasks into separate calls with the output of one feeding the next. Each prompt stays short, each step is testable on its own, and when the summary step breaks you know exactly which prompt to fix. Chaining costs more calls but produces fewer tangled failures.

Set temperature to match the task

Temperature controls how much randomness the model introduces when picking each token. For extraction, classification, and anything with a right answer, set it to zero:

```python

from openai import OpenAI

client = OpenAI()

response = client.chat.completions.create(

model="gpt-4o-mini",

temperature=0,

messages=[

{"role": "system", "content": "Classify the ticket as billing, technical, or account. Reply with one word."},

{"role": "user", "content": "I was charged twice for my subscription."},

],

)

print(response.choices[0].message.content)

```

Raise it for brainstorming, drafting, and creative variation. On OpenAI's API the scale runs 0 to 2; Anthropic's runs 0 to 1. Deterministic tasks deserve zero regardless of provider. Reasoning models expose a separate reasoning effort control instead of temperature for their internal thinking, so check the model docs before tuning.

Match the prompt to the model type

Reasoning models (OpenAI's o-series and equivalents) generate an internal chain of thought before answering, so they handle complex multi-step problems with a high-level goal. Standard chat models are faster and cheaper but need the steps spelled out explicitly. If you switch model families, expect to re-tune the prompt: snapshots within one family can behave differently, which is why OpenAI recommends pinning production apps to a specific model snapshot such as gpt-4.1-2025-04-14.

Test prompts like code

Change one variable at a time, keep a set of representative inputs with expected outputs, and re-run that set whenever you edit the prompt or change the model. OpenAI's guide recommends building evaluation suites that measure prompt behavior so regressions surface when you iterate or upgrade models. Store prompts in your application code (typed, reviewed, deployed through your normal process) rather than in a dashboard you edit by hand.

Keep repeated content stable and first

Every token in the prompt costs money and latency on every call. Both OpenAI and Anthropic support prompt caching: identical leading content across requests is served from cache instead of being reprocessed. Put instructions, examples, and documents that stay the same at the start of the prompt, and the per-request question at the end.

Comments

Loading comments…

Leave a comment

Posting as (guest — sign in for a profile)