Table of Contents

What is “Prompt Engineering”?

Prompt Engineering” is the practice of crafting clear, structured instructions (prompts) to guide AI models towards producing your desired output. Think of it as learning how to communicate effectively with an AI assistant to get better, more accurate results.

What makes a good prompt?

A good prompt will be clear and concise. It will provide relevant background context, describe the action you want it to take, state the format you want the response to be in, and will often contain examples or references.

One of my favourite quotes was from Anthropic's Amanda Askell. Here's a rough paraphrasing of what she said:

Imagine you've hired a temporary worker for a task.
They're skilled and knowledgeable about your industry, but they've just arrived and know nothing about your specific situation.
They ask, “I'm here to help - what would you like me to do?”
What instructions would you give this person to get the job done correctly?

What is a useful prompt structure?

To help remember this we can use the mnemonic “CAFE”:
Context
Action
Format
Examples

Remember, once you have a response you can iterate on the output with the AI Assistant.

CAFE Framework

Let's go through each of the elements of the CAFE framework. The order of the elements doesn't matter. The important things are clarity and simplicity: prompts should be clear and concise, using normal, natural language and sticking to relevant information.

Context

Provide background information relevant to the action you want the AI Assistant to perform.

This could include context such as the intended audience, your skills, where you are located, or what equipment you have access to.

Bad Example

Make a dinner party menu.

Better Example

I am hosting a Saturday evening dinner party for 12 people. I would like to prepare as much as possible in advance so I have time to socialise. Make a dinner party menu.

Action

Describe in detail the action you want to be completed by the AI Assistant.

Action Verbs

Use action verbs to describe the task you want completing. For example:

  • Act
  • Analyse
  • Categorise
  • Classify
  • Contrast
  • Compare
  • Create
  • Describe
  • Define
  • Evaluate
  • Extract
  • Find
  • Generate
  • Identify
  • List
  • Measure
  • Organise
  • Pick
  • Predict
  • Provide
  • Rank
  • Recommend
  • Rewrite
  • Select
  • Sort
  • Summarise
  • Translate
  • Write

Provide positive criteria over negative constraints

As a general rule, tell the AI Assistant what to do rather than what not to do. That is to say, focus on positive criteria rather than negative constraints.

Bad Example

I need a dinner party menu. Don't include meat, fish, eggs, or dairy. Don't use ingredients which are difficult to find.

Better Example

Create a dinner party menu using plant-based ingredients suitable for vegans. The ingredients should be easily available in Britain.

Format

The more specific you can be about the output format the better. This can include information such as:

  • tone (e.g. humorous or formal)
  • length (e.g. in-depth or fit on one side of A4 paper)
  • medium (e.g. PowerPoint presentation slides or easy to reference note)
  • layout (e.g. bullet points or descriptive paragraphs)

Example

The menu should be concise and easy to reference, making use of clear sections headed by the time the different elements need attention.

Examples

Providing examples can be key to getting a good output. The sweet spot is around two to five examples in what is called “few shot” prompting.

Example

On two previous occasions, the meals I cooked went down really well with guests. The first was a dish based around crispy sesame tofu with a peanut sauce; and the second was a red wine mushroom bourguignon.

Putting it all together

Dinner party prompt

I am hosting a Saturday evening dinner party for 12 people. I would like to prepare as much as possible in advance so I have time to socialise.
Create a dinner party menu using plant-based ingredients suitable for vegans. The ingredients should be easily available in Britain.
The menu should be concise and easy to reference, making use of clear sections headed by the time the different elements need attention.
On two previous occasions, the meals I cooked went down really well with guests. The first was a dish based around crispy sesame tofu with a peanut sauce; and the second was a red wine mushroom bourguignon.

Book recommendation prompt

I'm looking for some book recommendations, in particular ones which I can read before going to bed.
For this I would prefer shorter novels, or short stories.
I particularly enjoy books which make me think a bit about deeper subjects like philosophy, politics, ethics, religion, culture, and the societal impacts of future technology.
Recently I have enjoyed Ishmael by Daniel Quinn, The Paper Menagerie collection of short stories by Ken Lui, Spin by Robert Charles Wilson, and The First Fifteen Lives of Harry August by Claire North as bedtime reads. Provide me with 10 book suggestions, each with a one line description of why you think the suggestion fits.

Iterate

Once you have entered your initial prompt and received a response, evaluate it to see if the response meets your requirements.

Following up

If the response is close to meeting your requirements, you can discuss the response with the AI Assistant. This might be requesting a change, clarifying what you meant, or asking for further information.

Example

That plan looks good in general, however one of the guests has a severe allergy to tomatoes. Update the menu to account for that.
Additionally, suggest some wine and other drinks which would pair well.

Re-writing

If the response is quite far off what you would like, you can try rewriting the prompt using one or more of the following techniques:

  • ensure the CAFE framework is followed, in particular by adding better examples or including more positive criteria
  • break the prompt down into smaller tasks, following up with each smaller task after the first response
  • changing to an analogous or synonymous task by rephrasing in a different context

Frequently Asked Questions

What is the difference between zero-shot and few-shot prompting?

Zero-shot prompting means asking the AI to perform a task without providing any examples. Few-shot prompting involves providing one or more examples of the desired output format or style before asking the AI to complete a similar task. Few-shot prompting typically produces more consistent and higher-quality results.

How long should prompts be?

There's no single ideal length - prompts should be as long as necessary to provide sufficient context and clarity. Focus on being concise whilst including all essential information.

Can I use these techniques with any AI model?

Yes, the CAFE framework and prompt engineering principles work across different AI models including ChatGPT, Claude, Gemini, and DeepSeek.

Conclusion

Effective prompt engineering transforms AI interactions from simple questions to powerful collaborations. By applying the CAFE framework (Context, Action, Format, Examples), you can consistently generate more accurate, relevant, and useful responses from AI Assistants.

  • Provide comprehensive context to ground the AI's understanding
  • Specify clear actions using precise verbs and role-based instructions
  • Define exact output formats to match your needs
  • Use examples to demonstrate expectations and improve quality

For a quick reference guide, check out the CAFE AI Prompt Framework.