Working with AI

Prompt engineering, from a prompt that works

Prompt engineering means writing four things explicitly instead of one vague request: the context, exactly what you want, what must not appear in the answer, and the shape the answer comes back in. The real skill is not the first prompt; it is reading a wrong answer and changing exactly one thing in the next round.

  • Lesson 3 of 15
  • Beginner
  • Free, no signup

The four pieces that together make a prompt

Any piece you leave out, the model fills in for you. A bad answer usually means one of these four was its choice and not yours.

  • Context

    What the work is, who it is for, what the reader knows and does not know.

  • Task

    One concrete verb. "Help them choose" and "explain" are two different jobs.

  • Constraints

    What must not appear. A rule you cannot check afterwards is not finished.

  • Output shape

    How many parts, headings or none, a table or paragraphs. Most wasted time sits here.

There is no fixed law about the order you write them in. The one place order matters is long prompts, and that has its own section here.

Last checked: Facts and tool names in this lesson are re-checked against their sources on this date.

What a working prompt is actually made of

Every prompt that returns something usable carries four things, even when the person writing it does not know their names. First the context: where the model stands in the work, who it writes for, what it already knows and what it does not. Second the task: exactly what to do, with a concrete verb. Third the constraints: what must not appear in the answer. Fourth the output shape: what the answer comes back as, how many parts, headings or none, a table or paragraphs.

Most people write the first three, more or less. The fourth is where the time goes, because when you do not state a shape the model picks one, and it usually picks whichever shape was most common in the text it learned from: an intro, a bulleted list, a conclusion. Then you sit there rearranging it.

Constraints carry one point that gets said too rarely: a negative constraint is weaker than a positive one. "Do not be promotional" is a sentence everyone reads differently. "Use no superlatives such as best or highest quality" is a rule you can hold an output against afterwards. The test is simple: if you cannot say how you would check that a rule was followed, that rule is not finished yet.

Four glass jigsaw pieces lit red, green, blue and white fitting into one square

The same four parts on a real example

Here is a prompt people really write, and if it looks a little embarrassing it is because all of us have written a version of it:

write me some text for my site about brake pads. make it SEO friendly.

The model writes something. Eight hundred words, an introduction about how important brakes are, a list of pad types, and a conclusion saying that choosing the right pad matters a great deal. None of it is wrong and none of it belongs on a shop category page.

The same request in four parts:

Context: I run an online car parts shop and this text is for the "brake pads" category page. The buyer usually knows their car model but not which pad fits it.

Task: write 200 words that help the buyer choose the right pad for their car.

Constraints: no prices, because ours change weekly. Recommend no brand. Use no superlatives such as best or highest quality.

Output shape: three consecutive paragraphs, no headings, no lists.

The difference between these two outputs is not a difference of model. It is the same model. What changed is that in the second version the model no longer makes the four decisions it made for you in the first.

One note on length: models treat "200 words" as approximate, not exact. If the exact number matters, count it in the output and correct in the next round; insisting harder in the prompt does not fix it. The reason goes back to how the thing works, which the lesson on large language models covers: a model does not count words, it guesses the next token.

The same model, two prompts, two results

What changes between these two columns is the number of decisions the model takes on your behalf.

The vague prompt

  • The model guesses the audience itself
  • It picks length and tone on its own
  • It reaches for the common web shape: intro, list, conclusion
  • You rearrange the output afterwards

The four part prompt

  • The audience and what they know is written in the context
  • The task carries one concrete verb
  • The constraints can be checked
  • The output shape was decided in advance

The right column is not a guarantee either. You still read the first answer and fix it; the difference is that you know which piece to change.

How to fix a first prompt in three rounds

Your first prompt is incomplete, and that is not a personal failing. Until you see an output you cannot know which part of your request was ambiguous; ambiguity is something only visible from outside. So the real work starts at round two, and it has one rule: change exactly one thing per round. If you change three things and the result improves, you have learned nothing and next time you start from zero again.

On that brake pad text, three real rounds look like this. Round one comes back in the right shape but explains what a brake pad is instead of helping anyone choose. The problem is not in the constraints, it is in the task: the model read "help them choose" as "teach them". So we sharpen the task and nothing else.

Round two does help you choose, but it assumes the reader knows the part number. That one is a context problem rather than a task problem: we never said what the buyer knows and does not know. One line goes into the context. Round three is usually the thing you wanted.

One habit worth more than the prompt itself: do not throw the wrong outputs away. Those two unusable answers from rounds one and two are your test set. Next time you change the prompt, or the model changes under you, they are how you tell better from merely different.

And a warning: if three rounds have not got you there, the problem is probably not the prompt. Either the information the task needs is not in the prompt at all, or you have asked for something this kind of tool cannot do. Rounds four and five are just time.

The loop that actually fixes a prompt

Four steps, and step two is the one most people skip on their way to rewriting the whole prompt.

Every roundexactly one change
  • 1 Name the fault in one sentence
  • 2 Decide which piece the fault belongs to
  • 3 Change that one piece
  • 4 Run it again on the same inputs

If three rounds have not got you there, stop looping. The information the task needs is probably not in the prompt at all.

Which prompts to keep, and where

Any prompt you will use a second time is worth saving. The place to save it is a plain text file on your own machine, not the product internal memory. Three reasons: it moves between tools, it survives a change of subscription, and you can put the old and new versions side by side and see exactly what changed.

The prompt alone is not enough, though. Keep two other things next to it: the five real inputs you tested it on, and one output you accepted. Without those, what you saved is a paragraph; with them, it is something you can measure again next month.

Name the file after the task, not the tool. "Customer message summary" still means something in a year; "chatgpt prompt 2" does not.

One thing does not belong in that file: client data, passwords, tokens, account numbers. Prompts get copied and passed around work groups, and that is exactly where they leave your hands.

When you paste a long text, where does the question go

This is one of the few details vendors have written explicit guidance about, and Persian tutorials mostly leave it out. Google guidance for Gemini says that when you supply a large amount of context, a document or a block of code, put all the context first and place your specific question or instruction at the very end of the prompt. The same page says to put essential behavioural constraints, the role definition and output format requirements at the very beginning of the prompt or in the system instruction.

So the suggested order for a long prompt is: the main rules, then the whole text, then the question. The common habit is the exact reverse: people write the question and then paste fifteen pages under it.

An honesty note: we have not measured this on this server. It is Google own guidance for Google own model, and other vendors frame it differently. If your work involves long texts regularly, run your five test inputs once with the question first and once with the question last, and judge for yourself. It takes ten minutes and the answer is yours rather than a quotation from us.

Those magic prompts people sell

Our position is plain: most of those "500 golden prompts" packs are worthless, and the reason is technical rather than moral. A good prompt is tied to three things, none of which belongs to the seller: your specific task, your real inputs, and the model you use today. No prompt carries those three with it.

The second point is worse. Those prompts tend to be long, because length reads as professional, and they are full of rules nobody tested. An untested rule is not harmless: it takes up the model attention and it sometimes contradicts another rule in the same prompt. Cutting a crowded prompt down usually works better than adding to it.

Third, none of those packs ships a test. They show you an output, not a method for saying this prompt beats that one. Anthropic own documentation puts a condition before the prompt engineering chapter: have your success criteria and a way to test against them first, then go and improve the prompt. The same page says not every problem is best solved by prompting; sometimes the answer is a different model.

A prompt library is worth having, though, as long as it is yours. Five prompts written for your own real work and tested on your own inputs beat five hundred bought ones. That is not a nice sentiment: those five were built out of your actual failures, and the five hundred were built out of nothing.

The fast path, with AI

The fastest professional route today is not to write a better prompt; it is to not write it yourself. Collect three examples of the output you want, ask a strong model to write the prompt that would produce them, and have it tell you which parts of your request were ambiguous and what it assumed. That list of ambiguities is usually worth more than the prompt, because it shows you what you had assumed everybody knows.

  1. Collect three examples of the output you want. If you have none, two good ones and one bad one you already received will do; the bad one often teaches more.
  2. Run the recipe below on a strong model, not on the fastest one. This step is judgment rather than mechanical work; the current chat model ranking lives in the AI section of this site.
  3. Run the prompt you got back on five real inputs, not one. A fast cheap model is enough for this round, because all you want is to see where it breaks.
  4. Delete every rule whose removal did not change the output. Almost nobody does this step, and it is the one that keeps a prompt stable.
  5. Keep the final version in a text file, next to those five inputs and one accepted output. Next time you will not start from zero.

Copy-ready recipe

I want you to write a prompt that makes a language model do this: {the task, in one sentence}

These are examples of the output I want:
{example 1}
{example 2}
{example 3}

This is an output I got before and do not want repeated:
{bad example}

Give me three things:
1. The proposed prompt, in four separate labelled parts: context, task, constraints, output shape.
2. A list of the places where my request was ambiguous. For each one, say which reading you took and what the other reading would have been.
3. Three sample inputs that would break your prompt if it is weak.

Do not produce the answer itself. Write only the prompt.

Before you trust the output: The model writes a plausible prompt, not a tested one. Step three, running it on five real inputs, is that test and it is not optional. Separately, anything in that prompt which is a fact about your business, a price, a name, an internal rule, you write yourself and you check yourself; one wrong rule in a prompt repeats silently in every output after it.

AI in this kind of work

The right question here is not which tool writes prompts, but which model actually respects the instruction you wrote. Our honest answer: our own ranking does not measure that, and we will not answer it from a feeling. What you can settle in ten minutes is this: give your own five inputs and one prompt to two models and count which constraints each of them broke. An answer reached that way is yours and depends on nobody opinion.

Tools that actually help

  • Claude Asked for a list of the ambiguities in your request, it answers more directly and fills the gap in for you less often. Iran is on neither of Anthropic two supported-countries lists; we read that on Anthropic own page rather than measuring it.
  • Gemini Its vendor publishes the clearest guidance on prompt structure, including the rule about where the question goes in a long prompt that appears above. It also handles Persian well. Google own page says the Gemini web app runs in over 230 countries and territories, and Iran is not on that list.
  • ChatGPT The most common choice and acceptable for this job. We make no claim about access from Iran: the OpenAI supported-countries page, like the rest of that domain, returns an access error to this server, and we do not write a claim with nothing behind it.

Where it backfires

This backfires in two places. First the context piece: context is exactly where client data enters a prompt, and whether the text you send is used for training depends on plan and settings; Anthropic explains this on its own privacy page and other vendors keep a comparable page. Our practical rule is simple: if you would not post a text in your work group, do not put it in a prompt either. For how access and payment for these tools stands from Iran, see the buying guide. Second, a prompt is not portable: it is tied to a model, and when a vendor updates that model under the same product name, a prompt that worked for months can slip quietly. No notice arrives; you find out from the output, if you kept those five test inputs.

Sources: Anthropic: prompt engineering overview Anthropic: is my data used for model training Google: prompt design strategies for Gemini Anthropic: supported countries

Where this advice stops

A prompt adds no information. If the right answer needs data the model does not have, your prices today or one client contract, no phrasing conjures it; the fix is supplying the data, not writing the request more beautifully. Second, this whole lesson is about text: prompting an image model follows a different logic and belongs to the lesson on generating images with AI. Third, and bigger than both: this page does not tell you which model follows instructions best, because our own ranking does not measure that. What we do measure, with sources, sits in the chatbot ranking and, for code work, the coding model ranking. Last, this skill is shrinking: newer models need less ceremony, and the checked date at the top of this page exists for exactly that reason.

From our own work

The main rule of this lesson, that a rule you cannot check is not finished, comes from somewhere we paid for it ourselves. For the text on this site we keep a banned character list: 63 characters in the Persian rule set, from the em dash and curly quotes to the Arabic forms of two letters, plus 12 Persian filler openings. For a long time the assumption was that writing those rules into the prompt was enough. It was not. Now a Python script runs over the file before publication and reports every character with its Unicode codepoint, and in the very first session that built this section it caught 4 slips, none of which any human eye had seen. The conclusion that matters for your own prompting: an instruction does not guarantee an output; a checker does. The evidence is this page, where you will not find a single zero width joiner or long dash.

Real follow-up questions

Should I write the prompt in Persian or in English?

If you want Persian output, write in Persian; current models understand it. We have not measured a quality difference between the two on this server and we claim none. The one thing we are sure of comes from how the machine works: a language less represented in the training text breaks into smaller tokens, so the same meaning costs more. If you pay per token that matters, and if you are on a free chat plan it does not.

Why did the same prompt work yesterday and not today?

Two reasons, both outside your control. First, there is deliberate randomness in each word pick, so one question gets two answers. Second, the vendor can update the model under the same product name without telling you. Those five test inputs turn "it feels worse" into something you can actually show.

Does giving the model a role, like "you are a lawyer", actually help?

Less than advertised, but not nothing. A role shifts vocabulary, the assumed audience and the level of detail, which is why it belongs in the context part. What it does not add is knowledge: "you are a lawyer" does not make an answer legally correct. If the role only decorates the first line and the rest of the prompt says nothing about the audience, delete it.