Cleaning Up Skills and AGENTS.md: From False Triggers to On-Demand Loading
As agentic coding teams turn more workflows into reusable skills, broad descriptions can load the wrong skill and flood the context with unrelated rules. This article explains how over-triggering happens, how to rewrite triggers around actions and evidence, and how to slim AGENTS.md so skills load only when they are needed.
Cleaning Up Skills and AGENTS.md: From False Triggers to On-Demand Loading
In agentic development, many teams already see the efficiency of turning experience into reusable skills. Performance profiling, database changes, test fixes, and release checks can be captured as skills that a coding assistant loads only for the right task. But as skills multiply and descriptions grow broader, the problem grows with them. The model may treat a migration skill as relevant simply because the task mentions words such as “database,” “query,” or “model,” then pull migration rules, checklists, and reference material into the context. The context fills with noise, and the code, errors, and constraints that actually matter get diluted.
This is not mysterious, and it is usually not a lack of model capability. It is a failure of skill routing and context control. A cleanup of Skills and AGENTS.md is not about deleting every rule. It is about loading the right skill, at the right time, at the right level of detail.
1. Why Skills Over-Trigger: Domain Words Replace Actions and Evidence
Skill descriptions often say something like “use this when working with databases, queries, models, or persistence.” That scope is too wide. Changing an ORM field mapping, adjusting a query condition, or fixing an ordinary persistence call can all look related to a migration skill. Once the skill triggers, its migration rules, checklists, and references enter the context and contaminate everything that follows.
The causes usually fall into four groups:
- Domain words replace action words. The description says “database” but never says “add a table,” “edit a migration script,” or “apply a schema change.”
- Intent is confused with evidence. “Optimize this query” does not mean a database migration is required. File paths, error signatures, and the scope of the change are missing.
- Skills are not layered. Entry skills, domain skills, and reference material sit together, so one trigger loads everything.
- AGENTS.md becomes an encyclopedia. Rules, commands, and background are all piled into the entry file, so every task carries a large set of irrelevant constraints.
2. What the Cleanup Should Achieve: Minimal Loading, Clear Routing, and Regression Checks
An effective cleanup should pursue three goals:
- Minimal loading: Load only the smallest set of skills and references needed to finish the task.
- Clear routing: Decide whether to trigger a skill from the action, the file scope, error characteristics, and the user’s intent together.
- Regression checks: Use positive and negative examples to confirm that the right skills trigger and the wrong ones do not, then keep monitoring.
More skills are not automatically better, and a longer AGENTS.md is not automatically safer. The entry file should work like a routing table, not a knowledge base. A skill should be an executable procedure, not a domain encyclopedia. Reference material should be an appendix that is read on demand.
3. Rewrite Trigger Boundaries: From Domain Words to Action Plus Evidence
Trigger conditions should be combinations that can actually be judged. A useful design has three states:
- must: Load the skill when a clear action and supporting evidence are present.
- never: Do not load it for certain ordinary edits.
- ask: When the boundary is unclear, ask or do a light check first instead of loading a heavy skill.
For example, rewrite “use when working with databases” as:
name: database-migrationtriggers:must:- The user explicitly asks to add, modify, or delete a table schema- The change involves the migration script directory or versioned schema-change files- The error explicitly points to a schema mismatch or a failed migrationnever:- Only query conditions or index hints are adjusted- Only a field mapping is changed and no schema change is involved- Only the parameters of an ordinary persistence call are fixedask:- The change includes both query logic and schema definitionscontext:load: on_demandreferences: summary_then_pointer
The key is that a trigger must include an action and evidence, not only a domain noun. A performance-analysis skill should load its full procedure only when sampling data, profiling results, or a cold-start analysis is actually needed. Ordinary code reading should not automatically pull in the entire analysis rule set.
4. Layer Skills and Disclose Them Progressively
Organize skills into three layers:
- Entry skills: Identify the task type and route it. Keep them short.
- Domain skills: Hold the concrete procedure, checks, and failure handling.
- Reference skills and materials: Hold long documents, detailed rules, and case libraries, and read them only when needed.
A practical layout looks like this:
skills/router/task-routing.mddatabase/query-edit/SKILL.mdmigration/SKILL.mdreferences/checklist.mdexamples.mdperformance/profiling-analysis/SKILL.mdreferences/sampling-notes.md
Keep only hard constraints, the routing table, and verification requirements in AGENTS.md. Do not copy skill bodies into it. Inside a skill, point to long material with a short summary plus a pointer: give a three- to five-line summary first, and read the full reference only when it is actually needed. The knowledge stays available without being poured into the context all at once.
5. Slim Down AGENTS.md: The Entry File Should Do Four Things
AGENTS.md should govern the entry point. Limit it to four jobs:
- State the goal and the boundaries: What the project is trying to solve, and which actions must not run automatically.
- Provide a task routing table: Which task loads which skill, and which situations must not load a skill.
- List hard constraints: Safety, compatibility, code style, and verification thresholds.
- Give a verification path: Which existing tests, static checks, or human reviews must run after the task.
A short example:
## Task routing- Query-condition or field-mapping edits: load database-query-edit- Adding or changing a table schema: load database-migration- Profiling data is available and a cold start needs to be located: load profiling-analysis- Ordinary code reading or log investigation: do not load migration skills## Hard constraints- Do not apply schema changes automatically- Do not skip the project's existing tests and static checks- When a skill trigger is uncertain, state the basis for the judgment before deciding whether to load it
Used this way, AGENTS.md is a routing and constraint layer, not a dump of every rule. When a rule needs to grow, put it in the relevant skill or reference instead of expanding the entry file.
6. Build Positive and Negative Examples and a Trigger Regression
A cleanup cannot rely on intuition. Build a small evaluation set for important skills:
- Positive examples: Tasks that should trigger the skill, such as “add a table and generate a migration script.”
- Negative examples: Similar tasks that should not trigger it, such as “only adjust a query condition” or “only fix a field mapping.”
- Boundary examples: Tasks that need a question or a lightweight check first.
Useful signals include the false-trigger rate, the missed-trigger rate, the average number of skills loaded, the number of skill conflicts, and the first-pass task success rate. After every change to a trigger description or to AGENTS.md, run the regression and confirm that ordinary edits are not being treated as heavy workflows. For skills that misfire often, narrow the trigger first instead of adding more “do not trigger” patches.
7. Handle Conflicts, Version Skills, and Clean Up on a Schedule
Skills can give conflicting instructions. Define priority at the routing layer: safety and data protection outrank process efficiency; project hard constraints outrank generic skill advice; a skill for the specific task outranks a broad domain skill. When the choice is still unclear, have the model state why it would trigger and what it would load before continuing.
Skills also need versioned maintenance: record why something changed, what it affects, the regression result, and the plan for retiring it. Review the set on a fixed schedule. Merge duplicates, move long documents down into on-demand references, remove skills that have gone unused, and rewrite descriptions that frequently misfire. Cleanup is not a one-time event. It is ongoing management of the context budget.
8. A Practical Cleanup Checklist
- Inventory every skill and mark the ones that frequently trigger by mistake.
- Replace broad domain-word descriptions with action-plus-evidence conditions.
- Add never and ask rules to every heavy skill.
- Move long references out of the entry file and into directories that are read on demand.
- Slim AGENTS.md down to routing, hard constraints, and verification requirements.
- Build positive and negative example sets, and run a trigger regression after changes.
- Define skill priority and a conflict-handling strategy.
- Set a maintenance cycle for merging, moving material down, and retiring skills.
When Skills and AGENTS.md shift from storing knowledge to routing work, the coding assistant can keep its attention on the current task. A real cleanup does not make skills disappear. It makes every load have a clear reason, a boundary that can be checked, and a path that can be maintained.
