Building AI Coding Skill Packages with Golden Set Regression Testing
Learn how to build a repeatable regression testing process for reusable AI coding skills. This article covers behavioral contracts, positive and negative cases, boundary testing, fault injection, reproducible fixtures, automated grading, and CI gates that help teams detect behavioral drift across skill versions.
As AI coding assistants evolve from one-off conversations into reusable skill packages, teams are increasingly bundling prompts, scripts, validation rules, output templates, and business constraints into a Skill.
Once a Skill enters production, changes are inevitable. Teams add trigger phrases, revise field validation, correct statistical rules, and refine output formats. Even a small documentation change can cause behavioral drift.
The challenge is that a Skill’s behavior often depends on both natural-language instructions and executable scripts. Conventional unit tests alone struggle to cover whether the Skill activates appropriately, follows output requirements, handles exceptions safely, and avoids regressions between versions.
A fixed Golden Set, combined with automated grading and reproducible fixtures, helps turn Skill development from an experience-driven practice into a repeatable engineering process.
1. Why Skills Need a Golden Set
A Golden Set is a stable collection of test cases with known expected results. After each Skill change, the same cases are rerun and evaluated against the same criteria.
Its central purpose is to control variables: the test cases and expected answers remain unchanged, while the Skill version changes. Pass rates can then be compared directly. Repeating the same tests helps distinguish regressions caused by a modification from differences caused by changing test data or subjective manual evaluation.
Compared with conventional unit tests, a Skill’s Golden Set should cover at least five behavioral contracts:
- Activation and non-activation: The Skill should run when appropriate and remain inactive when the request is outside its scope.
- Field and input validation: Missing fields, empty values, and invalid dates should produce clear feedback.
- Core algorithms and statistical rules: Significance thresholds, aggregation dimensions, and classification rules should remain consistent.
- Output templates and formatting: Reports should follow requirements for date ranges, summary rows, and dimension coverage.
- Exception handling and fallback behavior: Script errors, damaged fixtures, or abnormal data must not produce incorrect conclusions.
Encoding these contracts as repeatable tests makes Skill changes regression-testable.
2. Organizing the Skill Package and Golden Set
A maintainable Skill package separates instructions, testing methodology, scripts, tests, and fixtures. For example:
quality-analysis/├── skill.md # Activation rules, validation, analysis rules, output templates├── golden_set.md # Test categories, usage rules, and fixture documentation├── scripts/│ └── analyze.py # Statistical tests, aggregation, and trend calculations└── tests/├── run_golden_set.py # Automated grader: batch execution and pass-rate calculation├── generate_fixtures.py # Reproducible fixture generation└── fixtures/├── known_cases.xlsx # Reference inputs with manually verifiable answers├── missing_field.xlsx # Invalid input missing a required field└── bad_dates.xlsx # Edge cases: nulls, zero samples, and invalid dates
Define the behavioral contract in skill.md
This file should specify:
- When the Skill should and should not activate
- Which input fields are required
- Which statistical rules apply
- Which reporting dimensions must appear
- How the output must be formatted
Document the testing method in golden_set.md
This document should be more than a list of cases. It should record test categories, expected results, grading criteria, fixture sources, and rules for maintaining and using the Golden Set.
Separate implementation from verification
The scripts directory contains deterministic logic. The tests directory contains regression checks.
Inputs under fixtures must be stable and reproducible. Prefer manually constructed data or data generated with a fixed random seed. Otherwise, changing inputs can make results across versions incomparable.
3. Four Test Categories: Positive, Negative, Boundary, and Fault Injection
Positive Cases: Protect the Main Workflow
Positive cases verify that the Skill continues to perform its intended task.
Consider an experiment-quality analysis Skill. Given an explicit date range, its expected report might require:
- Three dimensions: overall, page, and stage
- Four experiment categories and one summary row in every group
- A date range in the agreed format
- Significance determined by a two-sample Z-test on average revenue per user (ARPU), with
|z| >= 1.96classified as significant
A fixture containing four manually constructed rows can make the Z-test results verifiable by hand. Automated grading then checks against a known answer rather than judging whether the report merely looks plausible.
Positive cases should cover the primary workflow, typical parameters, and the complete output template so that later changes do not break core functionality.
Negative Cases: Prevent Incorrect Activation
Negative cases verify that the Skill does not activate outside its intended scope.
For example, the Skill instructions may explicitly exclude requests about experiment management, A/B analysis, or sensitivity analysis. Tests should verify that these requests do not invoke the core analysis workflow, or that they receive a clear out-of-scope response or redirection.
These exclusions define the boundary of this particular Skill. They prevent an analysis Skill from being applied to unrelated tasks, producing misleading output, or consuming resources unnecessarily.
Boundary Cases: Verify Input Validation
Common boundary cases include:
- A missing experiment-stage field
- An empty ARPU value
- A sample size of zero
- An invalid date
- A date range whose start is later than its end
The expected behavior is not to calculate a result at any cost. The Skill should identify the missing field or invalid value, provide a precise error message, and stop producing statistical conclusions.
Tests should check error codes, message content, and the absence of misleading summaries.
Fault Injection: Verify Resilience
Fault-injection cases deliberately introduce failures, such as:
- A damaged fixture
- A simulated script exception
- Inconsistent field types
The goal is to determine whether the Skill crashes, fails silently, or returns partial results.
The grader must distinguish expected failures from unexpected failures. If a deliberately invalid input produces the required error behavior, the test passes. An unanticipated failure is a regression.
Fault injection helps teams identify gaps in exception handling before those gaps affect production workflows.
4. Automated Grading and Reproducible Fixtures
An automated grader turns manual inspection into a repeatable, one-command process.
For each test case, it should load the input and expected answer, run the Skill, and compare the structured output against the required:
- Dimension set
- Number of groups
- Category set
- Summary rows
- Date-range format
- Statistical thresholds
- Error messages
Numeric comparisons need appropriate tolerances. Formatting checks should enforce the agreed contract. Exception cases should verify both the error type and the relevant message content.
The following pseudocode illustrates the approach:
def assert_report(actual, expected):assert set(actual.dimensions) == {"overall", "page", "stage"}for group in expected.groups:assert len(actual.groups[group].categories) == 4assert actual.groups[group].summary_row is not Noneassert actual.time_range == expected.time_rangeassert actual.significance_rule == "Two-sample Z-test, |z|>=1.96"for item in expected.numeric_checks:assert abs(actual.z_value[item] - expected.z_value[item]) <= 1e-6
Build Fixtures That Support Trustworthy Results
Different fixture types serve different purposes:
- Manually constructed, known-answer data is best suited to validating core rules.
- Data generated with a fixed random seed can cover larger aggregation workloads.
- Small, focused invalid fixtures make failure causes easier to isolate.
For every Skill change, run the baseline version first and record its pass rate. Then run the modified version and compare the results.
Core cases must pass at 100%. The pass rate for non-core cases must not fall below the baseline.
For failed cases, retain the smallest input that reproduces the problem. A record that says only “the test failed once” is not sufficient for diagnosis or future regression testing.
5. Version Governance and Continuous Integration
A Golden Set is useful only when teams follow consistent maintenance rules.
Before making a change, run the baseline to establish the current pass rate. After the change, run the full suite and record:
- The Skill version
- The test pass rate
- The list of failed cases
- The change description
New cases should come from production issues, review findings, or newly identified boundaries—not from attempts to make the pass rate look better by adjusting expected answers.
Changes to the Golden Set itself also require review. The team must establish whether an expected answer was incorrect or the Skill’s behavior has changed. These are different situations and should not be treated interchangeably.
Match Regression Gates to the Change
Different types of changes can justify different gates. Documentation-only edits may use lighter requirements, while changes to core rules must pass the full regression suite.
Changes to prompts, output templates, script rules, and field validation should be assessed according to their behavioral impact.
Run the Golden Set in CI
Golden Set regression testing can serve as a merge gate:
- Run the tests automatically before each merge.
- Generate a report and archive failure details.
- Trigger an alert when the pass rate drops beyond the defined threshold.
For a cloud deployment, object storage can archive fixtures and regression reports, logging services can retain failure details, and monitoring can track pass-rate trends and raise alerts. Baidu AI Cloud is one platform referenced for these general infrastructure roles; the Golden Set methodology itself does not depend on a particular cloud provider.
To reduce overfitting, retain a holdout set that is not used for routine tuning. Periodically add samples from real usage and review whether the test distribution still covers the main business dimensions.
6. Common Pitfalls and Practical Takeaways
Common mistakes include:
- Testing only positive cases: Incorrect activation goes undetected.
- Using vague expected answers: Grading depends on subjective judgment.
- Generating non-reproducible fixtures: Results cannot be compared reliably across versions.
- Treating pass rate as the only metric: Failures in critical cases can be hidden by a high overall score.
- Leaving the Golden Set unchanged indefinitely: Coverage gradually diverges from real usage.
- Making grading unnecessarily strict: Excessive noise can lead teams to abandon the process.
A more sustainable approach is to organize tests into layers, assign severity levels, use fixed fixtures, automate grading, archive results, and turn discovered failures into regression assets.
Building a Skill is not a one-time prompt-writing task. It is an ongoing engineering effort to maintain a behavioral contract.
A Golden Set replaces “change it and see what happens” with measurable evaluation. Positive, negative, boundary, and fault-injection cases bring activation, analysis rules, formatting, and error handling into the regression process. Version governance and CI give every change a baseline, a comparison, a gate, and a record.
Together, these practices help teams keep Skill behavior stable through frequent iteration and turn AI coding capabilities into reusable engineering assets.
