liveBook · Manning

Chapter 5: Templates

What you will learn in chapter 5 of Prompt Engineering in Practice

This introduction defines reusable prompt templates, explains how changing inputs fit into a stable framework, and emphasizes evaluation before use.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This introduction defines reusable prompt templates, explains how changing inputs fit into a stable framework, and emphasizes evaluation before use.

Key terms: prompt template, template pattern, structural elements, linguistic elements, prompt patterns, dynamic input parameters, input variables, placeholders, core logic, prompt evaluation

5.1 Prompt templates as reusable frameworks

Defines prompt templates as reusable prompts with stable core logic and runtime inputs, and recommends storing them outside source code.

Key terms: prompt template, input parameters, core template logic, external template files, Jinja2, Markdown

5.2 Practical example 1: Feature implementation plan generator

The section identifies the planning problems caused by loosely written tickets and inconsistent drafting, then introduces a prompt template as a way to produce consistent plans from changing ticket data.

Key terms: product tickets, implementation plans, prompt template, ticket data

5.2.1 Prompt template components

This section explains how structural elements, linguistic choices, and prompt patterns combine to make a reusable feature implementation planning template.

Key terms: instructions, constraints, input parameters, output format, plan schema, precision, directness, brevity, role assignment, senior software engineer

5.2.2 Prompt template

This section presents a feature implementation plan prompt template that grounds a sprint-ready plan in supplied request details and specifies its output structure.

Key terms: Feature Request, constraints, business goal, acceptance criteria, target release, Role Assignment, Implementation Steps, Risks, Scope, Delivery Checkpoint

5.2.3 Prompt with input parameters injected

An injected feature request demonstrates how a reusable template produces a structured implementation plan that respects the request’s constraints.

Key terms: acceptance criteria, nonbreaking data model extensions, migration, grace period, role assignment, constraints, output format, template pattern, output schema

5.3 Practical example 2: Legacy module refactor plan generator

The section explains why legacy-module refactor plans need to uncover missing constraints before turning answers into a plan.

Key terms: legacy modules, hidden coupling, data-contract assumptions, operational risk, inversion, refinement

5.3.1 Prompt template components

This section identifies the structural, linguistic, and pattern components of a two-stage prompt template for safer legacy-module refactor planning.

Key terms: risk-discovery questions, inversion pattern, refinement pattern, hidden dependencies, rollback requirements, legacy_module_context, refactor_goal, timeline, team_capacity, risk_tolerance

5.3.2 Prompt template

The section presents a legacy-refactor prompt template that asks for risk-revealing questions before a plan and leaves slots for the module context and planning parameters.

Key terms: Role Assignment, hidden dependencies, migration risk, rollback needs, Legacy Module Context, Refactor Parameters, refactor goal, timeline, team capacity, risk tolerance

5.3.3 Prompt with input parameters injected

A legacy-refactor example shows how questions about hidden risks feed a reusable refinement prompt and produce a plan with explicit rollout and rollback safeguards.

Key terms: inversion step, downstream consumers, implicit service contracts, rollback mechanics, refinement prompt template, assessment answers, input parameters, refactor parameters, characterization and contract tests, existing interface

5.3.4 Hands-on practice

This hands-on section gives readers a workflow for building and comparing reusable prompt templates, then asks them to apply it to several engineering tasks.

Key terms: structural elements, linguistic elements, prompt patterns, input parameters, baseline prompt, structure compliance, core logic, role framing, constraints

5.4 Summary

This summary explains how stable prompt templates, dynamic inputs, combined design techniques, and multistep workflows support repeatable results.

Where this is used later

Concepts explained in this chapter

← Chapter 4: Patterns Chapter 6: Prompt types →

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.