DEV Community

Douglas Walseth
Douglas Walseth

Posted on

How the Enforcement Ladder Maps to Anthropic's Context Engineering Framework

Anthropic Published the Playbook. We Already Ran It.

Last week Anthropic released "Effective Context Engineering for AI Agents" — their official guide to managing the tokens that flow through production AI systems. It immediately became the most-cited reference in the agent engineering space.

Reading it felt like looking in a mirror.

Their core framework — what they call "Right Altitude" — describes a spectrum from over-specified prose (brittle, breaks on edge cases) to structural constraints (robust, self-enforcing). They argue that the right level of abstraction determines whether your agent system compounds or collapses.

We've been running exactly this hierarchy in production since September 2025. We call it the enforcement ladder. Five levels, from conversation to pre-commit hooks, each encoding lessons at increasing durability.

The mapping isn't approximate. It's exact.

The Technical Mapping

Anthropic's guide identifies four core operations for context engineering: Write (add information), Select (choose what enters the window), Compress (reduce without losing signal), and Isolate (separate concerns into independent contexts).

Our enforcement ladder implements all four — plus a fifth operation Anthropic acknowledges but doesn't systematize: Verify.

Anthropic Concept Enforcement Ladder What It Does
Tool design constraints L5: Hooks Pre-commit hooks, automated scanners, CI gates. Hard constraints that reject bad context before it enters the system. Anthropic's guide says "tool design > verbose instructions." We agree — and we have 3,700+ violation records proving hooks catch what instructions miss.
Compaction with structured recall L4: Tests Automated tests that verify context survives compression. When Claude auto-compacts your 200K context to 40K, do the critical facts survive? L4 tests catch context rot before it causes downstream failures.
Structured note-taking patterns L3: Templates Standardized formats (WARM files, completion reports, spec templates) that ensure critical information is written in machine-parseable structure. Manus independently discovered the same pattern — their todo.md recitation is L3 enforcement.
"Brittle extreme" (over-specified prose) L2: Prose Natural language instructions in CLAUDE.md files. Anthropic explicitly warns this is the weakest form of context management. We track it as a failure mode: if a lesson can only be encoded as prose, we document why structural enforcement was impossible.

The hierarchy isn't arbitrary. Each level is strictly more durable than the one below it. A hook (L5) survives context compaction, developer turnover, and model upgrades. A prose instruction (L2) survives none of those.

The Layer Anthropic Left Out: Verification

Anthropic's guide focuses on getting the right context into the window. That's necessary but not sufficient.

The missing piece is closed-loop verification — systematically checking whether your context engineering actually worked. Not "did the model generate output?" but "did the output respect the constraints the context was supposed to enforce?"

In our system, this is the violation database. Every time an agent's output contradicts an encoded constraint, we record it: which rule, which agent, what happened, what the intended behavior was. 3,706 violations logged across 960+ commits. Each violation is a data point that feeds back into the enforcement ladder — promoting patterns from L2 prose up to L5 hooks when they fail repeatedly.

Anthropic hints at this with their mention of "evaluative signals," but they don't prescribe a systematic feedback loop. The OpenClaw-RL paper (arxiv 2603.10165) quantifies why this matters: combined evaluative + directive signals produce 4.8x improvement over 16 iterations compared to evaluative signals alone.

Context engineering without verification is like writing tests but never running them.

What Manus Confirms

The Manus team published their own context engineering lessons the same week. Their production agent — handling real user tasks at scale — independently validated the same hierarchy:

  • Logit masking (hard constraint on token generation) maps to L5 hooks
  • Dynamic tool removal (soft constraint) maps to L3/L4
  • File system as extended memory maps to our WARM files (persistent context that survives compaction)
  • todo.md recitation (re-reading structured state each step) maps to L3 templates

Their key insight: "No amount of raw capability replaces memory, environment, and feedback." That's the enforcement ladder thesis in one sentence.

Why This Matters for Your Production Agents

If you're running AI agents in production — or planning to — Anthropic's guide gives you the vocabulary. The enforcement ladder gives you the implementation.

Three concrete actions:

1. Audit your context altitude. How much of your agent's behavior depends on prose instructions (L2) vs. structural constraints (L5)? The ratio predicts failure rate. In our system, every lesson starts as prose and gets promoted up the ladder. If a constraint has been violated 3+ times as prose, it must be promoted to L4 or L5.

2. Build the verification loop. Log every time your agent violates an expected constraint. Not just errors — constraint violations. The difference matters. An error is "the code crashed." A violation is "the code ran fine but ignored the rule that says don't modify production data." Violations are invisible without explicit checking.

3. Measure context survival across compaction. Anthropic's guide discusses context rot — information loss when the context window compresses. Test this explicitly. Write a critical fact into your agent's context, trigger compaction, then check if the agent still knows the fact. Our data shows ~40% of L2 prose doesn't survive a single compaction cycle. L5 hooks survive indefinitely because they're encoded in the file system, not the context window.

The Competitive Window

Three things happened in March 2026:

  • Anthropic published official context engineering guidance
  • OpenAI acquired Promptfoo (AI testing/security)
  • Microsoft announced E7 general availability for May

The platform vendors are converging on "context integrity" as a feature. The window for independent practitioners to establish methodology ownership is narrowing.

The enforcement ladder isn't a product pitch. It's a framework that maps 1:1 to what Anthropic recommends, extends it with verification, and has 6 months of production data behind it. If you're evaluating how to manage context for your agents, the question isn't whether to use a hierarchy like this — it's whether to build it yourself or adopt one that's already been battle-tested.


Run a free context health scan on your repository at walseth.ai/scan. See how your project's enforcement structure maps to Anthropic's framework — in 30 seconds, no signup required.

Top comments (0)