arabelatso/test-deduplicator
Analyzes test suites to identify redundant and duplicate test cases using coverage analysis, semantic similarity, and execution results. Use this skill when you need to reduce test suite size, identify redundant tests, optimize test execution time, analyze test coverage overlap, find tests with identical behavior, or improve test suite maintainability. Triggers when users ask to deduplicate tests, find redundant test cases, reduce test suite size, identify duplicate tests, or optimize test coverage.
npx skills add https://github.com/ArabelaTso/Skills-4-SE --skill test-deduplicator
This skill analyzes test suites to identify redundant or duplicate tests by examining code coverage, semantic similarity, and execution behavior. It groups equivalent tests, explains deduplication rationale, and recommends which tests can be safely removed while preserving overall test effectiveness.
First, gather coverage information for each test in the suite.
For Python projects with pytest:
# Run tests with coverage for each test individually
pytest --cov=src --cov-report=json tests/
# Or use the coverage analyzer script with pre-collected data
python scripts/coverage_analyzer.py coverage_data.json --output coverage_analysis.json
Coverage data format:
{
"test_module::test_function_1": {
"coverage": {
"src/module.py": [10, 11, 12, 15, 20],
"src/utils.py": [5, 6, 7]
}
},
"test_module::test_function_2": {
"coverage": {
"src/module.py": [10, 11, 12, 15, 20],
"src/utils.py": [5, 6, 7]
}
}
}
Parse test code to identify semantic similarities:
python scripts/semantic_analyzer.py tests/*.py --output semantic_analysis.json --threshold 0.7
This analyzes:
Combine coverage and semantic analysis to produce recommendations:
python scripts/deduplicator.py \
--coverage coverage_analysis.json \
--semantic semantic_analysis.json \
--output recommendations.json \
--threshold 0.8
Examine the generated recommendations:
{
"redundant_groups": [
{
"type": "identical_coverage",
"tests": ["test_a", "test_b", "test_c"],
"reason": "Tests have identical code coverage",
"confidence": 1.0,
"keep": "test_a",
"remove": ["test_b", "test_c"],
"rationale": "test_a has descriptive name, fast execution"
}
],
"removal_candidates": [...],
"coverage_impact": {
"coverage_preserved": true,
"tests_removed": 15
}
}
After manual review, remove approved redundant tests and verify coverage is preserved.
Identifies tests with overlapping or identical coverage patterns.
Redundancy Types:
Script: scripts/coverage_analyzer.py
Output:
Identifies tests with similar code structure and assertions.
Similarity Metrics:
Script: scripts/semantic_analyzer.py
Output:
Combines multiple signals for comprehensive recommendations.
Redundancy Score:
Redundancy = 0.5 × Coverage_Sim + 0.3 × Semantic_Sim + 0.2 × Execution_Sim
Script: scripts/deduplicator.py
Output:
Customize analysis using the configuration template:
cp assets/deduplication_config.json my_config.json
# Edit my_config.json
Key Settings:
Thresholds:
identical_coverage: 1.0 (exact match)highly_similar_coverage: 0.9semantic_similarity: 0.7overall_redundancy: 0.8Prioritization Weights:
unique_coverage_lines: 10 (most important)execution_speed_bonus: 5stability_bonus: 3name_clarity_bonus: 2Safety Checks:
preserve_coverage: true (must maintain coverage)require_manual_review: true (human approval needed)min_confidence_for_auto_removal: 0.95User: "Our test suite has grown to 500 tests and takes too long to run. Find redundant tests."
→ Run coverage analysis on all tests
→ Run semantic analysis on test files
→ Generate deduplication recommendations
→ Review and remove redundant tests
→ Verify coverage is preserved
User: "We merged two branches and suspect there are duplicate tests now."
→ Analyze tests from both branches
→ Find tests with identical coverage and assertions
→ Recommend which duplicates to remove
→ Prioritize keeping tests with better names/documentation
User: "Tests take 30 minutes in CI. Which tests can we safely remove?"
→ Analyze coverage overlap
→ Find subsumed tests (tests fully covered by others)
→ Calculate time savings from removal
→ Generate removal plan with coverage guarantee
User: "Clean up our test suite and remove low-value tests."
→ Identify tests with zero unique coverage contribution
→ Find tests with identical assertions
→ Group semantically similar tests
→ Recommend merging or removing redundant tests
Identical Coverage (Confidence: 1.0)
Subsumed Tests (Confidence: 0.95)
Highly Similar (Confidence: 0.85)
Semantically Identical (Confidence: 0.90)
Tests are prioritized to keep based on:
Analyzes test coverage to identify redundant tests:
Analyzes test code for semantic similarity:
Integrated deduplication engine:
Comprehensive methodology guide covering:
Read this reference when you need deeper understanding of the methodology, want to customize similarity metrics, or need to explain the approach to stakeholders.
Configuration template for customizing:
Copy and modify this template to create custom configurations for specific projects or test suite characteristics.
Take arabelatso/test-deduplicator from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.