SproutStackSproutStack home

Anatomy of an Effective Prompt

6 min readBeginner-friendlyFree to read

Read a little, play a little. No scary maths, and no rush.

Share:

A template you can steal

Most good prompts share the same skeleton. Memorize it once, reuse it forever:

Role: Senior support agent for Acme returns.
Task: Answer the user's question using ONLY the context.
Context:
[1] Electronics: 30-day returns with receipt.
[2] Final-sale items are never returnable.
Constraints: Never invent policy. If missing, say NOT FOUND.
Format: 2 bullets max, cite like [1].

Each line earns its place. Delete one and watch reliability drop — that's how you learn what each clause does.

Why each part matters

  • Role primes vocabulary and posture ("support agent" answers differently than "poet").
  • Task states the job in one verb-forward sentence — vague tasks get vague answers.
  • Context is the evidence; numbered chunks enable citations.
  • Constraints are testable rules ("under 100 words" beats "be concise" because you can check it).
  • Format removes parsing pain downstream: bullets, JSON, tables — pick one, demand it.

One skeleton, three jobs

The same five parts adapt to very different tasks. Only the content of each line changes.

  • Classification. Role: triage assistant. Task: label the message. Context: the message. Constraints: choose exactly one of billing, technical, account, other. Format: {"label": "..."}.
  • Extraction. Role: data entry assistant. Task: pull the order number and requested action. Context: the email. Constraints: use null for anything not stated. Format: JSON with those two fields.
  • Writing. Role: support agent with a warm, plain tone. Task: draft a reply. Context: the customer's message and the relevant policy chunks. Constraints: under 120 words, no promises the policy does not make. Format: a short paragraph plus one next step.

Where each part goes

Chat APIs give you two places to write: the system message and the user message. A good split is to put the stable parts (role, standing constraints, format) in the system message and the per-request parts (task details, context, the question) in the user message. The stable part then stays identical across calls, which keeps behavior consistent and makes changes easy to review.

When the context is long, such as several pages of retrieved text, it often helps to restate the key instruction or question after the context, so the last thing the model reads is what you want it to do.

Fence off the data

Wrap pasted material in clear markers, such as <context> ... </context> tags or a line of ###, and say so in the instructions: "Answer using the text inside the context tags." Clear boundaries help the model tell your instructions apart from the content it is reading. That separation is also the first line of defense against text that tries to slip in instructions of its own, the subject of the prompt injection chapter.

Version prompts like code

Save every version, A/B against your eval set, review diffs. "It feels better" is not a measurement — pass rates are. Prompts are the cheapest code you'll ever ship and the easiest to break accidentally.

A quick check before shipping

Read the prompt as if you were the model, with no knowledge of your project. Could you do the job from this text alone? Is every constraint something a test could verify? Does it say what to do when the answer is not in the context? If any answer is no, fix that line before measuring anything else.

Remember this

  • Role → task → context → constraints → format. Same order, every time.
  • Constraints must be checkable; formats must be parseable.

Check your understanding

5 questions · first-try answers earn the most XP

1. What is the reusable order this chapter's template follows?
2. Why is "under 100 words" a better constraint than "be concise"?
3. Why does the template number the context chunks, like [1], [2]?
4. What does the chapter mean by "delete one line and watch reliability drop"?
5. Why does the chapter call a prompt "the cheapest code you will ever ship"?

My notes

Saved in this browser. Highlight a line above and save it, or write it in your own words.

Nothing saved yet. Your highlights will live here.

References

Finished reading?

Ticking it here also ticks the chapter in the sidebar, the section count and your streak — it is all one number.

Related chapters

Spotted a mistake or want a topic covered? Report an issue

📬 An occasional email when new lessons land

New lessons and showdowns, no more than a few times a month. No spam, unsubscribe anytime. We store your email only to send the newsletter.