liveBook · Manning

Context engineering

As explained in Spec-Driven Development

Context engineering is the deliberate organization of relevant information so that a participant or system can understand and act on it effectively.

Context engineering makes the right information available and organizes it so a person or coding agent can find what matters for a task. More context is not automatically better: messages, files, and tool output consume a bounded context window. When an agent compacts a long interaction, its summary may omit a constraint needed later. Important decisions should therefore move out of the conversation and into durable artifacts that can be loaded when relevant. section 1.3

Choose the form of context to match its lifespan:

  • Use prompts and plans to guide a single implementation iteration. Keeping every such file does not create a useful reference: old instructions may be hard to rank by priority, recency, or relevance. section 2.1.1
  • Use structured specifications as a durable reference for application behavior. Their hierarchy should let an agent retrieve relevant intent for a later change instead of reconstructing that intent from code or chat history. section 2.1.1
  • Make intent verifiable with user stories, acceptance criteria, and tests where appropriate. A test written before implementation frames the required behavior; a test written only after a misaligned implementation may preserve the wrong behavior. section 1.2

A URL shortener with missing decisions

“Build me a URL shortener” can produce a working application quickly. In one exercise, the agent chose a Node.js server with in-memory storage, a form, and a redirect endpoint. That output demonstrates what the instruction elicited, not that every product decision was intended. If a choice matters, articulate it as intent rather than relying on the agent’s interpretation and correcting the code afterward. section 2.3.1

For a password reset, “let users reset passwords” leaves consequential behavior unstated. Acceptance criteria can specify that a successful reset invalidates existing sessions and that a reset link expires after 30 minutes. A test can then check session invalidation before implementation begins. These artifacts give the agent a behavior to satisfy, not merely an implementation to imitate. section 1.2

Listing 1.2 Acceptance criteria password reset user story
Scenario: Resetting a password revokes existing access
 
Given I am an account holder with one or more active sessions
And I have requested a password reset
When I successfully set a new password using the reset link
Then all existing sessions for my account are invalidated
And I must log in again on any device
 
Scenario: A reset link is valid only for a limited time
 
Given I have requested a password reset
When I open the reset link within 30 minutes
Then I am allowed to choose a new password
 
Scenario: An expired reset link cannot be used
 
Given I have requested a password reset
When I open the reset link after 30 minutes
Then the link is rejected
And I am prompted to request a new one

The password-reset scenarios show how to turn a broad request into checkable outcomes, including session revocation and link expiry. section 1.2

The operational aim is sustained alignment, not the largest possible prompt. Tactical instructions can improve one pass; structured, reusable intent helps later passes stay oriented as the application grows. section 2.1.1 section 2.3.4

How Spec-Driven Development covers it

How deep it goes
Contrasts tactical prompts with structured specifications and explains context-window compaction; stops short of a detailed specification template.
Examples
Uses a prompted URL shortener and password-reset acceptance scenarios and tests to contrast inferred behavior with verifiable intent.
What it assumes
Assumes familiarity with prompts and implementation work while defining context windows and compaction explicitly.
What you can do after
Practice/perform context engineering by preserving important decisions in structured artifacts and supplying relevant intent for later agent work.
How it connects
Connects context engineering to intent-driven development, specification-driven development, user stories, acceptance criteria, BDD, and TDD.

Also explained in

Compare how 7 books explain context engineering →

Related concepts

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