Skip to content
Text prompts

How to Structure a Text Prompt

The five parts of a good prompt (role, context, task, format, and constraints), with ready-to-copy examples you can adapt to your own case.

Rodrigo Faustino ·

Call number
TXT-001
Level
Beginner
Reading
7 min
Published
Labs
Prompt anatomy, Before and after

A good prompt tells the AI who it should be, what’s going on, what to do, how to deliver it, and what to avoid. That makes five parts: role, context, task, format, and constraints. You don’t need all of them every time, but knowing they exist improves the quality of the answer right from your first request.

Why AI Needs More Than One Sentence

Think about asking a favor of a coworker who just joined the company. If all you say is “help me with the meeting,” they’ll have questions: which meeting, help with what, by when? Most of the time, the AI doesn’t ask those questions. It fills in the gaps with its most likely guess, and the most likely guess tends to be generic.

The documentation from Anthropic, the company that makes Claude, suggests a simple test: show your prompt to someone who knows nothing about the subject. If that person would be confused, the AI will be too.

Five stacked colored bands, one for each part of the prompt: role, context, task, format, and constraints, each with a sample sentence
A complete prompt for creating math exercises, part by part.

The Five Parts, One at a Time

Role. This tells the AI what point of view to answer from. “You are a high school math teacher” pulls in different vocabulary, tone, and examples than “you are a research mathematician.” One sentence is enough.

Context. This is what you know and the AI doesn’t: who will read it, why you’re asking, what you’ve already tried. Explaining the reason behind an instruction helps the AI get even the details you didn’t ask about right.

Task. The request itself, with a clear verb: summarize, compare, create, review, explain. One task per prompt works better than three tasks mixed together.

Format. How the answer should arrive: a numbered list, a table, short paragraphs, a ready-to-send email. If you’re going to paste the result somewhere else, say where.

Constraints. Length, what to avoid, and what’s required. Say what to do rather than what not to do: “write in paragraphs” works better than “don’t use lists.”

Try Building a Prompt

In the lab below, switch each part on and off and watch the prompt change. Then click “Edit texts” and swap the example for your own case.

LabBuild Your PromptTry it

Assembled prompt

RoleYou are a high school math teacher.ContextMy 9th-grade students often get adding fractions with negative signs wrong.TaskCreate 5 exercises on adding negative fractions, from easiest to hardest.FormatNumber the exercises and put the annotated answer key at the end.LimitsUse numbers up to 20 and no decimals.
  • Role The point of view the AI answers from.
  • Context What you know and the AI doesn't: audience, reason, situation.
  • Task The request itself, with a clear verb.
  • Format How the answer should arrive: list, table, email...
  • Limits Length, what to avoid, and what is required.
Open this lab on its own page →
What to notice: Turn off the context and the format: what's left is the kind of request that produces generic answers.

Notice that the task alone fits on one line. The other parts are what make the answer useful to you.

In Practice

Here’s a common request written two ways. First, the way almost everyone does it:

Summarize this meeting.

Now with all five parts:

You are an assistant to a sales manager.

Context: below are my notes from a 40-minute meeting with the team.
I'm going to send the summary to the people who missed it.

Task: summarize the meeting.

Format: two sections, "Decisions" and "Action Items." Under "Action
Items," say who does what and by when.

Constraints: 10 lines at most. If anything in the notes is ambiguous,
mark it with (confirm).

<notes>
paste your notes here
</notes>

See what changes in the result. The answers below were written to show the typical difference, not generated by a model.

LabBefore and AfterTry it

Illustrative data Answers written to show the difference, not generated by a model.

Before

Prompt

Summarize this meeting.

Answer

The meeting covered sales, goals, and the team's next steps. Several important points were discussed, and the team committed to improving results over the coming weeks.

After

Prompt

You are a sales manager's assistant. Context: these are my notes from a 40-minute meeting; I'll send the summary to the people who missed it. Summarize the meeting. Format: two sections, "Decisions" and "Tasks," saying who does what and by when. Limits: at most 10 lines; mark anything ambiguous with (confirm).

Answer

Decisions • December goal kept at 120 contracts. • Visits to existing clients move to Tuesdays. Tasks • Ana: review the price table by Friday. • Bruno: call the 15 inactive clients by the 10th. • Carla: prepare the weekly report (confirm the format).

What changed

  • Gained a role: the AI knows who it's working for.
  • Gained context: the AI knows the summary is for people who missed the meeting.
  • Asked for a format: decisions separated from tasks, with owners and deadlines.
  • Set limits: maximum length and what to do with doubts.
Open this lab on its own page →
What to notice: The answer on the right comes out already split into decisions and action items, with names and deadlines.

Look at the end of the strong prompt: the notes sit between tags, <notes> and </notes>. Separating your text from the instructions keeps the AI from confusing one with the other, especially when the text is long.

Side-by-side comparison: on the left, the weak prompt Help me with the meeting and the questions the AI has to guess at; on the right, the strong prompt divided into five colored bands
The strong prompt answers the questions before they come up.

A Template to Copy

Keep this skeleton and fill it in as needed. Delete any lines you don’t need.

You are [role].

Context: [who will read it, what it's for, what I already know].

Task: [verb + what to do].

Format: [list, table, paragraphs, email...].

Constraints: [length, what to avoid, what's required].

Common Mistakes and How to Avoid Them

The most frequent mistake is stopping at the task. “Write a post about healthy eating” produces text that could be on any website. Add the audience and the goal, and the text becomes yours.

The second is asking only for what not to do. AI understands a positive instruction better. Instead of “don’t be too formal,” say “write like a conversation between coworkers.”

The third is not giving an example when the format matters. If you want the answers in an exact pattern, show a finished example. Anthropic’s documentation recommends three to five varied examples when the format is critical.

Four cards showing common prompt mistakes: a vague request, no audience, only what not to do, and everything mixed together, each with the fix that solves it
Small swaps that improve the answer.

Finally, remember that the first answer is rarely the last one. Read it, say what’s missing, and ask again. A good prompt is the start of a conversation, not a magic spell.

Keep Reading

References

  1. Anthropic. Prompting best practices. Consultado em Nov 28, 2026.
  2. Anthropic. Prompt engineering overview. Consultado em Nov 28, 2026.