Notebooks
A
Anthropic
02 Being Clear And Direct

02 Being Clear And Direct

prompt_engineering_interactive_tutorialAnthropic 1Panthropic-courses

Chapter 2: Being Clear and Direct

Setup

Run the following setup cell to load your API key and establish the get_completion helper function.

[ ]

Lesson

Claude responds best to clear and direct instructions.

Think of Claude like any other human that is new to the job. Claude has no context on what to do aside from what you literally tell it. Just as when you instruct a human for the first time on a task, the more you explain exactly what you want in a straightforward manner to Claude, the better and more accurate Claude's response will be."

When in doubt, follow the Golden Rule of Clear Prompting:

  • Show your prompt to a colleague or friend and have them follow the instructions themselves to see if they can produce the result you want. If they're confused, Claude's confused.

Examples

Let's take a task like writing poetry. (Ignore any syllable mismatch - LLMs aren't great at counting syllables yet.)

[ ]

This haiku is nice enough, but users may want Claude to go directly into the poem without the "Here is a haiku" preamble.

How do we achieve that? We ask for it!

[ ]

Here's another example. Let's ask Claude who's the best basketball player of all time. You can see below that while Claude lists a few names, it doesn't respond with a definitive "best".

[ ]

Can we get Claude to make up its mind and decide on a best player? Yes! Just ask!

[ ]

If you would like to experiment with the lesson prompts without changing any content above, scroll all the way to the bottom of the lesson notebook to visit the Example Playground.

Exercise 2.1 - Spanish

Modify the SYSTEM_PROMPT to make Claude output its answer in Spanish.

[ ]

❓ If you want a hint, run the cell below!

[ ]

Exercise 2.2 - One Player Only

Modify the PROMPT so that Claude doesn't equivocate at all and responds with ONLY the name of one specific player, with no other words or punctuation.

[ ]

❓ If you want a hint, run the cell below!

[ ]

Exercise 2.3 - Write a Story

Modify the PROMPT so that Claude responds with as long a response as you can muster. If your answer is over 800 words, Claude's response will be graded as correct.

[ ]

❓ If you want a hint, run the cell below!

[ ]

Congrats!

If you've solved all exercises up until this point, you're ready to move to the next chapter. Happy prompting!


Example Playground

This is an area for you to experiment freely with the prompt examples shown in this lesson and tweak prompts to see how it may affect Claude's responses.

[ ]
[ ]
[ ]
[ ]