tdd · backnotprop — скилл для Claude Code: регрессионный тест до фикса
Скилл заставляет агента сначала написать падающий тест на баг, а потом править код. Включается только когда тест дешёвый и очевидный.
npx skills add backnotprop/pstack --skill tdd -a claude-codeЧто делает tdd
Скилл описывает порядок работы с багом: разобраться в поведении, выбрать самый узкий исполняемый тест, написать его первым, убедиться, что он падает по нужной причине, и только затем менять продакшн-код. После фикса тест прогоняется снова. В конце агент отчитывается не результатом, а доказательствами: какой тест падал до правки и что показал прогон после.
Если тест не влезает в разумные рамки — нужна широкая обвязка, хрупкие моки, медленная интеграционная инфраструктура или состояние только из продакшна — скилл велит пропустить новый тест и взять ближайшую рабочую проверку: точечный скрипт, команду ручного воспроизведения, снимок или проверку логов. Пустой тест ради галочки хуже, чем его отсутствие.
Есть отдельные ограничения: не подгонять тесты под неверную реализацию, не ослаблять существующие проверки без ясной причины и не раздувать фикстуры. Флаг disable-model-invocation: true в описании скилла означает, что агент не вызывает его сам — нужен явный запрос на TDD, падающий тест или регрессионный тест. Это стоит помнить, если ждёте, что скилл сработает молча.
Какие задачи решает
- написать регрессионный тест, который падает до фикса
- воспроизвести баг минимальным исполняемым способом
- не подгонять тесты под текущую реализацию
- зафиксировать причину падения, а не только результат
- выбрать точечную проверку вместо дорогой интеграционной обвязки
Примеры запросов агенту
- напиши падающий тест на этот баг, потом почини
- сделай регрессионный тест для этого кейса
- почини баг через TDD
Как установить tdd
1Через Skills CLI (Vercel)
npx skills add backnotprop/pstack --skill tdd -a claude-code2Вручную: положить файлы
~/.claude/skills/tdd/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/tdd/
1Через Skills CLI (Vercel)
npx skills add backnotprop/pstack --skill tdd -a codex2Вручную: положить файлы
.agents/skills/tdd/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add backnotprop/pstack --skill tdd -a cursor2Вручную: положить файлы
.cursor/skills/tdd/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install backnotprop/pstack tdd2Вручную: положить файлы
.github/skills/tdd/SKILL.md1Через Skills CLI (Vercel)
npx skills add backnotprop/pstack --skill tdd -a gemini-cli2Командой платформы
gemini skills install https://github.com/backnotprop/pstack --path skills/tddВручную: положить файлы
.devin/skills/tdd/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add backnotprop/pstack --skill tdd -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о tdd
Как установить tdd в Claude?
Выполните npx skills add backnotprop/pstack --skill tdd -a claude-code. Скилл окажется в ~/.claude/skills/tdd/SKILL.md.
Что делает скилл tdd?
Ведёт агента по шагам: разобрать баг, написать узкий падающий тест, подтвердить причину падения, внести минимальную правку и прогнать тест снова. В ответе агент называет тест и результат обоих прогонов.
Когда скилл не станет писать тест?
Когда путь до теста неясен, дорог или требует интеграционной инфраструктуры. Тогда он берёт ближайшую исполняемую проверку — скрипт, ручное воспроизведение или проверку логов.
Исходный текст
SKILL.md · MIT
--- name: tdd description: "Use only when the user explicitly asks for TDD, a failing test, or a regression test, OR when the bug has an obvious cheap local test target. Skip when the test path is unclear, expensive, integration-heavy, or not requested." disable-model-invocation: true --- # TDD Bug Fix When fixing a bug with a clear, cheap test path, make the broken behavior executable before changing production code. The goal is a focused regression test that fails before the fix and passes after it. Do not force a test when it would be impractical. If the available test would require broad harness setup, brittle mocks, slow end-to-end infrastructure, production-only state, vague reproduction steps, or large unrelated fixture churn, skip adding a new test and use the closest useful verification instead. ## Workflow 1. **Understand the bug.** Identify the intended behavior, current behavior, affected path, and smallest observable reproduction. 2. **Choose the narrowest executable check.** Prefer the closest unit, component, integration, or regression test already used for that codepath. If no practical test path is obvious, do not create one from scratch just to satisfy the workflow. 3. **Write the failing test first.** Add the smallest focused test that would have caught the bug. The test should encode intended behavior, not mirror the current implementation. 4. **Run the new test before fixing.** Confirm it fails for the intended reason. If it passes or fails for an unrelated reason, correct the test or reproduction before editing the implementation. 5. **Fix the bug.** Make the smallest production change that satisfies the intended behavior while preserving nearby contracts. 6. **Rerun the regression test.** Confirm the test now passes. ## If a Failing Test Is Impractical Use the closest executable regression check instead: a targeted script, manual reproduction command, browser automation, snapshot comparison, log assertion, or focused integration check. Prefer no new test over a bad test. A bad test is one that mostly tests mocks, encodes current implementation details, depends on timing or unrelated global state, needs expensive infrastructure for a small fix, or would be deleted immediately after proving the fix. ## Guardrails - Do not change tests merely to match a wrong implementation. - Do not weaken existing assertions unless the expected behavior has genuinely changed and the reason is clear. - Keep the regression test focused on the bug. Avoid broad fixture churn or unrelated coverage expansion. - If the bug is flaky, make the test deterministic where possible and document the signal being locked down. - If the bug exposes a broader class of failures, first land the focused regression path, then consider additional sibling coverage. ## Final Response Report the evidence, not just the outcome: - Name the failing-before test or executable check and the failure it produced. - Name the passing-after test run and any nearby validation performed. - If failing-before evidence could not be demonstrated, state why and describe the closest regression check used instead.
© backnotprop · MIT · backnotprop/pstack
Похожие скиллы
Всё по теме «Тесты и QA» →Сначала — tdd от других авторов.