AI Personal Learning
and practical guidance
Resource Recommendation 1

Anthropic Prompts Engineering Course - Appendix: Chained Prompts

academic program

As the saying goes, "Writing is rewriting." It has been proven that when asked, Claude can usually improve the accuracy of his answers!

There are many ways to tip Claude "Think Again". The same ways that allow people to naturally check their work usually apply to Claude. (For more examples of when and how to use cue chains, check out our Cue Chain Documentation).


typical example

In this example, we asked Claude to think of ten words ...... but one of them is not a real word.

Example 1:

Input:
Prompt
User: List ten words ending in "ab".

Output:
Claude's (incorrect) answer
Here are 10 words that end in "ab":
1. Cab
2. Dab
3. Fab
4. Gab
5. Jab
6. Lab
7. Nab
8. Slab
9. Tab
10. Zab

Having Claude provide a more accurate answer could fix the error!

Below we take Claude's incorrect response from above and replace it with a prompt that asks Claude to recheck his previous response.

Tip: Click on the cell and copy the text into a text editor to see the complete tip, especially in the replaced cell G22.

Example 2:

Input:
Hint template
{{CONVO_HISTORY}}
User: Please find all alternatives to "words" that are not actual words.
+
Older hints + Claude's incorrect answer
(from above) {{CONVO_HISTORY}}
User: List ten words that end with the letter "ab".
Helper: Here are 10 words that end in "ab":

1. Cab
2. Dab
3. Fab
4. Gab
5. Jab
6. Lab
7. Nab
8. Slab
9. Tab
10. Zab
=
Hints after substitution
User: List ten words that end with the letter "ab".
Helper: Here are 10 words ending in "ab":

1. Cab
2. Dab
3. Fab
4. Gab
5. Jab
6. Lab
7. Nab
8. Slab
9. Tab
10. Zab
User: Find all the alternatives to "words" that are not actual words.

Output:
New answer by Claude
Here are 10 actual words that end with the letter "ab":

1. Cab
2. Dab
3. Grab
4. Gab
5. Jab
6. Lab
7. Nab
8. Slab
9. Tab
10. Blab

But did Claude change the answer just because we told it to? What if we had provided the correct answer in the first place?Would Claude have lost his confidence as a result? Here we put a correct answer in the purple box and ask it to check again.

Example 3:

Input:
Hint template
{{CONVO_HISTORY}}
User: Please find all alternatives to "word" that are not actual words.
+
Hypothetical Claude responds correctly {{CONVO_HISTORY}}
User: List ten words that end with the exact letter "ab".
Helper: 1. Cab
1. Dab
2. Grab
3. Gab
4. Jab
5. Lab
6. Nab
7. Slab
8. Tab
9. Blab
=
Hints after substitution
User: List ten words that end with the exact letter "ab".
Helper: 1. Cab
2. Dab
3. Grab
4. Gab
5. Jab
6. Lab
7. Nab
8. Slab
9. Tab
10. Blab
User: Find all the alternatives to "word" that are not actual words.

Output:
New response from Claude
Here are 10 actual words that end with the letter "ab":

1. Cab
2. Dab
3. Grab
4. Gab
5. Jab
6. Lab
7. Nab
8. Slab
9. Tab
10. Blab

As it turns out, not really.Claude didn't waver from his correct answer in this case.

You can also have Claude improve its responses. Below is a version of the story where we first asked Claude to write a story and then improve it. Your personal preferences may vary, but many of you will probably agree that Claude's second version is better.

Example 4:

Input:
Prompt
User: Write a three-sentence short story about a girl who likes to run.

Output:
Claude's response (first version of the story)
This is a three sentence short story about a girl who likes to run:

Amelia loved to run. The wind blowing through her hair, the rhythmic feel of her feet, and the sense of freedom that running gave her was all she needed. As she raced through the park, all her worries dissipated and she felt incredibly fulfilled.

Example 5:

Input:
Prompt template
{{PAST_STORY}}
User: Make this story a little better.
+
Claude's previous story {{PAST_STORY}}
User: Write a three-sentence short story about a girl who likes to run.
Assistant: This is a three sentence short story about a girl who likes to run:

Amelia loved to run. The wind in her hair, the rhythm of her footsteps, and the sense of freedom that running gave her were all she needed. As she raced through the park, all her worries dissipated and she felt incredibly fulfilled.
=
Replaced Prompt
User: Write a three-sentence short story about a girl who likes to run.
Assistant: This is a three-sentence short story about a girl who likes to run:

Amelia loved to run. The wind in her hair, the rhythm of her footsteps, and the sense of freedom that running gives her are all she needs. As she raced through the park, all of her worries dissipated and she felt incredibly fulfilled.
User: Make this story a little better.

Output:
Claude's new story.
This is an improved three-sentence short story:

Amelia's feet pounded on the pavement, her heart racing along with the excitement. The world around her faded away, replaced by the steady rhythm of her breathing and the feel of the wind in her hair. With each step, her worries dissipated, replaced by a deep sense of relief and joy.

This form of substitution is very powerful. We've been using substitution placeholders to pass lists, words, Claude's previous replies, and more. You can also use substitution to perform what we call a "function call", where you ask Claude to perform some function, and then pass the result of that function to Claude for further processing. This is the same as any other substitution operation. More on this in the next appendix.

Here is an example of embedding the results of one call to Claude into another longer call.

Example 6:

Enter:
First prompt
User: Find all names from the text below:

"Hey Jesse. it's me, Erin. i'm calling about Joey's party tomorrow. keisha said she'd be there, and i think Mel will be too."
Helper: 
+
New prompt template ( from previous output)
User: This is a list of names:
{{NAMES}}
Please alphabetize this list.

Claude's first reply → {{NAMES}}
- Jesse
- Erin
- Joey
- Keisha
- Mel
</names
=
New prompt after replacement
User: This is a list of names:
- Jesse
- Erin
- Joey
- Keisha
- Mel

Please arrange this list alphabetically.

Output:
Claude's second reply
This is an alphabetical list of names:

<names
- Erin
- Jesse
- Joey
- Keisha
- Mel
Tools Download
May not be reproduced without permission:Chief AI Sharing Circle " Anthropic Prompts Engineering Course - Appendix: Chained Prompts

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish