Context Governance and Skill-Based Extension for AI Coding Tools

    This article examines why the behavior of AI coding tools matters less than their controllability, and how to evaluate that controllability through instruction-following rate, context efficiency, and composability. It explains how context pollution undermines extension mechanisms, then presents a practical approach based on on-demand skill loading, a unified command-line execution interface, layered context budgets, and structured output validation. Engineering teams will find a reproducible evaluation framework, concrete configuration examples, governance guardrails, and a four-step adoption roadmap for turning unpredictable model behavior into measurable, auditable, and reusable development workflows.

    1. The Real Problem: Controllability, Not Which Tool Is “Smarter”

    After adopting AI coding tools, teams often describe them in anthropomorphic terms. One tool behaves like a talkative colleague who thinks in leaps and occasionally makes small mistakes; another resembles a quiet engineer in the corner who delivers reliably. These comparisons sometimes get a regional twist: the expressive, high-density output is labeled “too outgoing,” while the restrained, spec-following behavior is called “too rigid.”

    These metaphors are vivid but offer almost no value for engineering decisions. What actually determines whether a tool can enter the development workflow comes down to three measurable dimensions:

    • Instruction adherence: Does it strictly follow constraints, or does it expand the scope of changes on its own?
    • Context efficiency: How much of the information consumed to complete the same task is actually useful, and how much is redundant?
    • Extensibility and composability: Can capabilities be loaded on demand and assembled with the existing toolchain?

    The anthropomorphic differences are essentially the result of different sampling strategies, system prompt designs, and training preferences, which place tools at different points on the proactive-to-conservative spectrum. Outgoing tools tend to fill in implicit requirements, refactor proactively, and add tests and documentation along the way. The benefit is fewer round trips; the risk is out-of-scope changes and noise. Conservative tools favor minimal changes and strict adherence to the task. The benefit is predictability; the risk is repeated clarification when requirements are ambiguous and slow progress.

    The right move is not to pick a side but to turn subjective impressions into reproducible evaluations. A minimal viable evaluation framework looks like this:

    1. eval_set:
    2. - id: bugfix_001
    3. prompt: "Fix the null pointer; only changes under src/util are allowed"
    4. assertions:
    5. - changed_files_max: 2
    6. - tests_pass: true
    7. - no_new_dependency: true
    8. - id: refactor_002
    9. prompt: "Extract duplicated logic; keep the public API unchanged"
    10. assertions:
    11. - public_api_diff: none
    12. - cyclomatic_complexity_delta: "<= -5"
    13. metrics:
    14. instruction_follow_rate: 0.9 # constraint adherence rate
    15. first_pass_success: 0.7 # first-pass success rate
    16. token_efficiency: 0.6 # share of effective context
    17. rework_rounds_avg: 1.2 # average rework rounds

    With these metrics, “interesting but error-prone” and “quiet but reliable” translate into differences in constraint adherence and rework rounds. Tool selection and task assignment then become clear: exploratory tasks and prototype validation can go to outgoing tools; changes involving permissions, data, or release paths should go to conservative tools with a mandatory minimal diff.

    2. Context Pollution: The Root Cause of Failing Extensions

    The second problem is more subtle. Many teams find that performance degrades as more capabilities are connected. The cause is usually not model regression but polluted context.

    Pollution takes four main forms:

    1. Structural redundancy: every capability ships with long descriptions and metadata, so the context window is filled with protocol text before the task even starts;
    2. Semantic conflict: multiple capabilities have similar descriptions and overlapping trigger conditions, making it hard for the model to choose, leading to wrong selections or stacked invocations;
    3. Accumulation of intermediate artifacts: retrieved snippets, logs, and failed retry records pile up layer by layer, diluting critical constraints;
    4. Non-composability: capabilities are tightly coupled and can only be enabled as a whole, with no way to trim them per task or chain them with existing scripts.

    A simple metric helps detect pollution:

    1. effective context share = tokens directly relevant to the current task / total input tokens

    When this ratio stays below 0.5 over time, the extension mechanism itself is becoming the bottleneck. Adding more capabilities will only accelerate the degradation.

    3. Skill-Based Extension: Capabilities as On-Demand Instructions

    A more robust approach is to change “capabilities” from always-on protocols to on-demand skill packages: normally only the name and a one-line purpose are exposed, and the full instructions are loaded into context only after the task matches. Skill organization should follow four principles:

    • Single responsibility: one skill solves one class of problems, and its description states clearly “when to use it and when not to”;
    • Progressive disclosure: metadata stays resident, the body is lazy-loaded, and reference material is loaded on demand at a third level;
    • Text first: use generic structured text to carry workflows and constraints, avoiding proprietary binary protocols;
    • Composability: skills connect through standard inputs and outputs rather than calling each other’s internal interfaces.

    The directory layout can be abstracted as:

    1. skills/
    2. code-review/
    3. SKILL.md # name, applicable scenarios, input/output contract
    4. checklist.md # third-level reference, read on demand
    5. migration-plan/
    6. SKILL.md
    7. templates/

    Keep the resident part on the order of tens of tokens:

    1. name: code-review
    2. when: static review before commit; not for performance test plans
    3. contract: takes a diff and a spec checklist, outputs a structured issue list

    4. The Command Line as a Unified Capability Interface

    For skills to be truly composable, they need a stable execution surface that scripts can call. The command line is the most common and lowest-coupling choice. Its advantages are explicit parameters, redirectable output, decidable exit codes, and natural orchestration.

    1. # The skill only parses arguments and enforces the workflow; actual capability comes from the general toolchain
    2. run-skill code-review --diff ./changes.patch --spec ./style.md \
    3. --output json > review.json
    4. if [ $? -ne 0 ]; then
    5. echo "Review failed; merge blocked" >&2
    6. exit 1
    7. fi

    In CI, it exists as deterministic gates:

    1. stages:
    2. - static_check # lint and static scanning
    3. - unit_test # unit tests
    4. - contract_test # API contract validation
    5. - policy_gate # sensitive data and permission policy

    The key constraint is that the model generates and explains, while deterministic judgments belong to the toolchain. Anything whose correctness can be expressed by an exit code should not be left to natural-language adjudication.

    5. Layered Context and Structured Output

    Two supporting engineering practices help. The first is layered context: the global layer holds non-negotiable constraints (coding standards, forbidden directories, dependency allowlists), the task layer holds goals and acceptance criteria, and the evidence layer holds retrieval results and logs, with quotas and eviction policies that discard duplicate and stale snippets first when limits are exceeded.

    1. [global] constraints and forbidden zones (resident, share <= 10%)
    2. [task] goals and acceptance assertions (resident)
    3. [evidence] retrieval/logs (50% quota, LRU eviction)
    4. [scratch] intermediate reasoning (clearable at any time)

    The second is structured output with validation and retry: require results that conform to a fixed schema, and on validation failure return only an error summary rather than the full context, avoiding secondary pollution.

    1. {
    2. "changed_files": ["src/util/parse.ts"],
    3. "risk": "low",
    4. "tests": {"added": 1, "passed": 12},
    5. "notes": "no new dependencies"
    6. }

    6. Governance, Metrics, and an Adoption Roadmap

    Governance needs three guardrails: sensitive data must be redacted before entering context; permissions follow least privilege, and write operations and release actions require human confirmation; all generated artifacts retain provenance and change records for auditing.

    For metrics, track four indicators: effective context share, first-pass success rate, average rework rounds, and cost per task. If any indicator deteriorates consecutively, first cut resident capability descriptions, then check the evidence-layer quota.

    Adoption can proceed in four steps: first, build an evaluation set and baseline; second, distill high-frequency workflows into single-responsibility skills; third, move deterministic validation into the pipeline; fourth, retire low-hit, high-conflict capability entries each quarter.

    7. Conclusion

    “Outgoing” and “rigid” are only style differences; engineering value depends on constraint adherence and predictability. The central tension in capability extension is the context budget: always-on, tightly coupled protocols continuously create pollution, while the combination of on-demand skill loading, a unified command-line execution interface, layered context, and structured validation converges uncontrollable generation into a measurable, auditable, and reusable development workflow. In general engineering practice on cloud platforms such as Baidu AI Cloud, the same approach applies to the orchestration and governance of common capabilities like container platforms, log services, and monitoring and alerting.