liveBook · Manning

Prompt engineering

As explained in Context Engineering

Prompt engineering is the practice of designing and refining inputs to a language model to influence the quality and character of its output.

Prompt engineering is the practice of designing and refining LLM inputs to guide output quality and character. A prompt works like a specification: it states the task, relevant constraints, and expectations rather than leaving the model to infer them. Design is iterative—test a draft, observe the response, and refine unclear directions or missing assumptions. section 1.1 section 6.1 section 6.2

Prompt engineering is part of context engineering. In an application, a context-management layer may combine the user’s prompt with instructions, external knowledge, tools, memory, and state. The prompt expresses immediate intent; the broader context determines what else the model sees. section 6.1 section 1.1

Four principles make prompt design more systematic:

  • Give direction: state the desired outcome, then add audience, purpose, style, or other constraints where useful. section 6.2.1
  • Specify format: define the structure, field names, units, ordering, and handling of missing values when downstream systems depend on the output. section 6.2.1
  • Provide examples: show representative inputs and outputs to clarify the task and desired pattern. section 6.2.1
  • Break down complex tasks: use smaller steps, including chained model calls when appropriate. section 6.2.1

From question to specification

Instead of asking “What is context engineering?”, request: “Define context engineering in 3–4 sentences for a software engineering audience. Focus on its practical benefits, clearly distinguish it from prompt engineering, and use technical but accessible language.” The revision specifies length, audience, emphasis, and tone. section 6.1

Patterns such as role prompting, few-shot prompting, chain-of-thought, ReAct, and chaining structure interactions but consume context-window space. For reasoning models, explicit procedural reasoning prompts can be largely redundant or overly constraining; focus instead on the task, grounding data, constraints, examples, and tool definitions. section 6.7 section 6.3.7

In production, treat user prompts as untrusted input and isolate them with delimiters against injection attacks. Version prompt templates and run regression tests. Frameworks such as COSTAR and CRISPE can standardize prompt construction; tools such as DSPy support optimization, evaluation, and deployment. section 6.7

How Context Engineering covers it

How deep it goes
Develops iterative design principles, prompting patterns, production safeguards, and adaptations for reasoning models.
Examples
Contrasts an underspecified question with a constrained definition request and uses product naming to illustrate task direction.
What you can do after
Apply prompt design through clear instructions, output formats, examples, task decomposition, testing, and refinement.
How it connects
Connects context engineering, context windows, few-shot prompting, chain-of-thought, ReAct, and reasoning models.

Also explained in

Compare how 51 books explain prompt engineering →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Context Engineering. The section links point to the parts of the book it draws on.