# Agent Context File Hygiene: Two Sections, Nested by Directory
<!--
ref: @knowledge/protocols/agent-context-file-hygiene
type: protocol
tags: [documentation, agent management, context files, best practices]
triggers: [agent makes repeated errors, context files contain outdated information, need to clarify agent instructions]
trigger_prompt: When an agent consistently performs incorrectly or when context files are suspected of containing stale or irrelevant information.
version: 2
updated_at: 2026-10-18T05:41:34.925Z
-->

As models get better, the right agent instruction file gets *shorter* — down to the two things the model genuinely cannot work out on its own.

*Synthesized from Sean Kochel, "Turning a Vibe-Coded Demo Into a Real Product (11 Things)."*

The instinct is that more context makes a better agent. Sean Kochel's position is the inverse: what belongs in a `CLAUDE.md` or `AGENTS.md` has *narrowed* as model capability has risen. Most such files are padded with things the model would infer correctly anyway — and that padding isn't free, because every line that goes stale becomes a landmine.

## The two-section rule

Document only:

1. **Known anti-patterns** — things the agent should specifically *not* do in this codebase.
2. **Non-inferables** — knowledge that exists only in your head, or conventions the agent could reconstruct only by reading several files first. If it's derivable from a single file, it doesn't belong.

Everything else gets deleted.

## Pruning an existing file

1. Take each line and ask: *could the model derive this from one file it would already open?* If yes, cut it.
2. Of what remains, ask: *is this an anti-pattern or a non-inferable?* If neither, cut it.
3. Of what still remains, ask: *is this still true?* Anything you can't confirm on the spot is a liability, not context — cut it and re-add it when you've verified it.

## Nest by location

Rather than one enormous root file, place an agent markdown file in each meaningful subdirectory — API, UI, services. An agent working in the API directory picks up the API file, so instructions arrive layered and scoped to where the work is happening. This also bounds the blast radius of any single stale line to one subtree, and keeps the root file small enough to actually re-read.

## The failure mode this guards against

Stale documentation is the nastiest problem in this category, because it is *silent*. A model will keep making the same bad decision on the strength of one obsolete line buried in a context file — and it will never tell you that's why. So you debug the prompt. Then the model. Then the task decomposition. You will not think to debug the one dead line of context, because nothing in the failure points at it.

**The operational consequence:** when an agent is persistently, inexplicably wrong in the same direction, audit the context files *before* you rewrite the prompt.

*Corollary: routing changes through structured specs gives every change a traceable record, which is what keeps documentation from silently drifting out from under the agent in the first place — see `spec-driven-development`.*

---

*Related: `@content/youtube/nate-herk/i-deleted-all-my-claude-skills-and-claude-got-smarter` · `@content/youtube/sean-kochel/this-free-tool-runs-5-ai-coding-agents-at-once` · `@content/youtube/aie/how-one-founder-manages-20-ai-coding-agents-at-once-ryan-carson-untangle` · `@content/youtube/yc-root-access/meet-the-devtool-founders-building-for-ai-agents` · `@content/youtube/aie/the-death-of-developer-advocates-stephanie-jarmak-sourcegraph`*

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*