Skip to content

Search articles, repositories, topics and pages.

LLM

Five Prompting Patterns I Keep Using

A short collection of prompting patterns that consistently work in real projects, with one example each.

TIAN NEWS AI

Published Updated 1 min read

Instructions, untrusted input data and an output schema entering a model as clearly separated prompt sections

These are the patterns I reach for first when a prompt is not doing what I want. None of them are clever; they work because they remove ambiguity.

1. State the output format first

Say what the answer must look like before describing the task. The model then reads the task with the format in mind.

text
Answer with a JSON object {"verdict": "yes" | "no", "reason": string}.
Question: does this function mutate its input?

2. Give one good example

On my tasks, one realistic input/output example is often clearer than a paragraph of rules. More examples can help, but repetitive examples can also encourage the model to copy surface details, so measure the smallest set that works.

3. Separate instructions from data

Wrap pasted content in labelled blocks and refer to the labels. This reduces ambiguity, but it does not create a security boundary or prevent prompt injection. Treat external text as untrusted data, restrict available tools and validate sensitive actions outside the model.

4. Ask for the decision, then the explanation

Put the short answer first and the reasoning after it. It makes answers easier to parse and compare across runs.

5. Name the failure you want to avoid

If the model keeps doing something wrong, say so explicitly: "Do not invent function names that are not in the file."

Key takeaway

Most prompt fixes are about removing ambiguity, not adding cleverness.