How to Write a Good Prompt

An abstract question box with model chips and a coral ask button

A good prompt is not a magic phrase. It is a short brief. It tells the model what job to do, for whom, under what constraints, and in what shape. This guide shows the structure, then puts three vague prompts and their rewritten versions through the same model families so you can see what changes.

Try it

Give me three tips for sleeping better if I wake at 4am most nights and cannot get back to sleep.

Try this question

The four parts of a working prompt

Task

One verb. Write, summarize, compare, explain, list, rewrite, critique. If your prompt contains two verbs, it is two prompts.

Context

The facts the model cannot guess. Who it is for, what you already tried, what the situation is. This is where nearly all of the improvement comes from.

Constraints

Budget, length, tone, what to avoid, what must be included. Constraints are how you stop a model from producing the most average possible answer.

Format

Bullets, a table, two sentences, a numbered plan, an email. Say it explicitly. Format instructions are followed reliably by every family we run.

Before and after, three times

Each pair below went to the same families on this site. Nothing changed except the wording of the question.

Pair one: a trip

Real run on this site4 September 2026

tips for my trip

DeepSeek

8.9 s ✓
first words 1.6 s · 395 words

Qwen

10.8 s ✓
first words 2.0 s · 437 words

GLM

28.8 s ✓
first words 23.4 s · 190 words
Before: "tips for my trip". Four sentences of context short of being useful. Read the full answers in How to Ask AI a Question (and Get a Useful Answer).
Real run on this site4 September 2026

I have three days in Lisbon in October with two teenagers and a budget of 400 euros for activities. Suggest a day-by-day plan with walking distances.

DeepSeek

40.1 s ✓
first words 0.4 s · 524 words (answer reached its length limit)

Qwen

10.5 s ✓
first words 1.6 s · 503 words (answer reached its length limit)

MiniMax

28.1 s ✓
first words 23.8 s · 203 words (answer reached its length limit)
After: place, dates, who is coming, a budget and a format. Every family answered, and the answers turned into plans. Read the full answers in How to Ask AI a Question (and Get a Useful Answer).

Pair two: sleep advice

Real run on this site4 September 2026

Give me three tips for sleeping better.

DeepSeek

4.2 s ✓
first words 0.6 s · 130 words

Qwen

3.5 s ✓
first words 1.5 s · 151 words

GLM

no answer
this model did not reply

MiniMax

1.4 s ✓
first words 0.5 s · 126 words

GPT-OSS

1.6 s ✓
first words 0.5 s · 112 words
Before: "Give me three tips for sleeping better." Every family produces the same three or four well-known tips. Read the full answers in AI Model Comparison Chart.
Real run on this site4 September 2026

Give me three tips for sleeping better if I wake at 4am most nights and cannot get back to sleep.

DeepSeek

6.7 s ✓
first words 0.8 s · 173 words
  1. Get out of bed after 15–20 minutes. Lying there frustrated trains your brain to associate bed with wakefulness. Go to a dimly lit room, do something boring (read a paper book, fold laundry), and return to bed only when you feel sleepy again. Repeat as needed.
  1. Shift your wake-up time earlier and get bright light immediately. If you consistently wake at 4am, your circadian rhythm may be set too early. Wake up at that time, get 10–15 minutes of bright outdoor light (or a 10,000 lux lamp) within the first hour, and push your bedtime later in 15-minute increments every few days to reset your sleep window.
  1. Do a "worry dump" before bed and use a 4am rule. Write down every nagging thought, task, or worry 1–2 hours before sleep, then close the notebook. If you wake at 4am, tell yourself: "I will not solve this now—I’ll revisit it at 7am." This breaks the rumination loop that keeps you awake. Also avoid checking the clock; turn it away from view.

Qwen

5.5 s ✓
first words 1.4 s · 300 words (answer reached its length limit)

Waking up at 4 AM and struggling to return to sleep is often a sign of "sleep maintenance insomnia," which can be driven by stress, blood sugar fluctuations, or circadian rhythm misalignment. Here are three targeted tips to help you stay asleep:

1. Break the "Clock-Watching" Anxiety Loop

The moment you see it’s 4 AM, your brain may trigger a stress response ("I only have X hours left"), releasing cortisol that makes falling back asleep nearly impossible.

  • Hide the clock: Turn your alarm clock away from your bed and remove phones from arm’s reach. If you don’t know what time it is, you can’t judge yourself for being awake.
  • Use the 20-minute rule: If you’ve been lying there for more than 20 minutes (estimated, not checked), get out of bed. Go to another dimly lit room and do something boring and non-stimulating (like reading a paper book or listening to soft music) until you feel sleepy again. This prevents your brain from associating your bed with wakefulness.

2. Stabilize Blood Sugar Before Bed

A drop in blood sugar during the night can trigger a release of adrenaline and cortisol, which wakes you up abruptly. This is common if you eat dinner early or consume high-carb/sugary foods before bed.

  • Try a bedtime snack: Eat a small snack containing protein and healthy fat about an hour before bed. Examples include a handful of almonds, a spoonful of nut butter, or a small piece of cheese. This helps keep blood sugar stable through the night.
  • Avoid alcohol as a sleep aid: While alcohol may help you fall asleep initially, it metabolizes quickly and causes rebound alertness around 3–4 AM, fragmenting your second half of sleep.

3. Shift Your Circadian Rhythm with Light Exposure

If you consistently

GLM

no answer
this model did not reply

MiniMax

3.1 s ✓
first words 1.5 s · 182 words (answer reached its length limit)

Three Tips for Early Morning Awakenings

1. Get out of bed after 15–20 minutes. Lying in bed awake trains your brain to associate the bed with wakefulness. Get up, sit in dim light, and do something boring (read a dull book, fold laundry) until sleepiness returns. Avoid screens and bright lights, which signal your brain that it's time to be awake.

2. Move anxious thoughts out of your head before bed. Waking at 4am often coincides with rumination. Keep a notebook by your bed and write down anything looping in your mind—tomorrow's tasks, worries, random ideas—a few hours before sleep. This gives your brain permission to "let go" of those items, and they are safely stored if they resurface at 4am.

3. Re-examine your evening routine. Common culprits include:

  • Alcohol within 3 hours of bed (it fragments sleep later in the night)
  • Late caffeine (half-life is 5–6 hours)
  • A bedroom that's too warm (aim for 65–68°F / 18–20°C)
  • Eating a large meal close to bedtime

If the problem persists for more than a few weeks, mention it

GPT-OSS

1.6 s ✓
first words 0.5 s · 194 words

1. Create a “Wake‑Up Ritual”

  • Set a fixed wake‑up time: Even if you’re still awake, tell your body that this is the new bedtime.
  • Do a calming activity: Read a short book, practice a few gentle stretches, or do a quick breathing exercise in dim light.
  • Avoid screens: The blue light will trick your brain into thinking it’s still daytime.

2. Make the Environment Sleep‑Friendly

  • Darken the room: Use blackout curtains or an eye mask.
  • Cool it down: Aim for 60‑67°F (15‑19°C); a cooler room signals the body to drop its core temperature.
  • Use white‑noise or a fan: A steady, low‑volume sound can mask sudden noises that might wake you again.

3. Practice Relaxation Techniques

  • Progressive muscle relaxation: Tense each muscle group for 5 seconds, then release.
  • Controlled breathing: Inhale for 4 counts, hold 4, exhale for 6, repeat.
  • Mental “to‑do” list: Write down one task you’ll handle the next day. This reduces worry and lets your mind wind down.

Try to keep a consistent routine over a few weeks; your body will adjust and you’ll find it easier to stay asleep.

After: the same request with the actual problem in it. The advice narrows to the specific pattern described.

Pair three: code

Real run on this site4 September 2026

write a function

DeepSeek

1.1 s ✓
first words 0.6 s · 55 words

Qwen

2.4 s ✓
first words 0.9 s · 94 words

GLM

no answer
this model did not reply

MiniMax

1.6 s ✓
first words 0.8 s · 85 words

GPT-OSS

1.4 s ✓
first words 0.7 s · 71 words
Before: "write a function". With nothing to go on, each family invents a different task for itself.
Real run on this site4 September 2026

Write a Python function that returns the two numbers in a list that add up to a target.

DeepSeek

1.0 s ✓
first words 0.4 s · 35 words

def two_sum(nums, target): seen = {} for i, num in enumerate(nums): complement = target – num if complement in seen: return [seen[complement], i] seen[num] = i return [] # or raise ValueError if you prefer

Qwen

2.0 s ✓
first words 1.6 s · 30 words
def two_sum(nums, target):
 seen = {}
 for i, num in enumerate(nums):
 complement = target - num
 if complement in seen:
 return [seen[complement], i]
 seen[num] = i
 return []

GLM

21.2 s ✓
first words 5.4 s · 208 words
def two_sum(nums, target):
 seen = set()
 for num in nums:
 complement = target - num
 if complement in seen:
 return [complement, num]
 seen.add(num)
 return None

Example:

nums = [2, 7, 11, 15]
print(two_sum(nums, 9)) # [2, 7]
print(two_sum(nums, 30)) # None

How it works:

  • For each number, compute the complement (target minus the current number).
  • If the complement was already seen earlier in the list, you've found the pair.
  • Otherwise, add the current number to the set and keep going.

This runs in O(n) time and O(n) space, and returns None if no pair exists.

If you need the positions instead of the values, use a dict that maps each value to its index:

def two_sum_indices(nums, target):
 seen = {}
 for i, num in enumerate(nums):
 complement = target - num
 if complement in seen:
 return [seen[complement], i]
 seen[num] = i
 return None

Note: both versions assume at most one valid pair and that no number is paired with itself (e.g., target 10 with a single 5 in the list won't match). If duplicates like [5, 5] with target 10 should count, the dict version handles that correctly since the first 5 is stored before the second one is checked.

MiniMax

3.7 s ✓
first words 0.6 s · 222 words

Here's a Python function that finds two numbers in a list that add up to a target:

def two_sum(nums, target):
 seen = {}
 for i, num in enumerate(nums):
 complement = target - num
 if complement in seen:
 return [seen[complement], i]
 seen[num] = i
 return []

How it works:

  • Walk through the list once, keeping a dictionary of numbers you've seen and their indices.
  • For each number, compute the value it would need to pair with (target - num).
  • If that complement is already in the dictionary, you've found your pair and return both indices.
  • Otherwise, store the current number and its index, then continue.

Example usage:

print(two_sum([2, 7, 11, 15], 9)) # [0, 1] (2 + 7 = 9)
print(two_sum([3, 2, 4], 6)) # [1, 2] (2 + 4 = 6)
print(two_sum([1, 2, 3], 10)) # [] (no pair found)

Why this approach:

  • Time complexity: O(n) — one pass through the list.
  • Space complexity: O(n) — the dictionary holds at most one entry per element.

If you need the actual values instead of indices, swap the dictionary to store the number itself and return the pair:

def two_sum_values(nums, target):
 seen = set()
 for num in nums:
 if target - num in seen:
 return [target - num, num]
 seen.add(num)
 return []

GPT-OSS

2.6 s ✓
first words 1.2 s · 103 words
def find_pair(nums, target):
 """
 Return the two numbers from `nums` that sum to `target`.
 If no such pair exists, return None.
 """
 seen = {}
 for n in nums:
 complement = target - n
 if complement in seen:
 return [complement, n] # or [n, complement]
 seen[n] = True
 return None


# Example usage
sample = [2, 7, 11, 15]
print(find_pair(sample, 9)) # → [2, 7]
print(find_pair(sample, 13)) # → None

This function scans the list once, storing each number in a dictionary. For every new number it checks whether the needed complement is already in the dictionary, giving a linear‑time solution.

After: language, inputs, outputs and the exact behavior. Now the answers can be compared to each other, because they are answering the same question.

What the pairs have in common

In all three, the vague version produced fluent text that nobody asked for. The specific version produced something you could act on or reject. The models did not get smarter. They stopped having to guess.

Note also the length. Specific prompts often produce shorter answers, because the model no longer needs to cover every case it can imagine.

Techniques worth using

  • Give an example of what you want. One example of the output shape beats three paragraphs of description.
  • Name the audience, not a persona. “For a new apprentice” works better than “act as a senior engineer”.
  • Ask for the reasoning separately. “Give the answer, then the three assumptions behind it.”
  • Set a limit. “In under 120 words” is a real instruction and it is obeyed.
  • Say what to exclude. “No introductions, no summary at the end.”
  • Ask for alternatives. “Give me the safe option and the ambitious one.”

Techniques that do less than people think

  • “Take a deep breath.” Encouragement is not a lever on a text predictor.
  • Threats and rewards. “This is very important to my career” changes nothing you can measure.
  • “Be accurate and do not hallucinate.” A model cannot detect its own invention. Verification is the only fix; our accuracy page explains why.
  • Very long system-style preambles. Past a point they dilute the actual request.

Iterate in the follow-up, not the rewrite

When an answer is close but wrong, do not rewrite the original prompt. Reply to it. “Shorter.” “Assume I already have the account.” “Give me the version for a rental, not a purchase.” Each follow-up keeps everything the model already got right.

On the home page a follow-up goes to every family with its own earlier answer attached, so you can watch several drafts improve in parallel. On the compare page all five answer at once, which is the fastest way to see whether a rewrite helped.