mosaddik.dev
All posts

How to write prompts that get better AI answers

Mosaddik Billah 4 min read

AI

A person typing on a smartphone with an AI chat app open
Photo by Zulfugar Karimov on Unsplash
On this page
  1. 1. Give the context a colleague would need
  2. 2. Say what you want, not only what to avoid
  3. 3. Explain why
  4. 4. Show an example
  5. 5. Separate instructions from material
  6. 6. Ask for the format you’ll use
  7. 7. Let it say “I don’t know”
  8. 8. Iterate
  9. Prompts inside your own website or app

The quickest way to get better answers from an AI model is to write better instructions. Most weak results come from prompts that leave the model guessing: about who the audience is, what the output should look like, or what “good” means. These habits work with Claude, ChatGPT and other models.

1. Give the context a colleague would need#

Imagine handing the task to a smart new colleague who knows nothing about your business. What would they need to know?

Before:

Write a product description for our candle.

After:

Write a product description for our online shop.

Product: Monsoon, a soy wax candle that smells of wet earth and jasmine.
Burn time about 45 hours, hand-poured in Dhaka.
Audience: people buying gifts, mostly on their phones.
Tone: warm and simple, no exaggerated claims.
Length: about 60 words, then three short bullet points with the key facts.

The second prompt answers the questions the model would otherwise guess at.

2. Say what you want, not only what to avoid#

“Don’t be too formal” leaves a wide range of options. “Write like a friendly shop owner talking to a regular customer” points to one. Positive instructions are easier to follow than lists of things not to do.

3. Explain why#

A reason helps the model apply a rule sensibly. Compare:

Keep sentences short.
Keep sentences short. Many of our readers speak English as a second language.

With the reason, the model also avoids idioms and rare words without being told.

4. Show an example#

If you need a specific format or style, an example works better than a description. Put it in clearly marked tags so it isn’t confused with the instructions:

Turn customer reviews into a one-line summary, like this example:

<example>
Review: "Arrived in two days, the colour is a bit darker than the photo but I love it."
Summary: Fast delivery; colour darker than pictured; very happy overall.
</example>

Review: "Took over a week and the box was damaged, but support sent a replacement quickly."

Use two or three varied examples if you want the model to pick up a pattern rather than copy one example too closely.

5. Separate instructions from material#

When you paste in a document, email or data, wrap it in tags and refer to it by name:

<email>
...the customer's email...
</email>

Draft a reply to the email above. Offer a refund or an exchange, and keep it under 120 words.

This stops the model from confusing your instructions with the text it’s working on.

6. Ask for the format you’ll use#

If the output goes straight into a spreadsheet or a program, say so:

Return only JSON with the fields "name", "email" and "topic".
"topic" must be one of: "order", "refund", "question", "other".

When you use a model through its API, many providers also offer structured output features that guarantee valid JSON, which is more reliable than asking in the prompt alone.

7. Let it say “I don’t know”#

Models try to be helpful, and without permission to say no, they may invent an answer. Add:

If the answer isn't in the information above, say you don't know.

This one line prevents many made-up answers.

8. Iterate#

Treat the first answer as a draft. If it’s too long, say “shorter”. If it misses the point, explain what you wanted and why. Once a prompt works well, save it as a template.

Prompts inside your own website or app#

When an AI feature is built into a site, the prompt is part of the code, and the same habits apply, with a few extras:

  • Put standing instructions in the system prompt: the role, the facts, the rules and the tone. The visitor’s message goes in separately.
  • Test with real inputs, including messy, rude and off-topic ones, before going live.
  • Keep the facts current. If prices change, the prompt needs updating, or better, load the facts from your CMS.
  • Don’t rely on the prompt for security. Visitors can try to talk the model into ignoring its rules, so anything that must never happen, such as revealing private data, should be prevented by your code.

For a working example, see how to add an AI assistant to a Wix site with Velo.

If you’d like an AI feature built for your site, I do AI integration.

Comments