setup-tdd
БесплатноБез исполняемых скриптовНе проверенOne-command TDD infrastructure setup with pre-commit hooks and CI coverage gates
от jmagly★ 233 звезды на GitHubОб этом скилле
Setup TDD Command
Configure Test-Driven Development enforcement for the current project with a single command.
Research Foundation
This command implements TDD enforcement based on established research:
| Principle | Source | Reference |
|---|---|---|
| TDD Methodology | Kent Beck (2002) | "Test-Driven Development by Example" |
| 80% Coverage | Google (2010) | Code Coverage Goal |
| Pre-commit Hooks | Industry Practice | Husky, pre-commit |
| CI Gates | ISTQB CT-TAS | Test Automation Strategy |
Usage
/setup-tdd [options]
Options
| Option | Values | Default | Description |
|---|---|---|---|
--level |
strict, standard, gradual, audit | standard | Enforcement strictness |
--threshold |
0-100 | 80 | Line coverage threshold |
--branch-threshold |
0-100 | 75 | Branch coverage threshold |
Enforcement Levels
| Level | Pre-commit | CI Gate | Best For |
|---|---|---|---|
strict |
Block | Fail | New projects, critical systems |
standard |
Warn + Block | Fail | Most projects |
gradual |
Warn | Warn | Brownfield TDD adoption |
audit |
Log only | Report | Assessment before enforcement |
Instructions
When this command is invoked, perform these steps:
1. Analyze Project
- Detect project type (JavaScript, Python, Java, Go, Rust)
- Identify test framework (Vitest, Jest, Pytest, etc.)
- Check for existing test infrastructure
- Assess current coverage baseline
2. Configure Pre-commit Hooks
For JavaScript projects:
npm install --save-dev husky lint-staged
npx husky init
Create .husky/pre-commit:
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# Run tests for staged files
npx lint-staged
# Check coverage threshold
npm test -- --coverage
For Python projects:
pip install pre-commit pytest-cov
pre-commit install
Create .pre-commit-config.yaml:
repos:
- repo: local
hooks:
- id: pytest-coverage
name: pytest with coverage
entry: pytest --cov=src --cov-fail-under=80
language: system
types: [python]
pass_filenames: false
3. Configure CI Coverage Gates
Create .github/workflows/tdd-coverage-gate.yml:
name: TDD Coverage Gate
on:
pull_request:
branches: [main, master]
jobs:
test-coverage:
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 "::error::Coverage $COVERAGE% below 80% threshold"
exit 1
fi
- name: Comment on PR
uses: actions/github-script@v7
with:
script: |
// Add coverage report as PR comment
4. Create Test Presence Validation
Add script to validate new code has tests:
// scripts/check-test-presence.js
const changedFiles = getChangedFiles();
const srcFiles = changedFiles.filter(f => f.startsWith('src/'));
for (const src of srcFiles) {
const testFile = src.replace('src/', 'test/').replace('.ts', '.test.ts');
if (!fs.existsSync(testFile)) {
console.error(`Missing test: ${testFile}`);
process.exit(1);
}
}
5. Generate Documentation
Create docs/TDD_WORKFLOW.md:
# TDD Workflow
This project enforces Test-Driven Development.
## The TDD Cycle
1. **Red**: Write a failing test
2. **Green**: Write minimum code to pass
3. **Refactor**: Clean up while keeping tests green
## Coverage Requirements
- Line coverage: ≥80%
- Branch coverage: ≥75%
- Critical paths: 100%
## Pre-commit Checks
Every commit runs:
- Tests for staged files
- Coverage threshold validation
## CI Gates
Every PR requires:
- All tests passing
- Coverage ≥ threshold
- No coverage decrease
Output Format
Report setup results:
## TDD Enforcement Configured
**Project**: [project-name]
**Type**: JavaScript (Vitest)
**Level**: standard
### Pre-commit Hooks
- [x] Husky installed
- [x] lint-staged configured
- [x] Coverage check on commit
### CI Gates
- [x] GitHub Actions workflow created
- [x] Coverage threshold: 80%
- [x] PR comment integration
### Files Created
- `.husky/pre-commit`
- `.github/workflows/tdd-coverage-gate.yml`
- `docs/TDD_WORKFLOW.md`
### Files Modified
- `package.json` (added scripts)
### Next Steps
1. Run `npm test` to establish baseline
2. Commit changes to enable hooks
3. Create first PR to verify CI gates
Brownfield Adoption
For projects without tests, use gradual adoption:
Установить setup-tdd в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл setup-tdd?
One-command TDD infrastructure setup with pre-commit hooks and CI coverage gates
Как установить скилл setup-tdd?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл setup-tdd запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic