Refactoring Skills and AGENTS.md After a Major LLM Upgrade
When a base model gets a generational capability jump, the first thing developers notice is often not smarter answers but old configuration holding the agent back. This article explains why model upgrades force a context cleanup, how to audit existing Skills and AGENTS.md with ablation experiments, which principles to apply when trimming rules, how to layer context for on-demand loading, and how to keep the configuration maintainable with review gates and metrics. It also lists common pitfalls to avoid during the refactor.
1. What Is Really Happening: Why Model Upgrades Force a Context Refactor
Every time a base model gains a generational capability improvement, the first thing developers notice is often not “smarter answers” but “the old configuration is now holding us back.” The “big cleanup” mentioned in the original discussion is essentially a context engineering problem: the large amount of constraints, examples, and patch-style rules that were piled into system prompts, skill descriptions, and repository-level documentation to compensate for weaker models have turned from necessities into noise sources in front of a stronger model.
One common misunderstanding needs clearing up first: Skills and AGENTS.md are not magic switches. They are two types of context injection carriers. A Skill usually describes “what capability to invoke under which conditions, and which steps to follow,” while AGENTS.md usually describes “what conventions this codebase has, how directories are organized, and how tests are run.” Together they form the static knowledge layer that an AI coding tool reads before reasoning.
Old configuration fails for three main reasons:
- Redundant constraints conflict with each other: Hard rules added in earlier versions to keep the model on track, such as “never do X,” “always do Y first,” and “stop immediately when Z happens,” now compete for the attention budget once the model has strong instruction following and self-checking abilities, and may even contradict one another.
- Granularity mismatch: Details of one-off tasks were written as permanent rules, so irrelevant content gets loaded on every interaction.
- No layering: All knowledge is laid out flat in a single file and cannot be loaded dynamically by task type.
2. Start With an Audit: Build an Inventory of Configuration Assets
The first step of a refactor is not deletion but measurement. It is worth doing a full inventory of existing context assets and producing a list with at least the following fields:
| Field | Meaning | Criterion |
|---|---|---|
| Entry source | Who added it and when | Recheck if unchanged for over six months |
| Trigger frequency | Loaded every turn or on demand | Consider pushing low-frequency entries down a layer |
| Conflict flag | Semantically overlaps with other entries | Merge on any overlap |
| Measured benefit | Whether quality drops after removal | A candidate for deletion if nothing drops |
The audit phase should rely on controlled experiments rather than subjective judgment. Prepare a fixed regression task set covering four scenarios: code generation, refactoring, defect localization, and documentation writing. Run it under two conditions, “keep all configuration” and “remove a single entry,” then compare pass rate and average token consumption. A skeleton evaluation script looks like this:
# Pseudocode: single-entry ablation experimentbaseline = run_suite(tasks, context=full_config)for item in config_items:trimmed = full_config - {item}result = run_suite(tasks, context=trimmed)if result.pass_rate >= baseline.pass_rate - 0.02:mark_as_removable(item) # No noticeable drop, becomes a deletion candidate
The 0.02 threshold here is only illustrative and should be set according to the business’s tolerance for errors. The key principle is that every deletion must be backed by data, so that “trimming by feel” does not cause a capability regression.
3. Trimming Principles: From Piling Up Rules to Describing Goals
New models generally have stronger long-context understanding, multi-step reasoning, and tool-calling planning, so configuration should shift from imperative enumeration to goal-oriented description.
- Delete common sense the model has already internalized. Entries such as “code needs indentation” and “variables should have meaningful names” are capabilities the base model has already mastered reliably; keeping them only dilutes key information.
- Merge synonymous constraints. Converge sentences that express the same intent but are scattered across multiple places into a single entry, and state the priority order explicitly, for example “security > runnability > style preference.”
- Replace long lists with positive examples. Instead of listing ten prohibitions, provide a few dozen lines of canonical example code for the model to align its style with.
- Control the size of a single file. In practice, keeping the repository-level documentation concise and structured makes it easier to follow consistently; an overly long file should be split and referenced on demand.
A skeleton example of a trimmed AGENTS.md:
# Project Conventions- Tech stack and directory responsibilities: see docs/architecture.md- Test command: run through the project script entry point only; do not call internal implementations directly- Checks that must pass before committing: static analysis + unit tests- Style baseline: the examples under examples/ are the single source of truth# Collaboration Preferences- Give the minimal viable change first, then discuss extensions- For data structure changes, output an impact analysis first
4. Layering and Dynamic Loading: Make Context Appear on Demand
The core benefit of the refactor comes from layering. A three-layer structure is recommended:
- L1 global layer: Cross-project general preferences, smallest in size, loaded permanently.
- L2 repository layer: Conventions of the current codebase, loaded when switching repositories.
- L3 task layer: Injected only when a specific task is triggered, such as database migration or frontend component standards.
Skill definitions follow the same logic. They should adopt a five-part structure of “applicable condition, input, execution steps, output format, failure fallback,” and make mutual exclusion explicit so that two skills are not activated in the same scenario and cause the agent to waver. Example:
skill:name: schema-migrationwhen: "persistent structure changes are involved"steps: [impact analysis, generate migration script, provide rollback plan]output: "change description + script + verification checklist"fallback: "ask first when information is insufficient; do not invent fields"
5. Automated Governance and a Measurement Loop
A one-off cleanup will rot again quickly, so a standing mechanism is required:
- Include it in the review process: Treat context files and skill definitions like code, and require review for changes.
- Set size and redundancy gates: Add checks to continuous integration that alert when a threshold is exceeded or duplicate semantics are detected.
- Measure continuously: Track three metrics, task pass rate, average number of interaction turns, and the share of context tokens, and build a trend dashboard. Collection can rely on general-purpose cloud logging services and monitoring/alerting capabilities, with object storage used to archive historical evaluation results.
- Run regression regularly: After every base model or AI coding tool upgrade, rerun the regression task set and reuse the ablation experiment to locate newly introduced redundancy.
6. Common Pitfalls
- Treating the cleanup as “delete down to the minimum”: The goal is signal-to-noise ratio, not absolute brevity.
- Changing files but not the process: Without review and gates, configuration quickly slides back into chaos.
- Ignoring failure fallback design: A skill description with no guidance on “what to do when information is insufficient” is a major source of unstable behavior.
- One big-bang rewrite: Roll out in batches with gradual exposure, and keep a rollback-capable version for each batch.
In summary, the real work created by a model capability upgrade is making the implicit knowledge once used to “patch model weaknesses” explicit, structured, and layered. After this round of governance, developers typically gain more consistent adherence, lower context overhead, and configuration assets that can be maintained for the long term. If a team already uses the relevant toolchain on Baidu AI Cloud, the gates and measurement steps above can be embedded directly into the existing pipeline to reduce additional build costs.
