← Home · Tutorial 04 · Working with LLMs

Prompt engineering tactics

Nine prompting tactics that still hold, and why each matters.

Last reviewed 5 October 2026 · Written with AI assistance and reviewed by me

Where I learned this: my notes from the Guidelines and Iterative lessons of DeepLearning.AI's ChatGPT Prompt Engineering for Developers (Isa Fulford and Andrew Ng). I then checked each tactic against current provider documentation, including Anthropic's prompting best practices, to mark what still holds. The examples are my own.
Who this is for: anyone who writes prompts and wants more reliable results. You will learn the tactics that matter, and why hallucination is a limit rather than a bug to prompt away.

1Purpose first

Why prompting still matters, and what has moved.

I started my AI learning journey with prompt engineering. It is not out of date. On many real workloads you cannot always fine-tune a model or wire in fresh context, so the prompt is still the first lever you reach for.

Some older tactics have since moved out of the prompt text and into the API itself. This page keeps the ones that still hold and shows the modern version where the API now does the job.

The two questions for each tactic: what is it, and why does it matter when real people and real data are involved.

2The tactics at a glance

What each tactic is and why it matters.

TacticWhat it isWhy it matters
Use delimitersMark where the input text starts and endsKeeps content separate from instructions
Ask for structured outputGet JSON that matches a schemaReplies a program can use directly
Check conditions firstVerify an assumption before answeringStops the model inventing structure
Few-shot promptingShow worked examplesConsistent tone and format
Give the model time to thinkSolve independently before judgingAvoids rubber-stamping a wrong answer
Dictate the output formatSpell out the exact fieldsOutput usable without a human reading it
Know hallucination existsModels can sound sure about things that are not realThe core risk in enterprise use
Reduce hallucinationGround the answer in source textAnswers you can trace to evidence
IterateRefine a prompt in a loopPrompts rarely work the first time

3Use delimiters

Keep content separate from instructions.

What it is. Mark exactly where the input text starts and ends, using triple quotes, backticks, angle brackets or XML-style tags, so the model can tell your instructions apart from the material to work on.

Why it matters. When user-supplied text is mixed into a prompt, the model can mistake it for instructions. Clear boundaries keep content as content.

Prompt
<instructions>
Summarise the customer message in one sentence.
</instructions>

<customer_message>
{message}
</customer_message>

Anthropic's guidance recommends consistent, descriptive XML tags for exactly this, especially when a prompt mixes instructions, context, examples and inputs.

Know the limit: delimiters make injection harder, but they are not a complete defence. If the text comes from outside your control, also limit what the model is allowed to do and check its output in code.

4Ask for structured output

From free text to data.

What it is. Get the reply as JSON that matches a schema you define, so it loads straight into a dictionary.

Why it matters. It turns a chat reply into something a pipeline can use, with no string-splitting. Asking for JSON in plain words only requests the format. Providers now let you enforce a schema instead.

Anthropic structured outputs (shape taken from the docs, not run here)
response = client.messages.create(
    model="MODEL_ID_FROM_THE_DOCS",
    max_tokens=300,
    messages=[{"role": "user", "content": message}],
    output_config={
        "format": {
            "type": "json_schema",
            "schema": {
                "type": "object",
                "properties": {
                    "category": {"type": "string"},
                    "urgent": {"type": "boolean"},
                },
                "required": ["category", "urgent"],
                "additionalProperties": False,
            },
        }
    },
)

OpenAI offers the same idea: a JSON schema with strict turned on. Its older "JSON mode" only guarantees valid JSON, not that your fields exist.

Limits to check: support depends on the model, there are caps on schema size and complexity, and the first request with a new schema can be slower. Read the provider's current documentation before relying on it.

5Check conditions first

Validate before generating.

What it is. Before the model does the task, have it check that the input actually meets the condition the task assumes.

Why it matters. It stops the model inventing structure that was never there. This is validation before generation.

Prompt
You will be given text in triple quotes. If it contains a sequence of instructions,
rewrite them as numbered steps. If it does not, write exactly: "No steps provided."

"""{text}"""

A paragraph describing a sunny afternoon should come back as "No steps provided", not as made-up steps. You can then test for that exact reply in code.

6Few-shot prompting

Show, do not only tell.

What it is. Show the model a worked example of what a good answer looks like, instead of only describing it.

Why it matters. For tone and format consistency, such as a ticket summary or an escalation template, one good example often does more than paragraphs of instruction.

Prompt
<examples>
<example>
Message: "My invoice shows the wrong amount."
Reply: "Thanks for flagging this. I've sent it to our billing team, who will correct it within two working days."
</example>
</examples>

Write a reply in the same style for this message:
<message>{message}</message>

One example is the minimum. Anthropic's guidance suggests several well-chosen, varied examples (it mentions three to five) wrapped in their own tags, so the model picks up the pattern and not an accident of one example.

7Give the model time to think

Verdicts after reasoning.

What it is. Have the model work out its own solution first, and only then judge someone else's answer.

Why it matters. A model that jumps straight to a verdict is more likely to wave through a wrong answer. In a grading or validation setup, the safer design is: solve independently, then compare.

Prompt
First work out your own solution to the problem.
Then compare your solution to the student's.
Only then decide whether the student's solution is correct.
A note on older advice: you will see "think step by step" in many guides. Newer reasoning models do that internally, and Anthropic's current documentation prefers a general nudge to think thoroughly over a hand-written plan. The lasting lesson is the independent check, and a second pass or a piece of code can do it as well.

8Dictate the output format

Fields you can parse.

What it is. Spell out the exact fields and order you want in the reply.

Why it matters. It makes the output usable downstream without a person reading every response.

Prompt
Use this format:
Question: <the question>
Student solution: <the student's answer>
Actual solution: <your own worked answer>
Matches: yes or no
Grade: correct or incorrect

Naming the fields means a program can parse each line reliably. Where a provider offers enforced structured output (see above), prefer that to free-text formatting.

9Hallucination is a limit

Confident, fluent and wrong.

What it is. A language model can produce fluent, confident text about things that are not real. Ask about a product that does not exist and it will often describe it anyway.

Prompt
Tell me about the AeroGlide X900 toothbrush.
(a product I made up for this example)

Why it matters in an organisation. An ungrounded model can invent a policy, a number or a contract clause with the same confidence as a correct answer. The risk is not that it sounds unsure. The risk is that it does not.

Real risk: anything a customer, a regulator or a colleague might rely on needs a source behind it, or a person checking it.

10Reducing hallucination

Ground the answer in source text.

What it is. Ground the answer in real source text. Find the relevant passage first, then answer only from it.

Why it matters. The difference between "tell me about X" and "using only the text below, tell me about X" is the difference between an answer and a guess.

Prompt
<document>
{policy_text}
</document>

First quote the sentences from the document that are relevant to the question.
Then answer using only those quotes. If the document does not contain the answer,
say "I can't find that in the document."

Question: {question}

Anthropic's guidance for long documents recommends exactly this quote-first step. It is the manual version of what retrieval-augmented systems (RAG) automate. It is worth knowing by hand before you trust a framework to do it for you.

11Prompting is iterative

A loop, not a one-shot write.

A prompt is rarely right the first time. Treat it as a loop you tune against real examples.

The loop
Ideawhat you want
→
Write a promptclear and specific
→
Run iton real examples
→
Analysewhy was it wrong?
↺
Refinechange one thing
If the output is…Try…
Too longState a limit, for example a number of sentences or words
Too technicalName the audience and the level
Focused on the wrong thingSay what to focus on and what to leave out
Hard to use downstreamSpecify a format, or use enforced structured output
Plan for it: budget time for several rounds. Change one thing at a time, and keep a small fixed set of test inputs so you can tell whether a change helped.

12Check yourself

Short questions and one line to remember.

Do delimiters fully protect against prompt injection?

No. They help the model separate instructions from content, but you should also limit what the model can do and validate its output in code.

What is the difference between asking for JSON and using structured outputs?

Asking only requests the format. Structured outputs enforce a schema you supply, so the fields you need are there.

Why solve a problem independently before judging someone else's answer?

Because a model that goes straight to a verdict tends to agree with whatever it was shown. Working it out first gives it something to compare against.

What is the quote-first technique for?

Reducing made-up answers by forcing the model to find evidence in the source before it answers.

One line to remember: "Prompts request, systems enforce, and the best tactics are the ones that give the model something to check against."
Try it yourself: take one prompt you use often, wrap its input in tags, add a "say you don't know" rule, then test it on three inputs, one of which has no answer in the text.
Notes based on lessons from DeepLearning.AI’s ChatGPT Prompt Engineering for Developers by Isa Fulford and Andrew Ng, checked against provider documentation at the time of writing (Anthropic structured outputs, OpenAI structured outputs). Provider features change often, so check the current docs. Examples and wording are my own. Independent notes, not affiliated with or endorsed by DeepLearning.AI, Anthropic, OpenAI or any company named here.