Anthropic’s prompt optimizer turns short prompts into detailed templates



To speed up prompt engineering, Anthropic provides a smart tool that generates detailed prompt templates from short task descriptions.

A long and detailed prompt has a major influence on the output quality of a language model. But in addition to the content, formatting also plays a role.

Anthropic has released a useful tool that enhances short prompts and wraps them in the markup language optimized for Claude using XML tags (<tag>prompt part</tag>).

The end result is a prompt template for a specific type of task, such as finding a marketing strategy. However, the tool also extracts the variable content, such as the topic, so that the template can be quickly reused for different cases. The template can be used in Claude and other capable language models such as GPT-4.



Here is a sample output for the “Create a Marketing Strategy” task, which includes variables for product description, target audience, and company goals, as well as a five-step guide:




Your task is to develop a comprehensive marketing strategy for a product. To create an effective plan, you will need to carefully consider the product itself, the target audience, and the company’s overall goals.

First, please provide a detailed description of the product you will be marketing:


Next, describe the target audience for this product:


Finally, outline the key goals the company hopes to achieve with this marketing strategy:


Now that you have this key information, follow these steps to build out the marketing strategy:

1. analyze the product and identify its unique selling points and benefits to the target audience. Consider how it stands out from competitors.

2. brainstorm various marketing channels and tactics that would be effective for reaching the target audience. Think about their media consumption habits, interests, and pain points.

3. develop key messaging and positioning that highlights the product’s benefits and resonates with the target audience. Ensure it aligns with the company’s brand voice.

4. create a mix of marketing tactics that will effectively reach the audience at different stages of the buyer’s journey. Consider awareness-building, consideration, and conversion.

5. identify key metrics to measure the success of the marketing strategy and how it will support the company’s overarching goals.

First, brainstorm some initial ideas in a <brainstorming> section. Then, synthesize your analysis into a cohesive marketing strategy in a <strategy> section. The strategy should be thorough yet concise.

Remember, the ultimate goal is to create a marketing plan that effectively reaches the target audience, communicates the product’s value, and supports the company’s objectives. Be creative, targeted, and strategic in your approach.

In its current form, the Prompt Optimizer is a somewhat cumbersome Google Colab notebook that runs the short user input through a long few-shot prompt with some examples.

Colab notebooks like this are a mixture of descriptive text and Python code snippets that can be executed separately. In the last code snippet you can try out the generated prompt and you will be asked for your desired variables.


  • Before using the notebook, you must create a copy in Google Colab via File > Save copy in Google Drive.
  • You also need an API key from Anthropic, which you can generate via Remember to save the key, as it is only displayed once.
  • Before using the API, ensure that your account is funded. Anthropic provides five US dollars to users for experimentation after confirming their mobile number.

How to use

To use the Prompt Optimizer, simply describe the task in a few words in the first code section of TASK under Quickstart. You can also include variables in this section, such as the subject and length of a blog post or the tone and content of an email. If you don’t include variables, the Prompt Optimizer will generate them automatically.

The Prompt Optimizer takes short tasks and optimizes them for Claude. For example, it can turn ‘Build a marketing strategy’ into a comprehensive description.

Now that you have taken all the necessary precautions, you are ready to run the code. To begin, use the play button on the left and proceed through the sections from top to bottom. For faster execution, collapse the entire Quickstart chapter and execute the code snippets in one go.


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top