liveBook · Manning

Chapter 6: User prompts for LLMs

What you will learn in chapter 6 of Context Engineering

Introduces user prompts as the context source that expresses a user’s immediate intent and guides the model toward a specific outcome.

After this chapter you will be able to

What it builds on

Section by section

Introduction

Introduces user prompts as the context source that expresses a user’s immediate intent and guides the model toward a specific outcome.

Key terms: user prompts, immediate user intent, context sources

6.1 User prompt

This section explains how a user prompt supplies context, why specific prompts produce more useful responses, and how prompts fit into an application's broader context.

Key terms: user prompt, prompt engineering, underspecified, structured and constrained, context management layer, context engineering

6.2 Best practices for prompt design

Prompt design sets the conditions for an LLM’s answer and improves through testing and refinement.

Key terms: prompt design, testing, observing, and refining, context

6.2.1 Core design principles

This section explains four principles for making prompts more directed, predictable, and usable in larger systems.

Key terms: Give direction, clear intent, style, persona, Specify format, Markdown prose, JSON, schema, Provide examples, input and output format

6.2.2 Production considerations

This section explains how production prompts should handle untrusted inputs and be managed as versioned software assets.

Key terms: untrusted input, prompt injection, direct injection, indirect injection, explicit delimiters, defensive instructions, prompt templates, versioned software assets, runtime variable placeholders, regression testing

6.3 Prompting techniques

Introduces prompting techniques as repeatable patterns that turn prompting principles into structured context for model tasks.

Key terms: prompting principles, prompting strategies, structuring context

6.3.1 Role prompting

This section explains how assigning a role to an LLM focuses its response and when that focus is useful.

Key terms: role prompting, system instructions, user prompt, specialized domain perspectives

6.3.2 Few-shot prompting

This section explains how few-shot examples teach a model a task within a prompt, and the token and caching trade-offs of selecting those examples.

Key terms: few-shot prompting, input-output demonstrations, in-context learning, inference pass, demonstrations, tokens, context consumption, dynamic few-shot prompting, retrieval layer, demonstration store

6.3.3 Chain-of-thought prompting

Explains how chain-of-thought prompting uses intermediate reasoning to reach a decision, illustrated by a support-policy check, and identifies its benefits and costs.

Key terms: chain-of-thought (CoT) prompting, intermediate reasoning steps, reasoning tokens, audit trail, token consumption, latency, cost, logical decomposition, exact arithmetic, external tools

6.3.4 ReAct prompting

This section explains how ReAct prompting alternates reasoning and tool use, and why the resulting trace has a context cost.

Key terms: ReAct, Thought - Action - Observation loop, agent harness, observation, context window, intermediate steps

6.3.5 Prompt chaining

Explains how prompt chaining splits a workflow into sequential model calls and why production chains may need checks between calls.

Key terms: prompt chaining, sequential model calls, intermediate outputs, prompt budgets, failure propagation, validation checkpoints, schema parsing, confidence filters, fallback logic

6.3.6 Other prompting techniques

6.3.7 Prompting and reasoning models

Explains how reasoning models shift prompting away from prescribed thought steps and toward specifying the task and its context.

Key terms: reasoning models, explicit CoT, ToT, self-consistency, task specification, grounding data

6.4 Prompt frameworks

Defines prompt frameworks as repeatable structures and explains why their predictability supports prompt reuse and evaluation.

Key terms: prompt framework, templatable, versionable, comparable across runs

6.4.1 10-step prompt structure

Introduces a ten-component prompt structure, explains why its components are ordered from stable to dynamic context, and clarifies how to write useful reasoning guidance.

Key terms: task context, tone context, background data, documents, and images, detailed task description and rules, examples, conversation history, stable material, volatile parts, cached, generated tokens

6.4.2 Lightweight frameworks

This section contrasts lightweight prompt frameworks with the 10-step structure and explains why using one structure consistently matters in production.

Key terms: 10-step structure, lightweight frameworks, COSTAR, RTF, single agreed structure, diffable, testable, comparable

6.5 Prompting tools

This section distinguishes tools for experimenting with prompts, managing them in production, and building applications around them.

Key terms: interactive environments, managed artifacts, prompt versioning, prompt lifecycle platforms, evaluation runs, traces collected from production, AI frameworks, LangChain, LlamaIndex, DSPy

6.6 Hands-on

This section introduces the hands-on exercises and points readers to the companion repository for complete scripts, dependencies, and run commands.

6.6.1 Few-shot ticket normalizer

Shows how a few labeled examples in a prompt guide an LLM to turn noisy bug reports into a consistent support ticket format.

Key terms: labeled examples, repeating input-output pattern, support ticket schema

6.6.2 Prompt chaining for support replies

Illustrates how a support workflow chains two model calls with application logic between them to produce a policy-grounded customer reply.

Key terms: prompt chaining, inquiry analysis, policy resolution, response generation, SLA response targets

6.6.3 Prompting with DSPy: CoT vs ReAct

Shows how DSPy implements the same math-tutor task with reusable CoT and ReAct modules, and explains when to choose each strategy.

Key terms: DSPy, signature, module, CoT, ReAct, calculator tool

6.6.4 Using prompt frameworks

This section shows how a prompt builder turns framework components into reusable prompts and places user prompts alongside other context sources.

Key terms: context-aware prompt builder, prompt frameworks, Prompt sample, Copy prompt, Export, Import, user prompts, context sources, instructions, retrieved knowledge

6.7 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 5: Memory and state in agentic systems Chapter 7: Context management and orchestration →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.