What is advanced context engineering for coding agents?

Short answer

"Advanced Context Engineering for Coding Agents" is an August 2025 essay by Dex Horthy of HumanLayer, based on a talk at Y Combinator. Its method, frequent intentional compaction, builds the whole workflow around context: work in three phases (research, plan, implement), write each phase to a markdown file, start fresh windows often, keep context use around 40 to 60 percent, and spend human review on the research and the plan.

The problem it starts from

The essay opens with a familiar complaint: “AI coding tools struggle with real production codebases.” It cites research suggesting that in large, established codebases AI tools can make developers less productive. Dex Horthy’s argument is that the model is not the bottleneck. The context is. A coding agent that spends its window on file searches, build logs and long tool output ends up working from a cluttered, partly wrong picture of the code.

His answer is to design “your ENTIRE WORKFLOW around context management”, and he calls the method frequent intentional compaction.

The method in three phases

Phase What the agent does What it writes What the human checks
Research Finds the relevant parts of the codebase, how information flows, likely causes A research file Is the understanding of the system right?
Plan Lists the exact steps, files to edit and how, testing and verification per phase A plan file Is this the right change, in the right order?
Implement Works through the plan phase by phase Updates the plan with status after each verified phase Does it pass the verification in the plan?

Every phase ends in a file, and the next phase starts in a fresh window that reads that file. That is the compaction: “simply distilling them into structured artifacts”. For individual developers the simplest form is a prompt like “Write everything we did so far to progress.md” and then starting a new session.

The rules behind it

  1. Keep context use at 40 to 60 percent. The essay aims for that range depending on how complex the problem is, rather than filling the window until something breaks.
  2. Optimize for four things. Correctness, completeness, size and trajectory of what is in the window.
  3. Know what hurts most. In the author’s ranking, the worst things in context are, in order: incorrect information, missing information, too much noise.
  4. Use sub-agents for context control. “Subagents are about context control”: a sub-agent searches and reads in its own window and returns a summary, so the parent window stays clean. This matches what Cognition observed about Claude Code, whose sub-agents usually answer questions rather than write code.
  5. Review upstream. “A bad line of code is… a bad line of code. But a bad line of a plan could lead to hundreds of bad lines of code.” The author writes that he cannot read 2,000 lines of Go every day, but can read 200 lines of a good implementation plan.

What it claims, and what it does not

The essay reports a fix in BAML, a 300k-line Rust codebase, approved by a maintainer the next morning, and about 35k lines of cancellation and WASM support shipped by two people in roughly seven hours. It also reports a failed seven-hour attempt to remove Hadoop dependencies from parquet-java. These are one team’s experiences, not a controlled study. The method itself is close to what Anthropic recommends for long tasks: structured note-taking, compaction and sub-agents with clean windows.

The common misunderstanding

Many developers treat compaction as something the tool does for you when the window is full. Automatic compaction is a safety net: it summarizes whatever is there, at whatever moment, and details that do not make the summary are gone. Intentional compaction is a work habit. You decide when to stop, and you decide what the summary contains, because it is a research note or a plan you will review. The quality of the next session depends on that file, not on how large the window is. For the automatic version, see What is context compaction?

What this means for a team

The essay’s strongest team point is about review: when a team reviews research and plans instead of only diffs, the files become the shared record of why the code changed. The essay connects this to spec-driven development, where the specs became the team’s source of truth. What these files do not solve is knowledge that spans tasks: a convention learned in one plan is not in the next developer’s fresh window unless someone writes it into the repo’s rules. See What is context rot? for why fresh windows help, and How do you set up context engineering for a team? for the shared part.

Where Bombos fits

Fresh windows only work if the agent can find what was learned before. Bombos is a plugin that gives every coding agent a team uses, Claude Code, Codex, Cursor or Copilot, one shared memory of team knowledge, past decisions and learned rules, next to what is already in the repos. A research phase can start from that instead of rediscovering it, and you can see which knowledge an answer used. One developer can try it first for their own agents.

Related questions

What is frequent intentional compaction?

Deliberately pausing as the context fills, writing the state of the work to a file such as progress.md, and continuing in a fresh window from that file. It differs from automatic compaction because you decide when it happens and what the summary contains.

Does this only work with Claude Code?

The essay uses Claude Code and links to its research, planning and implementation slash command prompts in the humanlayer/humanlayer repo on GitHub. The method itself is tool-independent: any coding agent that can read and write files can follow it.

What results does HumanLayer claim?

Among others, a bug fix in BAML, a 300k-line Rust codebase the author did not know, that a maintainer approved the next morning. The essay also reports failures, such as an attempt to remove Hadoop dependencies from parquet-java. These are the author's own reports, not an independent study.

What goes into the research and plan files?

Research covers the relevant parts of the codebase, how information flows and likely causes. The plan lists the exact steps, the files to change and how, and how to test and verify each phase.

Sources

  1. Advanced Context Engineering for Coding Agents (HumanLayer, Dex Horthy, August 2025)
  2. Effective context engineering for AI agents (Anthropic, September 2025)
  3. Don't Build Multi-Agents (Cognition, June 2025)
The first half hour · free

What does your AI forget?

  1. 01You tell us which AI you use and where it keeps starting over.
  2. 02We show what a shared memory changes there, on your own examples.
  3. 03You keep the plan, with or without Bombos.
Piet Baudoin
Piet BaudoinYou talk to Piet, from the Bombos teamDutch team from Utrecht and Nijmegen · data in Europe
We reply the same working day.