Prompting Mechanics.
A technical reference on producing reliable output from language models and coding agents: prompting, context engineering, token economics, and the mechanics underneath.
The thesis
Prompting is what one writes, and context engineering is what arrives. The prompt itself is a small fraction of what the model receives. To produce the best results, one must understand the underlying mechanics of the overall system and each of the levers at play.
Everything one can control falls into one of two categories: the words in the request, and what else is in the window. Beginners spend nearly all their effort on the first, though the measurable wins are overwhelmingly in the second.
A third category sits outside both, and practitioners routinely forget it. On any coding agent, a layer between the user and the model rewrites the request before it is sent, and that layer measurably changes the answer.
Read Section 1 →The two sets
Two sets run through every chapter: the first divides what a practitioner controls from what the harness decides before the model sees the request, and the second accounts for where every billed token lands.
A model answers from everything that reaches it, so context deserves at least the deliberate design the wording gets. The harness assembles and rewrites that context before the request is sent, and it is the one surface a practitioner does not own.
Every billed token lands in exactly one lane, and the lanes differ in price by more than an order of magnitude. Optimization is the work of moving tokens toward the cheaper ones: keeping a prefix stable enough to be cached, and generating only the output the task actually requires.
The six parts
45 sectionsFoundations
What a prompt is once it is rendered, what a token costs, and why the same request answers differently twice.
The Craft
Instruction design, examples, reasoning, output contracts, and the point at which a prompt becomes an artifact.
The Environment
The six configuration mechanisms, instruction files, skills, tools, delegation, and the one control that is deterministic.
Economics and the Context Lifecycle
Four token lanes, prefix caching, invalidation, recycling, budgets, and what routing actually saves.
Advanced Mechanics
Below the API surface: tokenizers, attention, architectures, sampling, constrained decoding, evaluation and local inference.
Platforms
Claude, Codex, Copilot, Cursor and Gemini on the same five questions, and what portability costs.
Contents · Prompting Mechanics
v2.1The complete reference, typeset for print.
All 45 sections, the six platform chapters, the appendices, and 81 references in a single PDF.