Regression Testing for AI Coding Skills: A Practical Guide to Golden Sets

    This article explains why AI coding Skills become unstable after small edits and how a Golden Set solves the problem by holding the test cases and expected answers fixed so that only the Skill version changes. It covers the four requirements of a usable Golden Set, a recommended directory layout that keeps tests alongside the Skill, four categories of test cases (positive, negative, boundary, and error), automated grading with structured output, usage discipline, and common pitfalls to avoid. Readers will learn how to build a reliable regression baseline for LLM-driven Skills and integrate it into their iteration workflow.

    1. Why Skills Break So Easily

    In AI coding tools, a Skill is essentially a structured instruction document for the model. It defines when to trigger, when not to trigger, how input fields are validated, which decision rules apply, and which template the output follows. Unlike a deterministic function, a Skill’s final behavior is determined by three things together: the instruction text, the model’s reasoning, and the input data. As a result, rewording a single sentence or reordering a constraint can make previously stable behavior drift.

    Three pain points show up most often in engineering practice:

    • Fuzzy trigger boundaries: the Skill fails to trigger when it should, or triggers when it should not.
    • Output structure drift: missing fields, incomplete dimensions, inconsistent date formats.
    • Inconsistent decision criteria: the same batch of data gets classified differently across versions.

    To tell whether a change made things better or worse, spot-checking a few samples by hand is not reliable. You need a fixed measuring stick.

    2. The Core Idea of a Golden Set: Leave Only the Skill Version as the Variable

    A Golden Set is a collection of fixed test cases with known answers. Its value is not in testing “a lot,” but in controlling variables: the cases stay unchanged, the expected answers stay unchanged, and the only variable is the Skill version. Any change in pass rate can therefore be attributed entirely to the change itself. This is what makes it a “same exam, retaken” approach.

    A usable Golden Set must satisfy four conditions:

    1. Fixed: once cases and expected answers are committed, they are not casually changed as development progresses.
    2. Reproducible: fixture data is generated by scripts with a fixed random seed, so anyone rerunning it gets the same result.
    3. Automatically gradable: no human visual inspection is required; a script outputs the pass rate and failure details directly.
    4. Layered coverage: quotas for positive cases, negative cases, boundary cases, and format cases.

    3. Directory and File Organization: Make Testing Part of the Skill

    A recommended approach is to keep test assets in the same directory as the Skill itself, forming a four-layer structure of “instructions + methodology + scripts + fixtures”:

    1. ab-quality-analysis/
    2. ├── SKILL.md # Trigger/no-trigger rules, field validation, decision rules, output template
    3. ├── golden_set.md # Case list, usage discipline, fixture notes
    4. ├── scripts/
    5. │ └── analyze.py # Main analysis logic (significance test + multi-dimensional aggregation + trends)
    6. └── tests/
    7. ├── run_golden_set.py # Auto-grader, computes pass rate in one run
    8. ├── generate_fixtures.py # Fixture generation, fixed and reproducible data
    9. └── fixtures/ # Baseline inputs with known answers
    10. ├── known_cases.xlsx # Small hand-crafted sample, results verifiable by hand
    11. ├── missing_field.xlsx # Missing key fields
    12. └── bad_dates.xlsx # Null values / zero sample size / invalid dates

    The key design here is that fixtures are generated by scripts rather than maintained by hand, which avoids the situation where “the data quietly changed but everyone assumed the conclusion still held.” Decoupling the grader from the main logic ensures the test itself does not become a new source of uncertainty.

    4. Case Design: Four Categories for Effective Regression

    Take a typical Skill such as “experiment quality analysis” as an example. Its job is to receive experiment details over a time range, classify and count them by significance, and output summaries across three dimensions: overall, page, and step. The Golden Set can be divided into four categories:

    • Positive cases (prevent functional regression): given an explicit time range, the expected output has all three dimensions, each group contains four experiment types plus a summary row; the time range format is fixed as “2026/10/1-2026/10/31” (month and day without leading zeros, including the year); significance is based on a two-sample Z-test on ARPU, with |z| ≥ 1.96 judged as significant; classification of the small hand-crafted dataset must match manual calculation.
    • Negative cases (prevent false triggering): when the input belongs to scenarios like experiment management or sensitivity analysis, the Skill must not trigger. This is the capability most easily broken by “optimizing the prompt.”
    • Boundary cases: critical inputs such as lift exactly 0, extremely small sample size, or a ratio close to 1, used to verify whether the decision rules handle closed and open intervals consistently.
    • Error cases: missing key fields, empty or invalid dates, sample size of 0. The expected behavior is a clear error or a degraded explanation, not a fabricated conclusion.

    5. Automated Grading and Usage Discipline

    The grader should output structured results rather than a single “pass/fail”:

    1. [PASS] case_01 positive-three-dimension completeness
    2. [FAIL] case_07 boundary-lift=0 misclassified expected=not significant positive actual=significant positive
    3. Pass rate: 16/17 = 94.1%

    Usage discipline is equally important: run the set once before and once after each Skill change; if the pass rate drops, locate the specific case before merging; for new capabilities, add cases first and then change the implementation; fixture changes require review and are treated as contract changes. If conditions allow, the grader can be integrated into continuous integration to automatically block regressions at the commit stage.

    6. Common Pitfalls and Practical Advice

    Common pitfalls include: covering only the happy path, relying on human memory for expected values, mixing test data with real data, and directly editing expected values to “make it green” when a case fails. The right approach is to treat the Golden Set as a contract between versions: better to have a few accurate cases than many hollow ones. At the start, accumulate 10–20 highly representative cases, expand gradually with iterations, and periodically clean up entries that have lost their representativeness.