All articles

Keeping Your Main Context Clean with Subagents

The context window is a limited, shared resource. Every file you read and every search you run in your main session takes up space and attention. Subagents are the cleanest way to protect that space, because their work happens somewhere else and only the result comes back.

The core move

When a task involves reading a lot but producing a little, hand it to a subagent. A search across fifty files might return one answer. Do it in the main session and you carry all fifty file dumps forward. Do it in a subagent and you carry just the answer. Your main context stays focused on the decisions that matter.

What to offload

  • Broad searches and investigations.
  • Code review, where the diff and surrounding reads are noise once the report is written.
  • Any "go find out X" question where you only need the conclusion.

Combine with the built-in context tools

Subagents work alongside Claude Code's context commands:

/context   # see how full the window is
/compact   # summarize mid-task and keep going
/clear     # start fresh between unrelated tasks

A good rhythm is to use subagents for the noisy investigation, /compact when a session gets long but you want to keep going, and /clear when you move to something unrelated.

The payoff

Think of your main session as the place where decisions get made, not where raw material piles up. Push the reading, searching, and reviewing out to agents that run in their own windows, and keep your main context for the plan and the work. Over a long session, that discipline is the difference between a sharp assistant and one buried in old file dumps.

Comments

Be the first to comment.