Quality Assurance for AI Coding Skills: A Practical Guide to Golden Sets
This article explains how to use a Golden Set to stabilize the iteration of AI coding skills and agent workflows. It covers the core idea of controlling variables with fixed test cases and known answers, a practical walkthrough of building a Golden Set for an AB testing quality analysis skill, four categories of test cases, the logic of an automated grader with layered assertions, and team discipline for continuous integration. Readers will learn how to turn probabilistic skill tuning into measurable engineering experiments and verify that every change is a forward step.
Why Do Your “Skills” Become Less Stable with Every Change?
When building AI coding assistants or various agent workflows, we usually write a set of structured instruction files (such as SKILL.md) to define a tool’s behavior boundaries, trigger conditions, and output formats. However, as business requirements evolve, modifying and maintaining these “skill” files becomes a routine part of the development process.
But a headache-inducing question soon follows for many developers: How can I prove that my change is an improvement and that it hasn’t silently broken existing functionality?
Traditional unit testing for code works very well for deterministic function inputs and outputs, but it often falls short when facing agents driven by large models that produce probabilistic outputs. We need a brand-new quality assurance system to handle the testing of this “soft” logic.
The Core Solution: Introducing the Golden Set
A Golden Set is a collection of test cases that are fixed and have known answers. Its core principle is the control variable method:
- Invariants: The test case set and the expected standard output.
- The only variable: The modified version of the skill.
By re-running the Golden Set after each skill modification and scoring the results with the same evaluation standard (the same ruler), we can obtain an intuitive pass rate. This “retake the same exam” approach allows the performance of different skill versions to be compared directly side by side. Any drop in scores can be attributed one hundred percent to the problem introduced by the current change, greatly boosting confidence and efficiency in iteration.
Hands-On: Building a Golden Set for a Data Analysis Skill
To make this more concrete, let’s take a real scenario as an example. Suppose we are developing a skill named ab-quality-analysis (AB experiment quality analysis). This skill needs to accept experiment detail data, perform a two-sample Z-test based on the ARPU metric, and finally output significance classification statistics across three dimensions (overall, page, and stage).
1. Directory Structure Design
A well-structured and easy-to-maintain skill directory should contain core instructions, test scripts, and test data. The specific structure is as follows:
ab-quality-analysis/├── SKILL.md # Core logic: trigger rules, field validation, significance algorithm, output template├── golden_set.md # Methodology doc: defines case categories, usage discipline, and test fixtures├── scripts/│ └── analyze.py # Core analysis script: Z-test + three-dimension aggregation logic└── tests/├── run_golden_set.py # Automated grader: iterates cases and computes pass rate in one click├── generate_fixtures.py # Fixture generator: produces fixed and reproducible test data└── fixtures/ # Test fixture directory├── known_cases.xlsx # 4 rows of hand-crafted data; Z-test results can be verified manually├── missing_field.xlsx # Abnormal data missing the "experiment stage" key field└── bad_dates.xlsx # Dirty data with empty ARPU, zero sample size, and invalid dates
In this structure, the data under the fixtures directory is the soul of the entire Golden Set. We must ensure that this data is static, known, and covers all possible boundary cases.
2. Key Elements of the Skill Definition (SKILL.md)
In the SKILL.md file, we need to clearly define the skill’s metadata and execution logic. The metadata section is mainly used for semantic matching by the large model:
name: ab-quality-analysisdescription: AB experiment quality analysis. Use when the user mentions "experiment quality", "experiment revenue", "significance summary", etc., and needs significance classification statistics on AB experiment detail data by time range.Determines significance based on a two-sample Z-test on ARPU, and outputs a summary table across three dimensions: overall, experiment page, and experiment stage.Prohibited from triggering this skill in non-target scenarios such as "experiment management" and "AB analysis".
In addition to trigger rules, output format constraints are a top priority in testing. For example, we require the time range format to be strictly 2026/10/1-2026/10/31 (no zero-padding, includes the year), and it must contain the three dimensions “overall/page/stage”, with each dimension further divided into four categories: “significantly positive”, “not significantly positive”, “not significantly negative”, and “significantly negative”.
3. Designing Test Cases: Four Categories Covering the Full Lifecycle
In the golden_set.md document, we need to plan four categories of test cases to build a complete test matrix:
a. Positive Case (Happy Path) — Prevent Functional Regression
This is the most basic test, verifying that the skill can produce the expected standard answer under normal input.
- Input: Provide a standard set of experiment data for October 2026.
- Expected output: Output a summary table containing the three dimensions, with accurate Z-test result classification (|z| ≥ 1.96 is judged significant).
- Grading logic: The automated grader compares the actual output with the pre-stored Golden Answer, checking whether the classification counts and format specifications match 100%.
b. Negative Case (Boundary and Exception Handling) — Verify Robustness
Real-world data is often full of noise. We need to test whether the skill crashes when encountering “dirty data” or whether it can give a friendly error message.
- Test fixture:
bad_dates.xlsx(contains empty ARPU, zero sample size, invalid dates). - Expected behavior: The skill should recognize that null or zero values make the Z-test impossible to compute, and skip the row or output an Error Log, rather than producing
NaNor crashing with an error.
c. Missing Field Case — Verify the Validation Mechanism
Check whether the skill strictly enforces the preset field validation rules.
- Test fixture:
missing_field.xlsx(missing the “experiment stage” field). - Expected behavior: The skill should detect the missing required field during preprocessing, refuse to execute subsequent statistics, and return a clear prompt asking the user to supply the data.
d. Ambiguous Boundary Case — Test Trigger Accuracy
This tests not only the analysis logic but also whether the skill’s “trigger conditions” are precise.
- Input prompt: “Help me look at last quarter’s experiment situation.”
- Expected behavior: The skill should correctly understand the vague time expression, or proactively ask the user for the specific start and end dates, rather than forcibly applying default parameters.
Implementation Logic of the Automated Grader
With the cases and expected results in place, we need an automated script to execute everything. The following is the core pseudocode logic of run_golden_set.py:
def evaluate_skill(skill_version):cases = load_cases_from("golden_set.md")passed = 0total = len(cases)for case in cases:# 1. Load fixed inputinput_data = load_fixture(case.fixture_path)# 2. Execute the skillactual_output = invoke_skill(skill_version, case.prompt, input_data)# 3. Assertion comparisonif compare_with_golden(actual_output, case.expected_output):passed += 1log_success(case.id)else:log_failure(case.id, actual_output, case.expected_output)return passed / total
Key Evaluation Strategy: Layered Assertions
Do not try to compare complex JSON or Markdown tables with simple string matching. A layered assertion strategy is recommended:
- Structure assertion: First check whether the output structure conforms to the Schema (for example, whether it contains the headers for the three dimensions and whether the number of table columns is correct).
- Numerical assertion: Check whether key statistical values (such as the number of packages that are significantly positive, and the Z-value range) fall within the allowed margin of error.
- Format assertion: Check detail formatting (such as whether the date is
2026/10/1rather than2026-10-01).
Continuous Integration and Team Collaboration Discipline
A Golden Set is only valuable when strictly enforced. Within the team, we need to establish the following “usage discipline”:
- Test with every change: Any modification to the core logic of
SKILL.mdor the prompt must be accompanied by a Golden Set run report before merging code. - Baseline management: When business requirement changes cause the expected output to change, the Golden Answer must be updated first, with an explanation of the reason for the change. It is strictly forbidden to tamper with the expected answer privately just to make the test pass.
- Expand cases: Whenever a Bad Case (a poorly performing case) appears in production, it must be converted into a new Golden Case and added to the test set, ensuring that the same pit is never fallen into twice.
Summary
In the field of agent development, a Golden Set is not just a testing tool, but an engineering culture. It turns the vague, luck-dependent “parameter tuning” into a scientific and measurable engineering experiment. By building fixed test fixtures, clear expected answers, and an automated grading process, we can truly take control of skill iteration and ensure that every update is a solid step forward.
