Chapter 8
08Prompt Engineering: The “Magic Recipe”
“The quality of what you get from the machine is a direct reflection of the quality of what you give it.”
The real power of generative AI lies not in the model, but in our ability to steer it; the world’s most powerful engine remains latent energy without a skilled driver. That steering is “prompt engineering”: the art and science of crafting the inputs that guide a model to produce exactly what we want. It requires no programming languages, only precise “description.” Think of an effective prompt as a recipe: the more precise the ingredients, the closer the result to what you imagine.
The Four Ingredients of an Effective Prompt


Text in this figure
1 · Task · what to do? · “Write” · + · 2 · Context · why & for whom? · “for undergraduates” · + · 3 · Persona · in what voice? · “as an academic expert” · + · 4 · Format · in what shape? · “150 words” · Effective prompt = precise result · output quality mirrors input quality · From the “recipe” · to the “cookbook”: · zero-shot · one-shot · few-shot · chaining · Figure 12
- Task: the direct action: “write,” “summarize,” “translate,” “draw,” “analyze,” “create a table.”
- Context: what the model needs to understand “why” you ask: audience, topic and constraints. Weak: “write me an email.” Strong: “write an email to customers who stopped buying six months ago, offering a special 20% discount to win them back.”
- Persona / role: tone, style and role: “in a professional, formal tone,” “in an engaging storytelling style,” or, most powerful, “act as an award-winning economist.”
- Format: the shape of the answer: “a bulleted list,” “a structured JSON file,” or “an article of no more than 300 words.”
A complete example: (Task) write (Context) a summary of the main challenges facing solar power in desert regions (Persona) in a simplified academic style for undergraduates (Format) in one paragraph of no more than 150 words.
Advanced Strategies: From “Recipe” to “Cookbook”
- Zero-shot prompting: relies only on the model’s knowledge: “translate this text into German.” Enough for common tasks; may fail on complex or specialized ones.
- One-shot and few-shot prompting: give one or more examples to imitate: “translate in the same style: [sentence 1] → [translation 1]. Now: [new sentence] → ?” Effective for enforcing a style or format.
- Prompt chaining (co-creation): instead of one long prompt, a conversation that refines the output step by step: “draw an astronaut on Mars.” “Make the stars brighter.” “Add a small book in his hand.”
From Prompt Engineering to “Context Engineering”
2026 Update
With larger context windows and the rise of agents, the focus has shifted from writing one clever sentence to designing “everything the model sees”: persistent system instructions, retrieved reference documents, style examples, conversation history and tool results. This is “context engineering.” Its rules include: separate instructions from data with clear markers, ask for structured outputs that are easy to verify, state what to do and not only what to avoid, and keep a library of tested prompts for your team.
- System instructions: the role and lasting limits that govern every answer.
- Sources: the documents the answer must rely on (Chapter 12).
- Examples: models of the desired style and format.
- Memory: what is needed from past conversations, without padding.
Lessons Learned
- 1Prompt engineering is the new “language” of technology, and mastering it is essential for every creator.
- 2Output quality is a direct reflection of input quality.
- 3An effective prompt defines four pillars: task, context, persona and format.
- 4Do not expect perfection on the first try; use dialogue and chaining to co-create.
- 5Context engineering designs everything the model sees, not just one sentence.
Tip: use ← → to move between sections.

