The first hour with a coding agent is sharp. It respects your patterns, remembers your constraints, produces code that fits. Somewhere in the second hour it starts to drift. It forgets a decision it made earlier. It contradicts itself. The suggestions get vague. By the third hour you are fighting it.

You are not imagining it, and it is not the model having a bad day. It is context rot, and it has a specific, avoidable cause.

What is actually happening

Every file the agent reads, every command it runs, every dead end it explores stays in the session’s context window. Most of that is investigation: reading a test to understand why it failed, scanning a config, tracing a dependency chain. None of it is the work. All of it is the agent figuring out how to do the work.

By the time it starts implementing, the window is full of investigative debris, and models degrade as the window fills, well before it is technically full. So the actual coding happens in the worst possible context: cluttered, noisy, half-forgotten. The investigation poisoned the water the implementation had to drink.

The fix: delegate the investigation

Claude Code supports subagents. Separate agent instances with their own context window that do a task, report back a short summary, and vanish. Everything they read stays in their window and gets discarded. Your main session never sees the mess, only the conclusion.

The rule is simple. The main agent implements. Subagents investigate.

Instead of asking your main session to “find why this test is failing,” which drags every file it reads into your working context, delegate it:

Investigate the failure in AllocationServiceTests. Read the test, the service, and the repository. Report back what is causing the assertion failure and which files need to change. Do not fix anything.

The subagent reads five files, reasons through the problem, and hands back three sentences. Your main session takes those three sentences and implements the fix in clean context, as sharp as it was in minute one.

Same pattern for anything exploratory. Understanding how a library is used across the repo, scanning logs, mapping a dependency chain, reviewing a large diff before you read it yourself. All of it is investigation. All of it belongs in a subagent.

Why it works

Context rot needs two things: volume and time. A subagent has neither. It reads a handful of files, answers one question, and disappears before anything accumulates. The main session stays lean because it only ever receives conclusions, never the searching that produced them.

Think of it the way you would structure real work. You would not ask one person to research a problem, diagnose it, design the fix, build it, and review it in one unbroken sitting. You would split it. Subagents let you split it for the agent too.

Try it on your next debugging session. Delegate the diagnosis, implement from the summary, and notice that hour three feels like hour one.

While you are at it: skills and plugins worth installing

Two things you can bolt on, and it is worth knowing the difference.

A skill is a single markdown file, a SKILL.md, with a short description of when it applies and a body of instructions the agent loads on demand when a task matches. A plugin is a bundle that can contain skills plus tool-specific machinery like slash commands, hooks, and MCP servers.

The distinction matters because skills are the portable part. SKILL.md is a cross-agent standard: a skill written for Claude Code works in Cursor, Codex, Copilot, and a dozen other agents without modification, because it is just structured text. The plugin machinery around it often is not portable. If you care about not being locked to one tool, and after the Fable 5 suspension earlier this year a lot of us do, skills are the unit to invest in. The knowledge in them survives a tool switch. The platform-specific wrapper does not.

There are whole marketplaces of skills now, not just plugins. Directories carrying well over a thousand security-scanned skills across twenty-plus agents, browsable and installable individually, plus universal installers that drop the same skill into every agent you use at once. You do not have to adopt a full plugin bundle to get one useful behaviour.

The categories that pay off across almost any setup:

The one I would install first is Superpowers, Jesse Vincent’s skills framework and currently the most-starred in the ecosystem. It is not a point tool. It bundles a whole methodology as composable skills that auto-trigger: it refuses to write code until it has brainstormed the requirement with you and you have signed off on a design, breaks the work into small planned tasks, runs implementation in an isolated git worktree under real red-green-refactor TDD, and then does a code-review pass from a fresh agent before finishing. It is, essentially, the disciplined version of the two habits this whole piece is about, structured and enforced so you do not have to remember to do them. It installs from the official marketplace and runs on Claude Code, Codex, and Claude Desktop, so it is not locked to one tool.

Beyond that, a few point skills earn their place:

A security reviewer that watches the edit loop and flags command injection, unsafe deserialisation, and cross-site scripting before you commit. Anthropic’s security-guidance on Claude Code, Semgrep elsewhere. Highest value, lowest effort.

A commit and PR skill that turns edit-to-open-PR into one chained action: stage, generate a conventional-commit message from the diff, push, open the PR, without leaving the terminal. The most boring add-on on any list, and the one that saves the most keystrokes.

A live-docs lookup (Context7 is the common pick, and it travels across tools) so the agent stops hallucinating version-specific APIs and pulls the current signature instead.

A real-browser bridge (Chrome DevTools MCP) that lets the agent see actual rendered output, console errors, and network calls rather than guessing at frontend behaviour from source alone.

Installing is a two-command loop on Claude Code: /plugin opens the manager, and /plugin marketplace add / pulls in a marketplace, which is just a git repo. Standalone skills are simpler still: drop the folder into ~/.claude/skills/ and start a new session. On Cursor, VS Code, and the others, the path differs but the SKILL.md inside does not.

Start with Superpowers if you want the whole disciplined workflow in one install, or the security reviewer and commit skill if you prefer to add point tools one at a time. Either way, add the rest only when you feel the specific pain each one solves, because every skill and plugin you load is context the agent carries, and more is not free.