Skip to content

Lesson 2 of 6

Give Claude a role, task and output format

Improve that prompt by telling Claude who it is, what to produce, and how to format the result, then test it on the same text.

5 minClaude, Gemini and ChatGPT

After this lesson you will be able to write a prompt that gives Claude a role, a clear task, and an output format, and you will see how these parts change the answer.

Why a plain prompt is not enough

In the first lesson you asked Claude to explain a short text. The answer was useful, but it depended on Claude guessing what you wanted. Claude does not know if you are a student, a developer, or a manager. It does not know if you want one sentence or five paragraphs. When you give Claude a role, a task, and an output format, you remove the guesswork and get a more useful answer.

The three parts of a strong prompt

A strong prompt has three parts. First, tell Claude who it is. This is the role. For example, you can say 'You are a patient teacher who explains technical ideas to beginners.' Second, tell Claude what to do. This is the task. For example, 'Explain the text below in simple words.' Third, tell Claude how to format the answer. This is the output format. For example, 'Write three bullet points. Each bullet point must be one sentence.'

You can put these parts in any order, but it helps to keep them separate. Use a blank line between the role, the task, and the output format. This makes the prompt easy to read and easy to change.

Write an improved prompt

Start with the same short text from the first lesson. Open Claude chat in your browser. Copy the text into the chat, then write a prompt that includes a role, a task, and an output format. Here is an example:

You are a patient teacher who explains technical ideas to beginners.

Explain the text below in simple words.

Write three bullet points. Each bullet point must be one sentence.

Text:
Pandas is a Python library for working with data. It provides two main data structures: Series for one-dimensional data and DataFrame for two-dimensional data. You can use Pandas to read data from CSV files, clean it, and analyse it.

Read the answer. It should be three bullet points, each one sentence, and it should use simple words. If the answer is not what you expected, change one part of the prompt and run it again. For example, change the role to 'You are an expert Python developer who writes for other developers.' See how the answer changes.

Test the output format

The output format is the part that most often goes wrong. Claude may ignore it if the task is not clear. To test the format, ask for something very specific. For example, change the output format to 'Write exactly two sentences. The first sentence must start with the word Pandas. The second sentence must start with the word You.' Run the prompt and check that the answer follows the rule.

You are a patient teacher who explains technical ideas to beginners.

Explain the text below in simple words.

Write exactly two sentences. The first sentence must start with the word Pandas. The second sentence must start with the word You.

Text:
Pandas is a Python library for working with data. It provides two main data structures: Series for one-dimensional data and DataFrame for two-dimensional data. You can use Pandas to read data from CSV files, clean it, and analyse it.

If the answer does not follow the rule, make the rule more explicit. For example, say 'Do not write more than two sentences.' Claude usually follows a clear, simple rule.

Keep a prompt you can reuse

You will use this improved prompt again in the next lesson, where you store it in a Project. For now, save the prompt in a text file on your computer. Name the file prompt.txt. Put the role, task, and output format in the file, but leave out the text. Here is an example of what prompt.txt could contain:

You are a patient teacher who explains technical ideas to beginners.

Explain the text below in simple words.

Write three bullet points. Each bullet point must be one sentence.

Text:

This file deliberately has no text after Text:. When you want to use the prompt, open the file, copy the prompt, and paste it into Claude chat. Then add the text you want explained after Text:.

Summary

A strong prompt has a role, a task, and an output format. The role tells Claude who it is. The task tells Claude what to do. The output format tells Claude how to structure the answer. Test each part by changing one thing at a time. Save your prompt in a file so you can reuse it.

Key takeaways

  • A strong prompt has three parts: role, task, and output format.
  • The role tells Claude who it is, such as a teacher or a developer.
  • The task tells Claude what to do, such as explain or summarise.
  • The output format tells Claude how to structure the answer, such as bullet points or a number of sentences.
  • Test one part of the prompt at a time to see how it changes the answer.

Try it

Take the prompt you saved in prompt.txt and copy it into Claude chat. Add the Pandas text from this lesson after Text:, then change the output format to 'Write a single paragraph of no more than 50 words.' Run the prompt. Check that the answer is one paragraph and that it has 50 words or fewer. If it does not, adjust the output format instruction and run it again. A good result is a paragraph that explains the text in simple words and stays within the word limit.

Official documentation

Ready to use this in a job?

Rolebound applies to matching roles for you.

Start now

Written with AI and checked automatically. Tools change, so a command may behave differently in the version you install. Spotted a mistake? Tell us.

    Cookies on Rolebound

    We use necessary cookies to sign you in and keep the site working — those cannot be turned off. We would also like to set analytics and advertising cookies so we can see which pages help people get interviews and which adverts brought them here. Nothing optional is set unless you say yes, and you can change your mind at any time from “Cookie settings” in the footer. Read our Privacy Policy.