Context Minimization Principle Software design is for modification.
Correct modification requires sufficient context.
Good design makes that context cheaper to acquire.
For the modifications a system must realistically support, a design is better when the sufficient context required for correct modification is cheaper to acquire. Start here Better models and better harnesses matter. But agents also need codebases where the right context is cheap to find, trust, and use.
Part I — Foundations Why software development is better understood as continuous modification rather than one-time creation. Features, bug fixes, refactoring, review, and testing all revolve around changing a living system safely.
Required context, explicit and implicit knowledge, and why context cost is the shared currency of software engineering.
The formal statement of CMP and the four constraints that turn it from a slogan into a comparative frame for software design.
Part II — The Shape of Context Depth is the context cost of acquiring the behavioral meaning of a focal artifact. This chapter explains why a short call site can hide a long investigation, and why boundaries only stop traversal when their contracts do the work.
Breadth is the cost of acquiring every artifact that must be considered together for a realistic change to be correct — and of knowing the modification closure is complete.
Breadth selects artifacts; depth prices each one. Design moves transform context by reducing, relocating, indexing, or making it checkable.
Part III — Design as Context Engineering Boundary principles are context operators on depth: semantic contracts that let modifiers stop without loading implementation details behind them.
Locality makes modification closure reachable from every legitimate entry point. This chapter reframes DRY, SRP, and cohesion as design against omission — for humans and agents.
Architecture is a routing map for context acquisition. This chapter explains how layers, bounded contexts, framework conventions, and system boundaries make decision placement predictable.
Testability is the cost of acquiring the context needed to verify behavior. This chapter connects testing to CMP through verification context and explains why TDD applies testability pressure early.
A programming language is not just syntax for a machine — it is the base layer of boundary infrastructure. This chapter maps types, modules, ownership, and effect systems to boundary mechanisms, compares language trade-offs under CMP, and explains why AI-assisted development shifts the balance toward more expressive languages.
Part IV — Practice: Design in the Agent Era Over-engineering is not "too much design" - it is paying present context cost for future savings that do not arrive, arrive along the wrong axis, or would have been cheaper to defer. YAGNI and careless deferral are the opposite failure: refusing to bet when the future modification is reasonably foreseeable. This chapter frames both as wrong bets on expected context cost.
When agents make code cheap to produce, the cost-benefit math behind every design decision changes. This chapter explains what actually got cheap, what stayed expensive, and why practices that once looked like over-engineering can flip to positive ROI — and closes with testable predictions for the agent era.
Clean Architecture, Hexagonal, and Ports & Adapters were long dismissed as ceremony for most teams. In agentic engineering, their boundaries become high-leverage context routing: stable seams, explicit dependencies, and use-case isolation that make agents land changes in the right place. This chapter treats Clean Architecture as a concrete case study of agent-shifted ROI.
Solving the reliability problem of AI programming through context routing. This chapter explains why agents can erode codebases, and how post-task reflection turns each modification into locality repair, boundary guards, and ownership signals.
How to Design a CMP-aware Coding Agent Planned
Embeds CMP directly into a coding agent's workflow through two mechanisms: a pre-task planner that maps depth, breadth, and modification closure before touching code, and a post-task reflection loop that repairs boundaries and locality after each change. The aim is an agent that reasons about design in terms of boundary, locality, and context cost — actively maintaining and tightening architectural seams so the codebases AI maintains stay cleaner than the ones humans maintain.
Part V — Open Frontiers Can Context Cost Be Measured? Planned
Context cost may not be directly measurable, but its traces can be observed: retrieved files, failed localization, missed edits, patch breadth, test failures, review corrections, and static structure. What would a credible, comparable metric look like?
What Will Software Engineering Become? Planned
When agents become routine participants in software work, the question extends beyond codebase structure. Deployment, infrastructure, reliability, performance, operations, security, observability, and product iteration all become part of the agent-era engineering system. This chapter asks what software engineering becomes when the whole lifecycle—not just the codebase—must be redesigned around human judgment, machine execution, and continuous feedback.
Citation If you reference this work in academic or technical writing, please cite:
@online{zhang2026cmp,
author = {Zhang, Lianghui},
title = {Context Minimization Principle},
year = {2026},
url = {https://www.contextcost.dev/cmp/},
}GitHub repository
Put CMP into your agent CMP is not only a book — it ships as two Agent Skills you can install in Cursor, Claude Code, and other coding agents: a pre-task planner and a post-task reflection loop.
CMP Skills — download & install
Print full book — all published chapters on one page, formatted for Save as PDF.