Large-Scale AI Agent Configuration Cleanup: Best Practices for Maintaining Skills and AGENTS.md

    As large language models become more capable, outdated Skill definitions and project-level AGENTS.md files can consume context, slow down responses, increase costs, and lead agents toward unnecessary actions. This article explains how to identify configuration-model mismatches, redesign Skills around precise task intent, audit and consolidate rules, introduce regression testing, avoid over-cleaning, and build a configuration process that evolves with model capabilities.

    As large language models become better at reasoning, developers are delegating more work to AI agents—from static code analysis and performance profiling to production incident investigation.

    However, one problem is easy to overlook: after a model upgrade, carefully designed Skill definitions and project-level configuration files such as AGENTS.md may stop delivering value. Instead, they can consume context, interfere with decision-making, increase latency, and raise costs.

    This article discusses why a thorough cleanup may be necessary and how to perform it systematically.

    1. The Core Problem: Configuration-M列odel Mismatch

    When developers first adopt AI agents for software development, they often create highly detailed Skills for every possible scenario. For database-related work, for example, they might define a combined Skill covering queries, schema design, migrations, and performance optimization. They may also add a long list of trigger keywords to AGENTS.md.

    The original goal is reasonable: reduce the model’s interpretation burden and ensure that database-related requests automatically load the relevant rules.

    As models become more capable, however, the side effects of broad configuration become increasingly visible. Modern models understand natural language more precisely, but broad trigger terms can still lead them to make incorrect associations.

    Consider a database-related task. A developer may only need to modify an ORM model or fix a simple query, yet the agent may decide that migration-related Skills are also required. It then loads migration rules, validation procedures, and historical reference material into the context. The result can include:

    • Relevant context being pushed out: Code snippets and log information directly related to the task may be truncated.
    • Higher decision latency: The model must process more tokens, increasing response time.
    • More errors: Unnecessary rules can cause the agent to perform complex and incorrect operations, such as applying optimistic-locking checks that the task does not require.
    • Uncontrolled costs: In token-based usage models, every irrelevant Skill load creates a direct financial cost.

    This is fundamentally a mismatch between static configuration and dynamic model capability. Earlier models had weaker generalization abilities, so developers compensated by providing detailed instructions. Newer models can generalize more effectively, which means overly broad rules may become noise rather than assistance.

    2. The Central Principle: Classify by Task Type, Not Domain Keywords

    The first step in solving this problem is to adjust the granularity of Skills. Instead of using domain terms such as “database,” “network,” or “file system” as primary triggers, define Skills around observable and verifiable task types.

    For example, database-related work could be divided into:

    • schema change assessment: Triggered only when the model needs to modify a table structure or data model.
    • query performance diagnosis: Triggered only when the model needs to analyze a slow query or execution plan.
    • data integrity validation: Triggered only when the task involves data migration or bulk updates.

    Each Skill should clearly state both where it applies and where it does not apply. For example, the first line of a query performance diagnosis Skill might say:

    This Skill applies only when the user explicitly asks to analyze query latency, index usage, or an execution plan. Modifying an ORM model or adjusting connection-pool settings is outside its scope.

    These negative conditions are highly valuable because they directly prevent incorrect associations.

    Global rules in AGENTS.md should also be simplified. The file is not an encyclopedia. It should define operational boundaries. A well-designed AGENTS.md should contain:

    • An overview of the project’s technology stack and directory structure.
    • Prohibited operations, such as directly modifying production configuration.
    • Operations that require additional approval, such as changes to payment or financial calculation logic.
    • General coding conventions. Specific business rules should not be placed here; they belong in the relevant Skill.

    3. A Complete Cleanup Process: From Audit to Refactoring

    To make sure the cleanup is thorough, it is useful to organize the work into four stages.

    Stage 1: Audit the Configuration and Quantify the Cost

    Start by creating an inventory of all defined Skills and AGENTS.md rules. For each Skill, record:

    • Trigger keywords.
    • Estimated token footprint.
    • Number of actual triggers in the past 30 days.
    • Whether the Skill made a measurable positive contribution to the final result after being triggered.

    Use the logging capabilities of the agent platform when available. If suitable logs do not exist, use a shadow mode approach: run the agent with both the old and new configurations in a non-production environment, then compare output quality and token consumption.

    Quantifiable data provides a stronger basis for deletion and redesign decisions than intuition alone.

    Stage 2: Remove Duplicates and Consolidate Overlapping Rules

    Many Skills overlap. For example, a “code review” Skill may include security, performance, and style checks, while a separate “security review” Skill repeats many of the same rules. If both Skills are triggered, the context cost can effectively double.

    In such cases, extract the shared content into a common baseline and reference it instead of copying it into multiple Skills.

    One practical approach is to define a general review baseline in AGENTS.md. Individual Skills then describe only their scenario-specific requirements. For example:

    • The “security review” Skill can state that, in addition to the general review baseline, it checks for hard-coded sensitive information and dependency vulnerabilities.
    • The “performance review” Skill can state that, in addition to the baseline, it focuses on loop complexity and memory allocation.

    This structure reduces duplication while keeping specialized requirements explicit.

    Stage 3: Rewrite Triggers Around Semantic Intent

    This is the most important step. Replace simple keyword matching with trigger descriptions based on the user’s semantic intent.

    Instead of using “database,” “SQL,” and “ORM” as triggers, define conditions such as:

    • Trigger condition: The user asks to explain the execution plan of a SQL statement, compare the performance impact of two indexes, or provide a rollback plan for a schema change.
    • Do not trigger when: The user only asks to add a field, change a record’s default value, or check the current state of a record.

    A useful format for trigger descriptions is a three-part structure:

    Scenario + goal + output format

    For example:

    When the user provides a slow-query log and asks how to optimize it, this Skill should provide index recommendations, SQL rewrite suggestions, and validation steps in an optimization report that includes expected benefits.

    This is far more precise than a description such as “handle database performance issues.”

    Stage 4: Use Version Control and Regression Testing

    Configuration cleanup is not a one-time activity. It is an ongoing process.

    All Skill definitions and AGENTS.md files should be stored in version control, and every change should include a description of what changed and why.

    More importantly, create a set of regression test cases. Use 20 to 30 representative development tasks as a fixed test set. Run the agent with the old and new configurations and record:

    • Output accuracy.
    • Average response time.
    • Token consumption.

    A cleanup should be considered successful only when the new configuration performs at least as well as the old one on the test set while significantly reducing token usage.

    In one cleanup effort, 12 broad Skills were consolidated into five precisely defined Skills, while the rules in AGENTS.md were reduced from 80 lines to 25. On the same set of performance-analysis tasks, token consumption fell by 43%, while task completion increased from 82% to 91%.

    The main reason was that the model was no longer distracted by irrelevant rules and could focus on the actual code paths.

    4. Avoiding the Risks of Over-Cleaning

    A cleanup does not mean “delete as much as possible.” Removing too much configuration can create new problems:

    • Without necessary constraints, the model may invent an operational process, such as executing a high-risk command without authorization.
    • With too few Skills, the model may try to solve complex scenarios using only general knowledge and produce poor results.
    • Rare but important Skills may be deleted, leaving the agent without guidance during a serious incident.

    Cleanup decisions should therefore follow a two-part rule:

    • For frequently triggered Skills, first verify their precision. If they consistently contribute positively after being triggered, keep them and improve their trigger conditions.
    • For low-frequency but high-risk operations, such as rollback scripts and permission audits, keep the Skills even if they are rarely used. Instead, make their trigger conditions stricter to prevent accidental activation.

    5. Looking Ahead: Making Configuration Evolve

    Newer models already have strong instruction-following and context-understanding capabilities. Configuration should take advantage of this by shifting from static rules toward dynamic boundaries.

    Practical approaches include:

    1. Define when the model may proceed without a Skill in AGENTS.md. For example: “If an undefined subtask falls within general programming capabilities, you may handle it without loading a Skill. If it involves sensitive data operations, stop and ask for clarification.”

    2. Use the model’s summarization capabilities to suggest configuration updates. After completing a complex task, ask the model which rules were redundant and which were missing. Developers can use this feedback to guide future changes and create a continuous optimization loop.

    3. Reevaluate every Skill regularly. As models continue to improve, review the Skill set every two model versions and remove rules that have effectively become part of the model’s built-in capabilities.

    These practices are important not only for individual developers but also for teams. When multiple people share an agent configuration, every change should be reviewed to prevent individual preferences from contaminating global rules.

    A configuration repository can also include automated checks. For example, it can flag trigger descriptions that rely on overly broad verbs such as “handle” or “analyze” and prompt the author to make them more specific.

    6. Final Thoughts: Cleanup Is a Means, Not the Goal

    The purpose of cleaning up Skills and AGENTS.md is to help agents maintain a focused, precise, and efficient cognitive structure in complex engineering environments.

    An experienced engineer does not memorize every manual. Instead, they know which page to consult in a given situation. Agent configuration should follow the same philosophy.

    By classifying tasks precisely, describing triggers semantically, managing versions carefully, and continuously validating changes through regression tests, teams can better use the reasoning capabilities of modern models and make each agent invocation more economical, reliable, and controllable.

    Do not be afraid to delete rules that once required significant effort to write. The value of a configuration is not measured by its line count. What matters is whether the model can focus, at every step of its reasoning, on the work that actually deserves attention. That is the most meaningful benefit of a large-scale cleanup.