#context-engineering

56 posts tagged #context-engineering.

Agent Loop Engineering Is Context Engineering in Disguise

Agent Loop Engineering Is Context Engineering in Disguise

The loop engineering parts list from June 2026, classified by one question: five blocks are context moves, one is a schedule, and the genre's signature failure is fixed by a seventh block the list never counted.

Search Claude Code Session Transcripts Before They Delete

Search Claude Code Session Transcripts Before They Delete

Your session transcripts hold every decision you've made with an agent, and the only free way to search them counts mentions instead of truth. Rank the survivors by date and the reversed decision stops winning.

Run Headless AI Agents Overnight: One Task, One Context

Run Headless AI Agents Overnight: One Task, One Context

A frozen spec substitutes for the memory a disposable agent doesn't have - but only if every task is genuinely independent. The arithmetic for when a flat-rate build loop actually holds.

Write the Acceptance Test Into Your AI Agent's Spec

Write the Acceptance Test Into Your AI Agent's Spec

A green build proves the code compiled. It says nothing about whether the work is correct. Write the acceptance test into the spec, then measure how well it survives an agent gaming its own grade.

Use an MCP Server So Your AI Agent Reads Current Docs

A vibe-coded Stripe integration buries nine decisions in one handler. A teaching clause plus a plan-mode gate surfaces all nine - only three are worth your own trip to the docs.

Review AI-Generated Code by Blast Radius, Not Uniformly

Your daily review-minute budget is fixed, but a missed bug's dollar cost isn't. Spend the same minutes unevenly by blast radius and cut expected losses by roughly half, without reviewing more.

Claude Code Stop Hooks: The Two-Tooth Completion Gate

Claude Code Stop Hooks: The Two-Tooth Completion Gate

While you watch an agent work, you are quietly doing two jobs: judging what it may touch, and judging when the work is actually done. Headless mode deletes you from both at once. The gate that inherits the second job fails two separate ways unless it has two teeth.

AGENTS.md Too Long? Split Into Directory-Scoped Rules Files

AGENTS.md Too Long? Split Into Directory-Scoped Rules Files

A single root rules file guarantees every convention is always present for every edit - which is exactly what floods a backend edit with frontend rules it will never use. The fix is directory-scoped files, and the tax has a number: 62.5%.

Write AGENTS.md From Your Transcripts, Not Imagined Failures

Write AGENTS.md From Your Transcripts, Not Imagined Failures

Raw frequency tells you which failures are real. It still ranks them wrong. Weight each promoted category by what one instance costs, and the rule that looked #2 by count drops to last.

Hooks That Validate AI Agent Output Before It Ships

Hooks That Validate AI Agent Output Before It Ships

Against a 1-in-12 hallucination rate on a checkable failure, a deterministic hook with one capped retry drives the shipped-wrong rate to exactly zero and moves the remaining risk onto one computable number: the halt tax.

MCP Resources, Tools, and Prompts: the Three Primitives

MCP Resources, Tools, and Prompts: the Three Primitives

The MCP spec hands a server three levers: resources for the application, tools for the model, prompts for the user. Skip that sort and your reads ride the tool list every turn, at a price you can compute.

MCP Elicitation: Have Tools Ask for Missing Parameters

MCP Elicitation: Have Tools Ask for Missing Parameters

When a required tool parameter is a fact only the human holds, the two familiar responses, fail and guess, each cost one round trip on the wire and guarantee nothing. Under the MCP spec current since 2026-07-28, asking costs exactly two round trips, fixed, whatever the human answers.

Git Pre-Commit Hooks Stop AI Agents from Committing Bugs

Git Pre-Commit Hooks Stop AI Agents from Committing Bugs

A soft AGENTS.md rule is a per-commit probability, and probabilities compound: 95% compliance becomes a 92.31% chance of a lapse somewhere in a 50-commit sprint. The hook most teams write only cuts that to 22.37%. Here is the arithmetic, layer by layer, and the one layer that zeroes it.

Have an MCP Server Grade the Git Diff, Not Your Summary

Have an MCP Server Grade the Git Diff, Not Your Summary

Ask an agent to grade the work you just described and it grades the paragraph, not the code, because agreeing with a confident claim is the model's strongest reflex. Hand the same model the live diff and a rubric you author, and it finds the four misses your summary hid.

Reproduce AI Agent Bugs as Synthetic Test Scenarios

Reproduce AI Agent Bugs as Synthetic Test Scenarios

A one-line bug report about an agent carries exactly one testable fact: how often the failure fires. Turn the report into a committed synthetic scenario, then let that fact size how many reruns a fixed verdict is worth.

RAG Debugging: Retrieval Failures vs Generation Failures

A confidently wrong answer is two bugs in one costume: a fact that never reached the context window, and a fact that arrived and got ignored. Log the window, score two binaries, and each bug routes to a different layer of the stack.

Stop Broken Function Level Authorization in AI-Written Code

Every inline authorization check an agent writes is an independent guess at the same policy. The guesses disagree, quietly. Here is the arithmetic of how fast that compounds, and the one call that stops it.

Slash Commands and Rules: Stop Retyping the Same AI Correction

Slash Commands and Rules: Stop Retyping the Same AI Correction

The correction you keep re-typing into the chat is a workflow you haven't written down. Priced with a small invented schedule, it costs about 43 silently skipped build gates a quarter. Encoded as a slash command, it costs zero.

Subagents in AI Coding Agents: Isolate Search From Reasoning

Subagents in AI Coding Agents: Isolate Search From Reasoning

Route a codebase search to a subagent pinned to a cheap model and two things happen at once: the search itself costs a fifth as much, and only a hundredth of it ever reaches the window where your expensive model is about to think.

Subagent Dispatch: Task, Tools, and Rules for a Clean Context

Subagent Dispatch: Task, Tools, and Rules for a Clean Context

A 20-issue Sentry triage sweep run inline leaves 21,000 tokens of tool exhaust in the main thread. Dispatched to a subagent under a three-line return contract, it leaves 60. The ratio holds at every cadence.

MCP Server Security: the Confused Deputy Problem

MCP Server Security: the Confused Deputy Problem

The GitHub MCP server that leaked private repo names in May 2025 had no malicious code in it. The token's authority was ambient, good for every repo you can see. Scope it to the task and the blast radius drops 12x.

Auto-Compaction vs a Handoff File in a Long AI Agent Session

Auto-Compaction vs a Handoff File in a Long AI Agent Session

When the window fills, auto-compaction writes a faithful summary and a handoff file writes an edited one. Both can be 200 tokens; next session they are 5,000 tokens apart, and the whole gap is one line saying what was ruled out.

MCP Server Design: Keep API Keys Out of the Context Window

MCP Server Design: Keep API Keys Out of the Context Window

A raw token passthrough hands an injected agent all 34 endpoints of your billing API, five of them destructive. Hold the token server-side and expose three curated verbs instead: one bounded write, capped at $500 a call and logged.

AI Agent Plan File Checklists: The Counter-Signature

AI Agent Plan File Checklists: The Counter-Signature

A relay of fresh sessions inherits every earlier decision through the plan file's checkboxes. But the model that ticks a box has every incentive to believe its own diff. An unaudited checklist is a bet, and this is the arithmetic that prices it.

AI Agent Triggers: Automate Headless Runs with Hooks

AI Agent Triggers: Automate Headless Runs with Hooks

An event can fire a headless agent run as reliably as a hook fires inside a session. But wiring the event only removes the human who had to remember to ask. The one who caught bad output has to be rebuilt as code too: rules for what a careful review would do, guards for what it would never let happen unattended.

MCP Tool Output Schema: Stop Trusting Agent Prose

MCP Tool Output Schema: Stop Trusting Agent Prose

A model has one procedure for turning tool bytes into a sentence, so a clean success and a swallowed failure read the same. On 12 refund calls, narration confirms 3 that never happened; a validated output schema confirms zero.

AI Agent Evals in CI: Run Two Loops, Not One Suite

AI Agent Evals in CI: Run Two Loops, Not One Suite

A suite thorough enough to catch a real regression is too slow and noisy to gate every PR. Split the same 50 cases into a 32-case deterministic gate and an 18-case nightly judge sweep, and a team merging 8 PRs a day gets 156 minutes of blocked PR time back every week - without dropping a single case.

MCP Prompts: Ship Team Workflows as Slash Commands

MCP Prompts: Ship Team Workflows as Slash Commands

The triage prompt your team keeps re-typing makes the agent reassemble, through three round trips, context one expert already knew how to assemble once. That costs 600 plumbing tokens and 7.2 seconds per run. A server-side MCP prompt pays the assembly once, for everybody.

Headless AI Code Review: One Check for Local and CI

Headless AI Code Review: One Check for Local and CI

Your local review habit and your CI gate are two implementations of one question, and nothing forces them to agree. Write the policy once, pin the context, and both surfaces run literally the same check for about two cents a call. The same 30 weekly pull requests on Anthropic's managed Code Review run $450 to $750.

AGENTS.md Rot vs Agent Memory: Why Rules Files Decay

AGENTS.md Rot vs Agent Memory: Why Rules Files Decay

A rules file is right the day you write it and silently wrong forever after, because nothing marks a reversed line. Auto-memory keeps both truths and cannot pick one. A trigger, a dated demotion, and a human gate end it.

Turn Failed AI Agent Runs into Labeled Training Data

Turn Failed AI Agent Runs into Labeled Training Data

Every failed agent run is a labeled example. Capture them with a hook, judge them, count them. The count tells you which failure to fix first. The shape of the failure tells you where the fix belongs, and in one two-week log, half the rows are not fixable in the rules file at all.

Claude Code Skills: Why a Growing Library Gets Harder to Pick From

Claude Code Skills: Why a Growing Library Gets Harder to Pick From

Progressive disclosure keeps a skill library's index cost linear. The number of skill pairs an agent can confuse grows with the square of the library size - and nothing about a growing index tells you that's happening.

AI Plan Review: Catch Blind Spots With a Different Model

AI Plan Review: Catch Blind Spots With a Different Model

An agent reviewing its own plan misses the same defaults it always misses. Gate plan-mode exit on a different vendor's model, and a FAIL verdict re-engages planning before any code exists.

AI Agent Permissions: Gate Irreversible Actions, Not Diffs

AI Agent Permissions: Gate Irreversible Actions, Not Diffs

Permission systems that gate on scariness ask about everything and protect nothing. Gate on reversibility instead, and the same 12-call session drops to 3 interrupts without losing the one that counts.

Cut AI Coding Agent Token Cost With a Throwaway Map

Cut AI Coding Agent Token Cost With a Throwaway Map

Your agent spends about 38 tokens working out where to make a change for every 1 token it spends making it. Then it pays that bill again on the next run. Here's the math, and the throwaway file that ends it.

Build a Shared Glossary So Your AI Agent Stops Guessing

Build a Shared Glossary So Your AI Agent Stops Guessing

Every ambiguous noun in a prompt forces the agent into a blind search over candidate files. A committed glossary turns that search into a lookup - and nets 4,410 tokens back on the very first prompt, no waiting required.

Commission a Subagent to Research and Write Your Skill

Commission a Subagent to Research and Write Your Skill

You don't author a skill from a blank page. You commission a subagent to research the reconciliation once - across a fifteen-service fleet, that one commission is worth 56,500 tokens saved.

AI Agent Requirements Doc: Catch a Wrong Destination Early

AI Agent Requirements Doc: Catch a Wrong Destination Early

A requirements doc fixes the destination, a phased plan fixes the journey - and every technique on this blog for keeping a long build sharp only protects the journey. Here's what the destination costs when nobody checks it first.

Multi-Agent Orchestrator vs Swarm: the Channel Math

Multi-Agent Orchestrator vs Swarm: the Channel Math

Full mesh and hub-and-spoke need exactly the same number of channels at three agents, which is why every swarm demo looks fine. Add a fourth specialist and the mesh pulls ahead for good - 45 paths against 10 by the time you reach ten.

When Claude Code Ignores a Rule: Fire It From a Hook Instead

When Claude Code Ignores a Rule: Fire It From a Hook Instead

A rule in your rules file only gets read if it survives to the top of a shrinking window. Move it into a hook that fires on the event instead, and expected compliance across one session's edits goes from 42.8% to 95.0%.

Autonomous AI Coding Agents: Trust Comes From a Small Blast Radius

Autonomous AI Coding Agents: Trust Comes From a Small Blast Radius

The blocker to running an agent overnight was never capability - it's trust. Layer a sandbox, an allowlist, and a scoped credential right, and one laptop's worst-case reach falls from 399 addressable things to 63, all recoverable with git checkout.

Prompt Injection Defense: Mark the Channel, Not the Words

Prompt Injection Defense: Mark the Channel, Not the Words

The model cannot tell an instruction from data, because both arrive as tokens in one flat stream. The defense that measured best marks which channel a token came from. It never reads the words.

Plan Mode's Real Value: the Agent Interrogates You First

Plan Mode's Real Value: the Agent Interrogates You First

A plan built from a vague prompt is a guess in a nicer font. ClarEval shows what skipping the interview costs: about 11 build attempts before one passes, versus about 1 if you ask first.

Package an Agent Workflow as a Claude Code Plugin

Package an Agent Workflow as a Claude Code Plugin

Your best agent workflow is six files that live on one machine. Rebuilt through Slack and memory, all six arrive intact 9.6% of the time. A plugin makes the whole loop one installable, versioned unit your team pulls.

One MCP Server Replaces Every Custom Tool Integration

One MCP Server Replaces Every Custom Tool Integration

A team wiring three agent surfaces to three systems by hand pays for nine adapters, 108 hours of year-one work. One MCP server per system, pointed at from each agent, costs 40.5 hours, and the ratio climbs with every agent the team adds.

Prompt Regression Tests: Gate AGENTS.md Changes in CI

Prompt Regression Tests: Gate AGENTS.md Changes in CI

A one-line AGENTS.md fix that visibly resolves the case you were chasing can still fail its own regression gate. Fixing one case here drops a six-case eval from 0.833 to 0.500 - and only a baseline that ratchets upward catches it before a user does.

Autonomous AI Agent Loops: Use the Git Log as Memory

Autonomous AI Agent Loops: Use the Git Log as Memory

An unattended loop that reads git log -5 each pass has a five-pass memory. In a 12-item plan, the decision made at pass 3 ages out at pass 9, two passes before pass 11 needs it. One line in PLAN.md pointing at the commit hash recovers it, for zero extra commits.

Long AI Coding Builds: Plan File Relay Instead of One Session

Long AI Coding Builds: Plan File Relay Instead of One Session

Auto-compact looks like memory because the session keeps running. Each pass is a lossy summary, and the loss compounds: two passes leave a Phase 1 decision a 25% chance of still being known. A plan-file relay holds 100% at any phase count.

Let Your AI Coding Agent Pick Tickets from the Backlog

Let Your AI Coding Agent Pick Tickets from the Backlog

Task selection is the one decision still routing every ticket through you. Write the priority order down once, and the 80 touches a sprint costs you collapse to 1 - same agent, same backlog.