regression-test-generator
Skill94 starsChanged 6 months agoMITView on GitHub
Generate regression tests when bugs are discovered during /debug or continuous checks. Auto-detects test framework, creates Arrange-Act-Assert tests, and links to error-log.md entries. (project)
We split this skill into the rules it gives an agent
35 rules. About 0 are common, 30 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈30
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Verify correct behavior (passes after fix)
- Distinctive: line 26
Before generating regression test:
- Distinctive: line 32
Check error-log.md to avoid duplicate tests for same error.
- Distinctive: line 65
Check project configuration (in priority order):
- Distinctive: line 95
Document assumption in test file comment
- Very specific: line 105
Check if tests/regression/ exists → use it
- Distinctive: line 106
Check project test structure:
- Very specific: line 110
Create tests/regression/ if no pattern found
- Very specific: line 123
Use framework-appropriate template from references/framework-templates.md.
- Distinctive: line 176
A (Save): Write file, run test, update error-log.md
- Distinctive: line 188
If bug not yet fixed: Test should FAIL (proves bug exists)
- Distinctive: line 189
If bug already fixed: Test should PASS (validates fix)
- Distinctive: line 201
Validation: Test file exists, runs without syntax errors, linked in error-log.md.
- Distinctive: line 206
After generating regression test, verify:
- Distinctive: line 208
Test file created in correct location
- Distinctive: line 209
Test follows project naming conventions
- Distinctive: line 210
Test uses Arrange-Act-Assert pattern
- Distinctive: line 211
Test has clear name describing expected behavior
- Distinctive: line 214
Test runs without syntax errors
- Distinctive: line 215
Test behavior matches expectations (fails before fix OR passes after) </validation>
- Distinctive: line 220
Don't: Test implementation details
- Distinctive: line 229
Do: Test observable behavior
- Distinctive: line 243
Don't: Use fragile DOM selectors
- Distinctive: line 250
Do: Use accessible selectors
- Distinctive: line 261
Don't: Create test without linking to error
- Distinctive: line 282
Don't: Write E2E test for unit-level bug
- Distinctive: line 295
Write test names that describe expected behavior:
- Distinctive: line 384
No error reference (no traceability)
- Very specific: line 393
Solution: Check package.json, pyproject.toml manually.
- Distinctive: line 395
Issue: No existing test directory
- Very specific: line 396
Solution: Create tests/regression/ and document in test file comment
- Distinctive: line 398
Issue: Test passes before fix applied
- Distinctive: line 399
Solution: Test may not be reproducing bug correctly.
- Distinctive: line 401
Issue: Test fails after fix applied
- Distinctive: line 411
Test location strategies (monorepo, co-located, centralized)
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<objective>
Automatically generate regression tests that capture bugs to prevent recurrence. Creates complete, framework-appropriate tests that:
1. Reproduce the bug scenario (fails before fix)
2. Verify correct behavior (passes after fix)
3. Link back to error-log.md for traceability
</objective><quick_start> Generate regression test for a bug:
- Collect bug details: error ID, symptoms, root cause, affected component
- Detect test framework from project (Jest, Vitest, pytest, Playwright)
- Generate test file following project patterns
- Present to user for review: [A] Save [B] Edit [C] Skip
- Save test to
tests/regression/and update error-log.md
Key principle: Tests should FAIL before the fix is applied (proves bug exists). </quick_start>
<prerequisites>
Before generating regression test:
- Bug has been identified with symptoms and reproduction steps
- Root cause determined (from 5 Whys or debugging)
- Component/file affected is known
- Error ID assigned (ERR-XXXX) or will be assignedCheck error-log.md to avoid duplicate tests for same error.
</prerequisites>
<workflow>
<step number="1">
**Collect bug details**Extract from debug context:
- Error ID: ERR-XXXX from error-log.md (or generate new)
- Title: Brief description (e.g., "Dashboard timeout due to missing pagination")
- Symptoms: Observable behavior (error message, incorrect output)
- Root cause: Why the bug occurred (from 5 Whys analysis)
- Component: Affected file/function (e.g.,
StudentProgressService.fetchExternalData) - Reproduction steps: How to trigger the bug
Example:
error_id: ERR-0042
title: Dashboard timeout due to missing pagination
symptoms: Dashboard fails to load, timeout after 30s
root_cause: Missing pagination parameter causes over-fetching
component: src/services/StudentProgressService.ts:fetchExternalData
reproduction:
- Navigate to /dashboard/student/123
- Click "Load Data" button
- Observe timeout error</step><step number="2">
**Detect test framework**Check project configuration (in priority order):
- docs/project/tech-stack.md (if exists):
grep -i "test\|jest\|vitest\|pytest\|playwright" docs/project/tech-stack.md - package.json (JavaScript/TypeScript):
# Check devDependencies grep -E '"(jest|vitest|@playwright/test|mocha)"' package.json - pyproject.toml / requirements.txt (Python):
grep -E "(pytest|unittest|nose)" pyproject.toml requirements.txt - Existing test file patterns:
# JavaScript patterns find . -name "*.test.ts" -o -name "*.spec.ts" | head -1 # Python patterns find . -name "*_test.py" -o -name "test_*.py" | head -1 - Defaults:
- JavaScript/TypeScript: Jest
- Python: pytest
- Document assumption in test file comment
Output: Framework name and test file extension (e.g., Jest → .test.ts)
</step>
<step number="3">
**Determine test file location**Find appropriate location:
- Check if
tests/regression/exists → use it - Check project test structure:
tests/directory →tests/regression/__tests__/directory →__tests__/regression/- Co-located tests (same dir as source) →
src/__tests__/regression/
- Create
tests/regression/if no pattern found
File naming:
- Format:
regression-ERR-{ID}-{slug}.{ext} - Slug: lowercase kebab-case from title
- Examples:
regression-ERR-0042-dashboard-timeout.test.tstest_regression_err_0042_dashboard_timeout.py</step>
<step number="4">
**Generate test code**Use framework-appropriate template from references/framework-templates.md.
Structure (Arrange-Act-Assert):
Header: Error ID, title, description, root cause, link to error-log
describe/class: "Regression: ERR-XXXX - {title_short}"
test: "should {expected} when {condition}"
ARRANGE: Set up bug scenario (data, mocks, state)
ACT: Execute action that caused bug
ASSERT: Verify correct behavior (would have failed before fix)Required elements:
- Error ID reference in comment header
- Link to error-log.md entry
- Clear test name describing expected behavior
- Setup code matching reproduction steps
- Assertion that validates the fix
See references/framework-templates.md for complete templates.
</step>
<step number="5">
**Present to user for review**Display generated test:
=== Regression Test Generated ===
Error: ERR-0042 - Dashboard Timeout Due to Missing Pagination
File: tests/regression/regression-ERR-0042-dashboard-timeout.test.ts
--- Generated Test Code ---
[Full test code here]
---
This test will:
- {describe what test validates}
- {explain why test would have failed before fix}
What would you like to do?
[A] Save test and continue
[B] Edit test before saving
[C] Skip generation (add to debt tracker)
>If user chooses:
- A (Save): Write file, run test, update error-log.md
- B (Edit): Show edit instructions, wait for confirmation
- C (Skip): Log skip reason in NOTES.md as technical debt
</step>
<step number="6">
**Save and verify**After user approval:
- Write test file to determined location
- Run test to verify:
- If bug not yet fixed: Test should FAIL (proves bug exists)
- If bug already fixed: Test should PASS (validates fix)
- Update error-log.md with regression test reference:
**Regression Test**:
- **File**: `tests/regression/regression-ERR-0042-dashboard-timeout.test.ts`
- **Status**: Generated
- **Validates**: Pagination parameter prevents timeout- Stage file for commit (do not auto-commit)
Validation: Test file exists, runs without syntax errors, linked in error-log.md.
</step>
</workflow>
<validation>
After generating regression test, verify:- Test file created in correct location
- Test follows project naming conventions
- Test uses Arrange-Act-Assert pattern
- Test has clear name describing expected behavior
- Error ID referenced in test header comment
- error-log.md updated with test reference
- Test runs without syntax errors
- Test behavior matches expectations (fails before fix OR passes after)
</validation>
<anti_patterns>
<pitfall name="implementation_testing">
Don't: Test implementation details
// BAD: Tests internal method name
test('calls _fetchWithPagination', () => {
expect(service._fetchWithPagination).toHaveBeenCalled();
});Do: Test observable behavior
// GOOD: Tests behavior user expects
test('should return paginated results within 5 seconds', async () => {
const result = await service.fetchData(studentId);
expect(result.length).toBeLessThanOrEqual(10);
});Why: Implementation can change; behavior should remain stable.
</pitfall>
<pitfall name="brittle_selectors">
**Don't**: Use fragile DOM selectors// BAD: Breaks if CSS class changes
await page.locator('.btn-primary-xl-dashboard').click();Do: Use accessible selectors
// GOOD: Stable, user-focused
await page.getByRole('button', { name: 'Load Data' }).click();Why: Regression tests should be stable across refactors.
</pitfall>
<pitfall name="no_error_link">
**Don't**: Create test without linking to error// BAD: No reference to error-log.md
test('dashboard loads', () => { /* ... */ });Do: Include error ID and link
/**
* Regression Test for ERR-0042
* @see specs/my-feature/error-log.md#ERR-0042
*/
test('should load dashboard within 5s (ERR-0042)', () => { /* ... */ });Why: Traceability enables understanding why test exists.
</pitfall>
<pitfall name="testing_wrong_layer">
**Don't**: Write E2E test for unit-level bugDo: Match test type to bug scope:
- Logic error in function → Unit test
- Integration failure → Integration test
- User flow broken → E2E test
Why: Faster feedback, more stable tests, easier maintenance.
</pitfall>
</anti_patterns>
<best_practices>
<practice name="behavior_focused_names">
Write test names that describe expected behavior:
- Format:
should {expected} when {condition} - Examples:
should return paginated results when dataset exceeds 100 recordsshould complete within 5 seconds when loading dashboardshould show error message when API returns 500
Result: Test serves as documentation, failures are self-explanatory.
</practice>
<practice name="minimal_reproduction">
Include only setup necessary to reproduce bug:// Include: State that triggers bug
const service = new StudentProgressService();
const result = await service.fetchData(studentWithLargeDataset);
// Exclude: Unrelated setup
// const userPrefs = loadPreferences(); // Not needed for this testResult: Faster tests, clearer intent, easier maintenance.
</practice>
<practice name="assert_specific">
Make assertions specific to the bug:// BAD: Vague assertion
expect(result).toBeTruthy();
// GOOD: Specific to bug being prevented
expect(result.length).toBeLessThanOrEqual(10); // Pagination limit
expect(response.time).toBeLessThan(5000); // No timeoutResult: Test catches regressions, not false positives.
</practice>
<practice name="document_context">
Include context in test file header:/**
* Regression Test for ERR-0042: Dashboard Timeout
*
* Bug: Dashboard failed to load due to missing pagination
* Root Cause: API call fetched all records (1000+) instead of paginated (10)
* Fixed: Added page_size parameter to API call
*
* @see specs/001-dashboard/error-log.md#ERR-0042
*/Result: Future developers understand why test exists.
</practice>
</best_practices>
<success_criteria> Regression test generation complete when:
- Bug details collected (error ID, symptoms, root cause, component)
- Test framework detected from project
- Test file location determined (follows project patterns)
- Test code generated with Arrange-Act-Assert structure
- Test presented to user for review
- User approved (A) or edited (B) test
- Test file written to correct location
- Test runs without syntax errors
- error-log.md updated with regression test reference
- Test file staged for commit </success_criteria>
<quality_standards> Good regression test:
- Clear name describing expected behavior
- Error ID in test name or comment
- Link to error-log.md entry
- Minimal setup (only what's needed to reproduce)
- Specific assertion (fails if bug reoccurs)
- Uses accessible selectors (E2E tests)
- Follows project test patterns
Bad regression test:
- Generic name (
test1,dashboard test) - No error reference (no traceability)
- Tests implementation details
- Brittle selectors or timing-dependent
- Vague assertions (
toBeTruthy) - Doesn't actually catch the bug if reintroduced </quality_standards>
<troubleshooting>
**Issue**: Can't detect test framework
**Solution**: Check package.json, pyproject.toml manually; ask user to specifyIssue: No existing test directory
Solution: Create tests/regression/ and document in test file comment
Issue: Test passes before fix applied Solution: Test may not be reproducing bug correctly; review reproduction steps
Issue: Test fails after fix applied Solution: Assertion may be testing wrong behavior; adjust to match expected post-fix state
Issue: User skips too many regression tests
Solution: Track in NOTES.md as tech debt; surface during /optimize phase
</troubleshooting>
<references>
See references/ for:
- Framework templates (Jest, Vitest, pytest, Playwright)
- Test location strategies (monorepo, co-located, centralized)
- Example regression tests (good vs bad patterns)
- Integration with error-log.md
</references>In this repository48 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .codex/Agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- analysis-phaseSkill
- anti-duplicationSkill
- audit-claude-mdSkill
- breaking-change-detectorSkill
- caching-strategySkill
- clarification-phaseSkill
- create-agent-skillsSkill
- create-hooksSkill
- create-meta-promptsSkill
- create-slash-commandsSkill
- create-subagentsSkill
- debug-phaseSkill
- dependency-conflict-resolverSkill
- design-tokensSkill
- domain-memorySkill
- dry-runSkill
- epic-meta-promptingSkill
- epic-scopingSkill
- epic-sprintsSkill
- epic-walkthroughSkill
- error-recoverySkill
- finalize-phaseSkill
- git-workflow-enforcerSkill
- hallucination-detectorSkill
- implementation-phaseSkill
- mockup-extractionSkill
- multi-agent-votingSkill
- optimization-phaseSkill
- parallel-execution-optimizerSkill
- planning-phaseSkill
- production-deployment-phaseSkill
- project-initialization-phaseSkill
- roadmap-integrationSkill
- session-boundarySkill
- shadcn-integrationSkill
- specification-phaseSkill
- staging-deployment-phaseSkill
- staging-validation-phaseSkill
- task-breakdown-phaseSkill
- task-status-syncSkill
- theme-consistencySkill
- ultrathinkSkill
- workflow-detectionSkill
- worktree-contextSkill
- x-announcementSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

