new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Prompt Engineering · all subjects

chaining

9 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Claude improves accuracy when asked to double-check responses

Claude can often improve the accuracy of its response when explicitly asked to do so. Ways that feel natural to ask a human to double-check their work will generally work for Claude as well.

Multi-turn conversation structure for prompt chaining

Prompt chaining uses multi-turn conversations where the messages array contains alternating user and assistant roles. The first message has role 'user' with the initial prompt, followed by role 'assistant' with Claude's previous response, then role 'user' with a follow-up request. This structure allows passing Claude's previous output into subsequent prompts.

Give Claude an out to prevent unnecessary revisions

When asking Claude to revise its work, include explicit permission to leave the response unchanged if it is already correct. For example, instead of 'Please find replacements for all words that are not real words,' use 'Please find replacements for all words that are not real words. If all the words are real words, return the original list.' This reduces Claude's tendency to make changes even when the original answer is correct.

Use prompt chaining to improve response quality iteratively

Prompt chaining can be used to ask Claude to improve or refine its previous responses. After Claude generates an initial response, a follow-up prompt can ask it to enhance the response in ways such as making it better, more detailed, or better formatted.

Substitute Claude's previous output into follow-up prompts

In prompt chaining, store Claude's response from one API call and include it in the assistant role of the messages array for the next call. This allows you to reference and build upon Claude's previous work. Variables can be used to pass lists, words, Claude's former responses, and other results into subsequent prompts.

Example: Chaining prompts to find and alphabetize names

First prompt finds all names from text using a prefill: first_user asks to find names from a text snippet, with prefill = '<names>'. The messages array contains the user message and assistant prefill. Claude completes this and returns a list of names. Second prompt alphabetizes the result: second_user = 'Alphabetize the list.' The messages array chains all previous turns plus the new request, using prefill + '\n' + first_response as the assistant's previous content. This demonstrates passing one prompt's output directly into the next prompt's input.

Example: Chaining prompts to create and improve a story

First prompt: first_user = 'Write a three-sentence short story about a girl who likes to run.' Messages array contains one user message. Claude generates first_response. Second prompt improves the story: second_user = 'Make the story better.' Messages array chains the original user message, Claude's first_response as assistant content, and the new second_user request. Claude then generates an improved version of the story.

Example: Chaining prompts to validate and correct word list

First prompt: first_user = 'Name ten words that all end with the exact letters \'ab\'.' Second prompt asks Claude to review: second_user = 'Please find replacements for all \'words\' that are not real words. If all the words are real words, return the original list.' The messages array chains the initial request, Claude's response, and the validation request. This demonstrates error correction and the importance of giving Claude permission to leave correct answers unchanged.

Prompt chaining enables function-like behavior

You can use prompt chaining to ask Claude to perform a function (such as extracting data or processing information) and then take the results of that function and ask Claude to do additional work with those results. This is similar to traditional function calling patterns where output from one step becomes input to the next.

Give your agent this brain