agentic/code/addons/testing-quality/skills/tdd-enforce/SKILL.md
Configure TDD enforcement via pre-commit hooks and CI coverage gates. Use when setting up test-first workflows or adding coverage gates.
npx skillsauth add jmagly/aiwg tdd-enforceInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Skill access pattern (post-kernel-pivot, 2026.5+)
Skill names referenced in this document are AIWG skills, not slash commands. Most are not kernel-listed and cannot be invoked as
/skill-nameby the platform. Reach them via:aiwg discover "<capability>" aiwg show skill <name>Only kernel-listed skills (
aiwg-doctor,aiwg-refresh,aiwg-status,aiwg-help,use,steward) are directly invokable as slash commands. See skill-discovery rule.
Configure Test-Driven Development enforcement through pre-commit hooks, CI coverage gates, and automated test execution. Ensures code cannot be committed or merged without adequate test coverage.
| Principle | Source | Reference | |-----------|--------|-----------| | TDD Methodology | Kent Beck (2002) | "Test-Driven Development by Example" | | 80% Coverage | Google Testing Blog (2010) | Code Coverage Goal | | Pre-commit Hooks | Industry Best Practice | Husky, pre-commit | | CI Gates | ISTQB CT-TAS | Test Automation Strategy |
| Natural Language | Action | |------------------|--------| | "Set up TDD enforcement" | Configure pre-commit + CI gates | | "Add coverage gates" | Configure CI coverage thresholds | | "Block commits without tests" | Set up pre-commit test hooks | | "Enforce test-first development" | Full TDD setup | | "Run tests on commit" | Configure pre-commit test execution | | "Check if tests exist for new code" | Configure test presence validation |
coverage:
line: 80 # Google standard: 80% minimum
branch: 75 # Branch coverage threshold
function: 90 # Function coverage threshold
critical_paths: 100 # Auth, payments, validation
| Level | Pre-commit | CI Gate | Description |
|-------|-----------|---------|-------------|
| strict | Block | Fail | No exceptions, 100% enforcement |
| standard | Warn + Block | Fail | Standard TDD enforcement |
| gradual | Warn | Warn | For TDD adoption in brownfield |
| audit | Log only | Report | Visibility without blocking |
def detect_project():
"""Identify project language and tooling"""
if exists("package.json"):
return "javascript" # Use Husky
elif exists("pyproject.toml") or exists("setup.py"):
return "python" # Use pre-commit
elif exists("pom.xml") or exists("build.gradle"):
return "java" # Use maven/gradle hooks
# ... etc
JavaScript (Husky + lint-staged):
npm install --save-dev husky lint-staged
npx husky init
.husky/pre-commit:
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# Run tests for staged files
npx lint-staged
# Check coverage delta
npm run test:coverage -- --changedSince=HEAD~1
Python (pre-commit):
pip install pre-commit
pre-commit install
.pre-commit-config.yaml:
repos:
- repo: local
hooks:
- id: pytest-check
name: pytest-check
entry: pytest --cov=src --cov-fail-under=80
language: system
types: [python]
pass_filenames: false
GitHub Actions:
name: Test Coverage Gate
on: [pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests with coverage
run: npm test -- --coverage
- name: Check coverage threshold
run: |
COVERAGE=$(jq '.total.lines.pct' coverage/coverage-summary.json)
if (( $(echo "$COVERAGE < 80" | bc -l) )); then
echo "Coverage $COVERAGE% is below 80% threshold"
exit 1
fi
- name: Comment coverage on PR
uses: actions/github-script@v7
with:
script: |
const coverage = require('./coverage/coverage-summary.json');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## Coverage Report\n- Lines: ${coverage.total.lines.pct}%\n- Branches: ${coverage.total.branches.pct}%`
});
Check that new/modified files have corresponding tests:
def validate_test_presence(changed_files):
"""Ensure every source file has a test file"""
missing_tests = []
for src_file in changed_files:
if is_source_file(src_file):
test_file = get_test_file_path(src_file)
if not exists(test_file):
missing_tests.append(src_file)
if missing_tests:
print("ERROR: Missing tests for:")
for f in missing_tests:
print(f" - {f}")
return False
return True
When reporting TDD enforcement setup:
## TDD Enforcement Configured
### Pre-commit Hooks
- [x] Husky installed and initialized
- [x] Pre-commit hook: Run affected tests
- [x] Pre-commit hook: Check test presence for new files
### Coverage Gates
- Line coverage threshold: 80%
- Branch coverage threshold: 75%
- Critical path coverage: 100%
### CI Integration
- [x] GitHub Actions workflow created
- [x] Coverage gate: Fail PR if coverage < 80%
- [x] PR comment: Coverage report
### Files Created/Modified
- `.husky/pre-commit`
- `.github/workflows/test-coverage.yml`
- `package.json` (scripts updated)
### Next Steps
1. Run `npm test` to verify baseline coverage
2. Commit and push to test CI gates
3. Review coverage report on first PR
For existing projects without tests:
enforcement: audit
# Log coverage but don't block
# Establish baseline
enforcement: gradual
coverage_delta: true # Only check new code
threshold: 80
enforcement: standard
threshold: 80
block_on_decrease: true
setup-tdd commandmutation-test skill for quality validationflow-gate-check for phase transitionsmutation-test - Validate test quality beyond coverageflaky-detect - Identify unreliable testsgenerate-factory - Create test data infrastructuretest-sync - Maintain test-code alignmentConfigure TDD enforcement for project:
# Standard enforcement (80% line, 75% branch)
python scripts/tdd_setup.py --level standard
# Custom thresholds
python scripts/tdd_setup.py --threshold 90 --branch-threshold 85
# Gradual adoption for brownfield projects
python scripts/tdd_setup.py --level gradual
# Preview without making changes
python scripts/tdd_setup.py --dry-run
Options:
--level: Enforcement level (strict, standard, gradual, audit)--threshold: Line coverage threshold (default: 80)--branch-threshold: Branch coverage threshold (default: 75)--dry-run: Show what would be done without making changesdata-ai
Report which research-corpus radar sidecars are overdue for refresh. Computes staleness (days since last refresh vs the cadence window) for every radar, sorted most-overdue-first. Runs via `aiwg corpus radar-status`.
data-ai
Aggregate research-corpus radar sidecars into a corpus or per-cluster freshness report — totals, overdue count, per-cluster / per-GRADE / per-trajectory breakdowns, an overdue table, and per-radar rationale snippets. Runs via `aiwg corpus radar-report`.
testing
Scaffold radar/freshness sidecars for research-corpus REFs. Pulls title/authors from the citation sidecar and GRADE from the analysis doc, defaults the refresh cadence from GRADE and the cluster from a corpus-local map, and stamps documentation/radar/REF-XXX-radar.md. Runs via `aiwg corpus radar-init`.
data-ai
Compute an entity's publication trajectory — per-year paper counts, topic drift, hot-streak detection (≥3 consecutive A-grade years), and career phase. Runs via `aiwg corpus profile-temporal`.