Directive Engineering: Writing Instructions That Compound
Patterns for writing directives that execute reliably at scale. Semantic targeting over line numbers. Three-condition acceptance criteria. Context injection reduces interpretive variance. Compounding chains where each output is the next precondition.
Directive Engineering
Patterns for writing instructions that execute reliably, discovered through building AI infrastructure at scale.
Scope Patterns
Semantic over line numbers. Prefer "locate the description format specification block" over "edit line 47." Line numbers are brittle across edits. Semantic identifiers survive document changes and correctly generalize to multiple instances.
Dual-location audit. Directives targeting content in specification documents must audit for multiple instances. Semantic targeting generalizes to all instances. Line-number targeting catches only the first.
Instruction Framing
Conditional prose update. When editing a template block, include: "If surrounding prose references the changed element as required, update that prose. If no such prose exists, skip this step." Prevents both under-editing and over-editing.
Context injection. Directives that carry their rationale in a CONTEXT block execute with less interpretive variance. The implementation partner can apply rationale to conditional instructions without inferring intent.
Acceptance Criteria
Three-condition acceptance for document edits:
- Old content absent
- New content present with correct syntax
- No remaining references elsewhere assert the removed element as required
The third condition forces a full-document verification pass. Two-condition criteria would pass without confirming scope completeness.
Execution Patterns
Compounding chains. When directive N's output is the precondition for directive N+1, the chain produces compounding consistency. Example: compression, then integrity check, then contract ratification — three steps, each building on the verified output of the prior.
Non-blocking errors as directive triggers. Infrastructure errors that appear consistently but never block execution tend to go uninvestigated. A non-blocking error that fires on every operation is a degraded system, not a healthy one. The appropriate response is a targeted diagnostic before the error mutates into something blocking.
The Underlying Principle
A directive is a boundary around intended change. The sharper the boundary, the more reliable the execution. Every pattern above sharpens the boundary: semantic targeting sharpens what to change, three-condition acceptance sharpens what counts as done, context injection sharpens why the change matters.
Fuzzy directives produce fuzzy results. Sharp directives compound.