Context Governance for LLMs: A Cleanup Guide for Skills and AGENTS.md
As teams upgrade to newer coding models, they often find that existing context assets—skill descriptions and project-level files like AGENTS.md—start to slow the model down instead of helping it. This article explains why overly broad trigger conditions and bloated instruction files cause frequent misfires, and lays out a practical cleanup process: auditing your context assets, narrowing triggers to specific actions and outputs, layering instructions instead of injecting everything, and using a regression set to keep misfire rates low. You will get concrete before-and-after examples, a four-step audit method, and common pitfalls to avoid.
1. The Symptom: Why a Stronger Model Makes Old Configs a Liability
After upgrading to a newer generation of coding models, many teams report a familiar sequence: first comes the “wow” moment, then the confusion of “why did it suddenly get dumber?” Instructions that used to be followed precisely start being executed in a generalized way, capabilities that were only occasionally triggered get invoked constantly, and answers grow longer and slower—sometimes drifting away from the task entirely. The problem is usually not the model itself, but the context assets we have piled up around it: capability description files (the Skill type) and project-level instruction files (the AGENTS.md type).
The original intent of these files was to front-load domain knowledge so the model takes fewer wrong turns. But once the model becomes more sensitive to natural-language descriptions, any loosely worded trigger condition gets taken seriously. Configuration shifts from an asset to a burden.
2. Root Cause One: Trigger Conditions Written Too Broadly
A typical bad example looks like this:
Use when working with databases, queries, models, or persistence.
The problem is the scope is far too wide. You only wanted to change a single ORM field or fix one query, but the model decides that “database migration capability” is highly relevant to the current task and pulls in migration rules, checklists, and reference material all at once. The result:
- Context gets crowded out by irrelevant content, lowering the density of useful information;
- The model’s attention is diluted—it follows the “more complete rules” while losing sight of the actual goal;
- Token costs rise, responses slow down, and long tasks lose focus more easily midway.
3. Root Cause Two: Project Instruction Files Turn into Rule Compilations
The common degradation path for AGENTS.md-style files is this: every time something goes wrong, someone appends another “must… never…”. Six months later it has become a rule compilation nobody dares to delete, full of entries that only hold in extremely narrow scenarios yet get injected unconditionally into every conversation. The model cannot tell which rule applies, so it takes all of them literally—and its behavior becomes conservative, verbose, and process-heavy.
4. The Audit: Give Your Context Assets a Checkup
A four-step approach works best: quantify first, then act.
- Inventory: list every capability description file and project instruction file, recording its trigger conditions, injected size, last modified date, and associated scenarios.
- Measure hit rate: sample tasks from the past two weeks and mark which capabilities were triggered, and how many of those were misfires.
- Calculate cost: measure what share of tokens this content takes up in each session; anything above 30% should be treated as high risk.
- Prioritize: clean up “high misfire + high volume” items first, and schedule the rest.
5. The Convergence Principle: Write “When to Use” Narrowly
The core move is to change trigger conditions from “domain words” to “action + output + boundary”. A comparison:
# Before (too broad)Use when working with databases, queries, models, or persistence.# After (narrower)Use when the change alters schema definition or requires a data migration step.Do not use for read-only query tuning or field rename without schema change.
Three reusable rules:
- Write positive conditions as specific actions and outputs, not academic nouns;
- Explicitly state the “not applicable” scenarios to give the model an exclusion;
- Each file should serve a single goal, with no overlap between capabilities.
6. Structural Reorganization: Layered Injection Instead of Full Injection
Split instructions into three layers, loaded on demand:
- Global layer: keep only general engineering conventions, within a hundred lines;
- Directory layer: instructions placed in subdirectories take effect along the task path;
- Task layer: checklists strongly tied to the current change, brought in temporarily.
Example layout:
AGENTS.md # Global: build, test, commit conventionsservices/api/AGENTS.md # Directory-level: API and data conventionsskills/perf-analysis/ # Task-level: loaded only during performance profiling
7. Working with Performance Profiling Capabilities
Take cold-start optimization for an inference service as an example. The right approach is “wake on demand”: a human first confirms the task is performance profiling, then the profiling guidance is loaded, producing structured conclusions (hot operators, wait time, memory peak), and only then does the optimization iteration begin. If instead you write it as “use whenever a model is involved”, it will misfire repeatedly during ordinary business changes and actually slow down iteration.
8. The Verification Loop: Hold the Line with a Regression Set
Cleanup is not a one-time job; it needs to be measurable:
- Build a regression set of 20–30 representative tasks covering both “should trigger” and “should not trigger”;
- After each change, track misfire rate, average context length, and task completion rate;
- Set thresholds, for example misfire rate below 5% and context share below 20%;
- Fold the results into continuous integration to prevent configuration regressions.
9. Common Pitfalls
- Delete without rewriting: removing redundancy but failing to add “not applicable” scenarios—misfires will bounce back;
- Chasing comprehensiveness: one file covering every scenario inevitably leads to generalized execution;
- Ignoring versioning: unrecorded config changes make problems impossible to trace;
- Treating instructions as documentation: instructions are behavioral constraints for the model, not an encyclopedia for humans.
10. Conclusion
The newer generation of models follows context and instructions more “seriously”, which demands that we govern Skills and AGENTS.md like code: narrow conditions, layered structure, regression-testable changes. One thorough cleanup buys not just lower token overhead, but stable, predictable engineering output.
