Artificial intelligence

How to write a prompt

A good prompt differs from a bad one not in length or politeness but in having everything the work needs — the task, the material, the shape of the answer and what a usable result looks like.

Updated
In this article

The five parts of a prompt#

Keep this order at hand and fill it in from the top.

  1. The task in one sentence. A verb and a result: "rewrite", "find the bug", "make a table". Not "help me with this text".
  2. The material. The text, code, data or problem itself. Without it the model fills in the gaps, and you later mistake its guesses for your own facts.
  3. Who it is for and why. Who the reader is, where it will be published, what they already know. This decides the vocabulary better than any "keep it simple".
  4. The shape of the answer. Length, structure, language, headings, a table or a list. If the result goes into a program, a schema.
  5. Constraints and stop rules. What not to do; what to write if there is not enough information.

The fifth part is the one most often skipped, and it saves the most time. A line like "if the text does not contain the answer, write 'not in the text'" turns a confident invention into an honest gap.

Example one: a piece of writing#

Bad:

Write a post about the new plan

The model knows nothing about the plan, the platform or the reader — you get a faceless template you will have to rewrite from scratch.

Good:

Task: write a LinkedIn post about our new pricing plan.
Material: the "Team" plan — 5 seats, a shared archive,
report export to CSV; do not mention the price.
Reader: owners of small agencies, not technical people.
Shape: 700–900 characters, three paragraphs, no emoji, no
"don't miss out" calls; the last paragraph is one line on what to do next.
Constraint: do not invent features that are not in the material.

What changed: there is material, the platform and the reader are named, the length is set, and the main failure of such texts — adding features that do not exist — is ruled out.

Example two: code#

Bad:

Why doesn't my code work?

Good:

Python 3.12. The script reads a CSV and crashes.
Code:
    import csv
    with open("data.csv") as f:
        rows = list(csv.DictReader(f))
    print(rows[0]["Price"])
Error: KeyError: 'Price'
Already checked: the file opens and has rows.
Needed: explain the cause and give a corrected snippet,
without rewriting the whole script.

What changed: the language version, the full error text, the code itself, the hypotheses already ruled out, and an explicit limit on how much to change. The last part matters most — otherwise you get a script rewritten from scratch that you have to understand all over again.

Example three: working with a document#

Bad:

Summarize this

Good:

Below are meeting notes. Summarize them using this outline:
1) decisions — a bulleted list, one sentence each;
2) who does what and by when — a three-column table;
3) open questions.
Write only what is in the text. If no deadline is given,
put a dash in the date column.
Text: <...>

What changed: the structure is set, guessing is ruled out, and the behaviour when information is missing is described. You can paste this answer straight into a working document.

If the answer misses#

Do not start with "try again" — with a probabilistic model that is just a second roll of the dice. Do one of three things.

Say exactly what is wrong. "Too long — make it half the length and drop the intro paragraph" beats "I don't like it".

Show an example. One sample of a finished result in the style you want changes the answer more than a paragraph of description.

Split the task. First a plan, which you edit, then the text based on the approved plan. A long task in one go goes off course more often; AI agents are built on the same principle.

Edit the prompt rather than replying in the old conversation: a long thread drags all the earlier clutter along with it.

Checklist before sending#

  • The task is named with one verb, and the result is clear.
  • All the material needed is pasted into the prompt, not implied.
  • The reader is named.
  • The length and structure of the answer are set.
  • It says what to do if information is missing.
  • The prompt contains no personal data, passwords, keys or other people's documents that must not be shown to a third party.
  • If the answer goes into a program, there is a format you can parse automatically.

What to check in the answer#

Numbers, dates, names and legal references — check against the source. Links — open them: an address can be invented whole. Quotes — find them in the original. Code — run it, do not just read it. Claims about your own field deserve extra attention: a plausible inaccuracy is noticeable in a familiar topic and invisible in an unfamiliar one.

Remember that an answer sounds equally smooth and confident whether it is right or wrong, and a hedge like "possibly" is not a sign of doubt — it is just another chosen phrase. Why it works this way is explained in what is an LLM.

And a line that no wording can move: medical, legal and financial decisions are made by a doctor, lawyer or financial adviser with a licence and responsibility, not by a chat. Where a mistake costs health, money or rights, a person who is accountable decides. The name of the service — ChatGPT, Claude, Gemini or any other — changes nothing here.

Step-by-step plan

  1. Write the task in one lineA verb plus a result; if the line will not come together, the task is not defined yet.
  2. Paste in the materialCopy the text, code or data into the prompt in full instead of describing it.
  3. Set the shape and a stop ruleLength, structure and what to do when information is missing — three lines that save a round.
  4. Run the checklistBefore sending, go through the seven points, especially the one about personal data.
  5. Fix the prompt, not the chatWhen the answer is bad, edit the original prompt and send it again from a clean start.
  6. Fact-check the answerOpen the links, check the numbers, run the code — only then use it.

Start learning this in your own space

The plan goes into your repository: tick off stages, keep notes — the change history shows how far you have come.

Start the plan

Check yourself

1.Which part of a prompt is most often missing when a model "makes up" details about your product?

2.Why add the line "if the text does not contain the answer, say so" to a prompt?

3.The answer came out too long and off the point. What helps most?

Sources

Was this helpful?

More articles

Artificial intelligence Prompt engineering Prompt engineering is choosing the input text so that a model more often produces the result you need. It is not a set of magic spells but ordinary engineering work — a hypothesis, a test on a set of examples, rolling back changes that did not help. Artificial intelligence How to use AI Getting started is simpler than it looks: you need one service, one real task from your own work and the habit of checking the result. Everything else is detail you pick up along the way. Artificial intelligence AI agents An agent is not a special, smarter model but a harness around an ordinary one: the model gets a list of tools and is allowed to call them in a loop until the task is finished — or until patience runs out. Artificial intelligence AI for studying A model can explain a confusing point three different ways and answer a silly question patiently, without judgement. It can also hand you a finished assignment that leaves you unable to do anything new. Artificial intelligence How neural networks work A neural network is simpler than its name suggests. Inside there are no thoughts or images — there are tables of numbers multiplied by the input values, and a procedure that keeps nudging those numbers until the answers get more accurate. Artificial intelligence What is an LLM An LLM (large language model) is a program trained to continue text. Everything it does comes down to one operation: look at what has been written so far, predict the next small piece, and repeat.

More solutions