Enhancing AI Coding Assistant Stability: Skill Engineering and Golden Set Testing

    As AI coding assistants increasingly use Skills (structured prompt documents) for repetitive domain tasks, frequent prompt modifications often lead to untracked regressions due to primitive validation methods. This article introduces the Golden Set testing methodology—a regression testing approach for prompt engineering. By using a fixed set of test cases with known answers, developers can objectively compare Skill versions and control variables during iteration. Through a practical example of an AB test quality analysis Skill, the article details how to design directory structures, trigger conditions, test fixtures, and automated graders, ultimately establishing an engineering workflow where every modification is quantitatively evaluated to ensure stable evolution.

    1. Why Skills Need an Engineering Testing Method

    With the widespread adoption of AI coding assistants, more teams are encapsulating repetitive domain tasks (such as data validation, report generation, and code review standards) into Skills. A Skill is a structured documentation file containing trigger conditions, execution rules, and output templates. Essentially, a Skill is a “program” written in natural language, and its behavior relies heavily on prompt wording and rule organization.

    This brings a practical problem: Skills are modified extremely frequently, but their validation methods remain primitive. The common practice is to casually test one or two examples after tweaking the prompt and ship it if it feels right. This “gut-feeling” iteration approach has three obvious flaws:

    1. Blind to regressions: Fixing a boundary case might silently break previously working functionality without you noticing.
    2. Incomparable results: Without a unified evaluation benchmark, judging which version is better relies solely on subjective impressions.
    3. Low iteration efficiency: Every change requires manually constructing inputs and manually checking outputs. High validation costs lead to low validation frequency, ultimately creating a vicious cycle.

    The core idea to solve these problems is applying the classic regression testing concept from software engineering to prompt engineering—the Golden Set.

    2. Golden Set: Measuring All Versions with the Same Ruler

    2.1 One-Sentence Definition

    A Golden Set is a fixed set of test cases with known answers. After every Skill modification, you run the entire set again, using the same ruler to measure different versions, making the results directly comparable.

    2.2 Why It Works

    The value of a Golden Set lies in controlling variables. When evaluating Skill versions, three factors might influence the results:

    • The test cases themselves;
    • The expected answers (evaluation criteria);
    • The Skill version (prompts, scripts, rules).

    The Golden Set completely fixes the first two: the case set and expected answers remain unchanged. The only variable is the Skill version. The pass rate derived from this can be directly compared across versions—similar to “retaking the same exam repeatedly.” Any fluctuation in scores can be entirely attributed to the modified content rather than environmental drift or changes in the questions.

    2.3 Design Principles

    A usable Golden Set typically includes four types of cases:

    Case Type Purpose
    Standard Positive Prevents basic functionality regression; covers the most typical task inputs
    Boundary Positive Covers extreme values and special inputs (e.g., zero increment, exactly hitting a threshold)
    Negative / Exception Missing fields, null values, illegal formats; verifies error handling and prompt capabilities
    Non-Trigger Scenarios Verifies trigger boundaries; prevents the Skill from being mistakenly triggered when it shouldn’t be

    Accompanying usage discipline is equally important: Once a Golden Set is established, it is frozen. If a test case is found to be flawed during testing, it should go through a formal change process (recording the reason, updating the expected answer, and syncing the review) rather than being casually modified. Otherwise, the “ruler” itself loses its measurement significance.

    3. A Complete Practice of a Data Analysis Skill

    Below is an example of an AB experiment quality analysis Skill to demonstrate how this method is implemented. The Skill’s function is to perform significance classification statistics on detailed experiment data by time range, determine significance based on a two-sample Z-test, and output summary tables across three dimensions: overall, page, and step.

    3.1 Directory Structure Design

    1. ab-quality-analysis/
    2. ├── SKILL.md # Core: trigger/prohibition rules, field validation,
    3. │ # significance rules, output templates, display constraints
    4. ├── golden_set.md # Methodology doc: case list, usage discipline, fixture explanation
    5. ├── scripts/
    6. │ └── analyze.py # Core analysis script (Z-test + multi-dim aggregation + trend)
    7. └── tests/
    8. ├── run_golden_set.py # Automated grader: one-click pass rate calculation
    9. ├── generate_fixtures.py # Fixture generation script: fixed, reproducible data
    10. └── fixtures/ # Benchmark inputs with known answers
    11. ├── known_cases.xlsx # Manually constructed data, results verifiable by hand
    12. ├── missing_field.xlsx # Exception input missing key fields
    13. └── bad_dates.xlsx # Null / zero sample / illegal date

    This structure reflects several important design decisions:

    • SKILL.md is the single source of truth for rules: Trigger conditions, prohibition conditions, field validation logic, statistical rules, and output templates are all centralized in one place. This prevents rules from being scattered across multiple files and causing missed modifications.
    • Trigger descriptions must cover “both sides”: Clearly state which keywords should trigger the Skill (e.g., “experiment quality”, “significance summary”) and explicitly list similar scenarios where triggering is prohibited (e.g., “experiment management”, “sensitivity analysis”). Trigger boundaries are where Skills are most prone to errors and must be explicitly declared.
    • Test assets are managed alongside functional code: The grader, fixture generation script, and test data all have clear ownership and documentation. Anyone taking over can quickly understand how to validate.

    3.2 Writing Trigger Conditions

    An example of the trigger description in SKILL.md (excerpt):

    1. name: ab-quality-analysis
    2. description: >
    3. Experiment quality analysis. Used when the user mentions "experiment quality"
    4. "experiment revenue" "experiment significance summary" "experiment effect summary"
    5. and needs to perform significance classification statistics (significant positive /
    6. non-significant positive / non-significant negative / significant negative) on
    7. experiment detail data by time range. Determines significance based on a two-sample
    8. Z-test for a specific metric, and outputs summary tables across three dimensions:
    9. overall, experiment page, and experiment step. Triggering this skill in "experiment
    10. management" "AB analysis" "sensitivity analysis" scenarios is prohibited.

    Note several details: specific trigger phrases are listed rather than abstract descriptions; determination rules (e.g., |z| >= 1.96 is significant) and output structures are defined; “prohibited” statements draw negative boundaries. These contents themselves serve as the evaluation criteria for “non-trigger scenarios” in the Golden Set.

    3.3 Fixtures: Inputs with Known Answers and Reproducibility

    Test fixtures are the physical carriers of the Golden Set. The key requirements are fixed data and independently verifiable answers:

    • known_cases.xlsx: Only 4 rows of manually constructed data, intentionally including boundary cases like zero increment. The data is small enough that the Z-test results can be manually verified with a calculator. This ensures the expected answers are trustworthy, rather than a circular argument of “whatever the program outputs is correct.”
    • missing_field.xlsx: Missing required fields. The expected behavior is that the Skill provides a clear prompt about missing fields instead of crashing or silently skipping.
    • bad_dates.xlsx: Contains three types of dirty data: null metric values, zero sample sizes, and illegal dates, verifying data cleaning and fault tolerance logic.

    Fixtures are generated by the generate_fixtures.py script rather than manually editing files—this ensures anyone regenerating them gets the exact same data, making test results reproducible.

    3.4 Automated Grader

    run_golden_set.py plays the “grader” role: it reads the input and expected output for each case, calls the Skill to execute, automatically compares results, and finally outputs the overall pass rate. The expected output for positive cases includes multiple mechanically verifiable assertion points:

    • The output includes three dimensions: overall, page, and step, with all 4 experiment categories and summary rows present under each dimension;
    • The time range format complies with conventions (month/day without leading zeros, year included);
    • The significance classification results are consistent with manually calculated Z-test conclusions.

    Assertions like “format conventions” may seem trivial but are highly worth adding—prompts’ requirements for output formats are the most easily and unconsciously broken by subsequent modifications. Automated comparisons can capture such regressions immediately.

    4. Daily Workflow: Evaluate Upon Modification

    Once the Golden Set is established, the Skill iteration process becomes:

    1. Modify SKILL.md or scripts;
    2. Run the grader with one click to get the pass rate;
    3. Compare with the previous version’s pass rate: If it drops, locate which type of case degraded; if it rises, confirm the modification is effective;
    4. Merge only after the pass rate meets the standard and there are no regressions.

    This workflow turns “modifying Skills” from dark magic into engineering: every modification has a quantitative quality signal, and every regression has clear case evidence. In practice, the grading script can also be integrated into the pre-commit hook process to form a mandatory checkpoint.

    5. Experience Summary

    • Build the ruler before cutting: Before performing large-scale refactoring or rule adjustments on a Skill, establish the Golden Set first. Otherwise, you cannot prove your changes are improvements.
    • Expected answers must be independently verifiable: Use small-scale, manually calculable constructed data as fixtures to avoid the circular logic of “defining correctness using the program being tested.”
    • Negative cases and trigger boundaries are equally important: The ability to handle abnormal inputs and “not trigger when it shouldn’t” often distinguishes a Skill’s maturity better than positive cases.
    • Write methodology into the repository: Store case lists, usage disciplines, and fixture explanations as documentation in the same repository as the code, making test standards a team asset rather than individual memory.
    • Discipline over tools: The technical implementation of a Golden Set is very simple; the hard part is the engineering discipline of freezing benchmarks, running them on every change, and not arbitrarily modifying cases.

    When prompt engineering is backed by regression testing, an AI coding assistant’s Skill is no longer a “lucky-to-work script,” but a product-level asset that can be continuously polished and stably evolved.