Overview

3 Prompt Engineering

Prompt engineering is presented as a practical communication skill for getting useful results from language models. The chapter uses the analogy of a powerful sports car: a model may be capable of impressive things, but that power matters only if the user knows how to direct it well. Rather than treating AI like traditional software, where instructions specify exactly how to act, prompt engineering focuses on expressing intent clearly so the model can infer how best to respond.

The core of an effective prompt is built from three parts: context, the main point, and action. Context tells the model who you are, what you are trying to do, what constraints matter, and what level of prior knowledge it should assume. The main point states the task itself, such as explaining, comparing, summarizing, or planning. Action shapes the output by specifying details like format, tone, audience, length, language, structure, and perspective. The chapter also shows how roles and examples can further guide behavior, with zero-shot prompting as the default and one-shot or few-shot prompting useful when the desired pattern is hard to describe directly.

Beyond single prompts, the chapter emphasizes working through conversations to refine ideas, zoom into details, zoom out to the bigger picture, or branch into alternatives. It also explains how long conversations can drift or become confusing, and how to recover by restating goals, summarizing progress, or starting a fresh thread with a concise checkpoint. Finally, the chapter stresses that even well-crafted prompts cannot guarantee correctness: models can hallucinate, overstate confidence, reflect biases, or be manipulated by prompt injection and jailbreaking. The takeaway is that prompting can greatly improve AI usefulness, but human judgment and verification remain essential.

The three components of a well-structured prompt, each answering a different question.
Four common types of context that help a model to produce more relevant responses
Two techniques for improving model responses, each answering a different question about how the model should behave
Three common prompting approaches. In zero-shot prompting, the model receives only a task. In one-shot prompting, a single example is provided. In few-shot prompting, multiple examples are provided to establish a clearer pattern.
Four conversation patterns for working effectively with a language model.
Three common risks and limitations of language models, each corresponding to a different question about how a model can fail.

Summary

  • Effective prompting is less about clever tricks and more about clear communication. A well-structured prompt typically contains three elements: context, a main point, and an action.
  • Context helps the model understand your situation. Useful context often includes who you are, what you are trying to achieve, your constraints, and what you already know.
  • The main point defines the task you want the model to perform. Strong prompts focus on a specific objective.
  • Actions specify how the response should be delivered, including format, audience, tone, length, level of detail, and perspective.
  • Assigning roles can improve responses by guiding the model toward a specific perspective, expertise, or communication style.
  • Examples are often more effective than instructions alone. Zero-shot prompting relies on a task description, while one-shot and few-shot prompting provide examples for the model to follow.
  • The most powerful AI interactions often happen through conversations. Refinement, Zoom In, Zoom Out, and Branching are common conversation patterns for exploring ideas and improving results.
  • Long conversations can lose focus over time. Techniques such as restating instructions, creating summaries, and starting new conversations help keep discussions on track.
  • Even well-written prompts cannot eliminate the limitations of language models. Hallucinations, overconfidence, bias, prompt injection, and jailbreaking remain important risks that require critical thinking and human oversight.
  • Effective AI users treat model outputs as information to evaluate. The quality of the answer depends both on the model and how it is prompted, verified, and used.
  1. Bender, E. M., Gebru, T., McMillan-Major, A., & Shmitchell, S. (2021). On the dangers of stochastic parrots: Can language models be too big? In Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency (pp. 610–623). Association for Computing Machinery. https://doi.org/10.1145/3442188.3445922
  2. Brown, T. B., Mann, B., Ryder, N., Subbiah, M., Kaplan, J. D., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., Agarwal, S., Herbert-Voss, A., Krueger, G., Henighan, T., Child, R., Ramesh, A., Ziegler, D., Wu, J., Winter, C., Hesse, C., Chen, M., Sigler, E., Litwin, M., Gray, S., Chess, B., Clark, J., Berner, C., McCandlish, S., Radford, A., Sutskever, I., & Amodei, D. (2020). Language models are few-shot learners. Advances in Neural Information Processing Systems, 33, 1877–1901. https://proceedings.neurips.cc/paper_files/paper/2020/file/1457c0d6bfcb4967418bfb8ac142f64a-Paper.pdf
  3. Gibney, E. (2025, July 11). Scientists hide messages in papers to game AI peer review. Nature, 643, 887–888. https://doi.org/10.1038/d41586-025-02172-y
  4. Ji, Z., Lee, N., Frieske, R., Yu, T., Su, D., Xu, Y., Ishii, E., Bang, Y. J., Madotto, A., & Fung, P. (2023). Survey of hallucination in natural language generation. ACM Computing Surveys, 55(12), Article 248, 1–38. https://doi.org/10.1145/3571730
  5. Liu, N. F., Lin, K., Hewitt, J., Paranjape, A., Bevilacqua, M., Petroni, F., & Liang, P. (2024). Lost in the middle: How language models use long contexts. Transactions of the Association for Computational Linguistics, 12, 157–173. https://doi.org/10.1162/tacl_a_00638
  6. Meincke, L., Shapiro, D., Duckworth, A. L., Mollick, E., Mollick, L., Van den Bulte, C., & Cialdini, R. B. (2026). Persuading large language models to comply with objectionable requests. Proceedings of the National Academy of Sciences, 123(21), e2535868123. https://doi.org/10.1073/pnas.2535868123
  7. White, J., Fu, Q., Hays, S., Sandborn, M., Olea, C., Gilbert, H., Elnashar, A., Spencer-Smith, J., & Schmidt, D. C. (2023). A prompt pattern catalog to enhance prompt engineering with ChatGPT. In Proceedings of the 30th Conference on Pattern Languages of Programs (PLoP '23) (Article 5, pp. 1–31). The Hillside Group.

FAQ

What is prompt engineering?Prompt engineering is the skill of designing prompts so a language model produces useful, accurate, and relevant outputs. It is fundamentally a communication skill that translates your intent into instructions the model can understand and execute effectively.
Why is context important in a prompt?Context tells the model what it needs to know about your situation before answering. It helps the model choose the most relevant knowledge and tailor its response, especially when a general question could be answered in many different ways.
What are the three main components of a well-structured prompt?The three components are context, the main point, and action. Context explains your situation, the main point tells the model what you want it to do, and action specifies how the answer should be delivered.
What is the difference between the main point and action in a prompt?The main point defines the task itself, such as explain, compare, summarize, or analyze. Action defines the form of the response, such as its length, tone, audience, structure, or output format.
How can assigning a role improve a model’s response?Assigning a role tells the model what perspective to use, such as teacher, consultant, analyst, or editor. This helps it choose the most relevant knowledge, vocabulary, and style for the task without adding new information.
What is the difference between zero-shot, one-shot, and few-shot prompting?Zero-shot prompting gives the model only a task. One-shot prompting includes a single example, while few-shot prompting includes multiple examples so the model can better recognize the desired pattern, format, or style.
What are the main conversation patterns used with language models?The chapter highlights refinement, zoom in, zoom out, and branching. Refinement improves a draft step by step, zoom in develops a broad topic in detail, zoom out expands from a detail to the bigger picture, and branching explores multiple alternatives before choosing one.
How can you recover from a long or confusing conversation with a model?You can restate the most important instruction, summarize and redirect, create a checkpoint summary, or start a new conversation using the summary as fresh context. These techniques help restore focus when the conversation drifts.
What is a hallucination in a language model?A hallucination is when the model generates incorrect, misleading, or fabricated information. Even well-written prompts cannot eliminate this risk, so important facts should be verified with trusted external sources.
What is prompt injection, and how can it be reduced?Prompt injection happens when hidden instructions inside content like documents or web pages try to override your original request. You can reduce the risk by treating external content as untrusted, reviewing outputs carefully, keeping human oversight for high-stakes decisions, and avoiding the assumption that every instruction should be followed.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Understanding AI ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Understanding AI ebook for free