К основному содержанию
скилл CX Codex

behavior-driven-development — скилл для Claude Code

Скилл behavior-driven-development задаёт BDD-процесс для фич, исправлений и тестов: сначала сценарий и падающий тест, затем код.

MIT 151 установок ★ 597 обновлён 2026-10-09

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add FradSer/dotclaude --skill behavior-driven-development -a claude-code
Открыть на GitHub

Что делает behavior-driven-development

Скилл помогает описывать поведение через конкретные примеры в формате Gherkin и превращать их в исполняемые спецификации. Сначала уточняются требования, затем формируются сценарии Given/When/Then, после чего реализация проходит цикл Red-Green-Refactor.

Плановые сценарии хранятся в bdd-specs.md, а автоматизируемые — в .feature или формате тестового фреймворка. Внутри также есть ссылки на ./references/bdd-best-practices.md, ./references/gherkin-guide.md и ./references/testing-anti-patterns.md.

Без предварительно падающего теста production-код писать нельзя: тест нужно запустить и проверить причину сбоя. Для уже существующего кода скилл требует удалить реализацию и вывести её заново из теста; исключения описаны в ./references/bdd-best-practices.md.

Какие задачи решает

  • описать поведение фичи сценариями Gherkin
  • проверить исправление бага через падающий тест
  • разделить плановые и исполняемые спецификации
  • провести реализацию через цикл Red-Green-Refactor

Примеры запросов агенту

  • Опиши новую функцию сценариями Given/When/Then и создай для них падающий тест.
  • Исправь этот баг по принципу BDD: сначала проверь, что тест падает по нужной причине.
  • Перенеси проверенные сценарии из bdd-specs.md в .feature и реализуй их через TDD.

Как установить behavior-driven-development

1Через Skills CLI (Vercel)

npx skills add FradSer/dotclaude --skill behavior-driven-development -a claude-code

2Вручную: положить файлы

~/.claude/skills/behavior-driven-development/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/behavior-driven-development/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о behavior-driven-development

Как установить behavior-driven-development в Claude Code?

Выполните npx skills add FradSer/dotclaude --skill behavior-driven-development -a claude-code. Скилл появится в ~/.claude/skills/behavior-driven-development/SKILL.md.

Что делает behavior-driven-development?

Скилл ведёт задачу от примеров поведения и Gherkin-сценариев к падающему тесту, минимальной реализации и рефакторингу.

Где хранить сценарии BDD?

Для планирования используйте bdd-specs.md. Сценарии, которые запускаются автоматически, храните в .feature или в нативном формате тестового фреймворка.

Исходный текст

SKILL.md · MIT
---
name: behavior-driven-development
description: Applies behavior-driven development principles including Gherkin scenarios and test-driven development. This skill should be used when the user asks to implement features, fix bugs, or when writing executable specifications and tests before writing production code.
user-invocable: false
---

# Behavior-Driven Development (BDD) Skill

This skill provides a comprehensive guide to applying Behavior-Driven Development principles to your coding tasks. BDD is not just about tools; it's a methodology for shared understanding and high-quality implementation.

## How to Use This Skill

When the user asks for a feature, bug fix, or refactor, apply the following mindset:

1.  **Understand Behavior First:** Do not start coding until you know *what* the system should do.
2.  **Define Scenarios:** Create or ask for concrete examples (Gherkin) of the expected behavior.
3.  **Drive Implementation with Tests:** Use the Red-Green-Refactor cycle.

## Core Concepts

### 1. The BDD Cycle
The process flows from requirements to code:
*   **Discovery:** Clarify requirements through examples (The "Three Amigos").
*   **Formulation:** Write these examples as specific scenarios (Given/When/Then).
*   **Automation:** Implement using TDD.

See `./references/bdd-best-practices.md` for a detailed guide.

### 2. Writing Scenarios (Gherkin)
Scenarios are your "Executable Specifications".
*   Keep them declarative (business focus).
*   Avoid technical jargon and UI details.
*   One behavior per scenario.
*   Use `bdd-specs.md` as the planning-stage scenario inventory in the superpowers workflow. During brainstorming and plan writing, keep the reviewed Given/When/Then scenarios in `docs/plans/.../bdd-specs.md` so design review, task decomposition, and sprint contracts all read from the same source.
*   **Store executable scenarios in .feature files, NOT as code comments** - once implementation begins, translate the scenarios that will be automated into `.feature` files or the framework-native executable test format. `bdd-specs.md` is for design and planning; `.feature` files are for automation and living documentation.

See `./references/gherkin-guide.md` for syntax and storage structure.

### 3. Red-Green-Refactor (TDD)
The engine of implementation:
1.  **RED:** Write a failing test for the scenario (or a unit thereof).
2.  **GREEN:** Write the minimal code to pass the test.
3.  **REFACTOR:** Clean up the code while keeping tests passing.

## CRITICAL: The Iron Law

> **"No production code is written without a failing test first."**

The Red step MUST verify the test fails for the right reason (run the test and read the failure output) before writing any implementation. Skipping or rationalizing this step produces:

1.  Tests that pass spuriously — you cannot tell if they are capable of failing.
2.  Implementation-biased tests — they reflect the code that was written, not the behavior under contract.
3.  Legacy code from day one — no behavioral safety net catches future regressions.

### If Production Code Already Exists

Delete it and re-derive it from a failing test — do not keep it "as reference," do not "adapt" it into the test-first version, do not read it while writing the test. Any of those re-introduces the implementation-biased-test failure mode above through the back door: a test written while looking at the code it's meant to constrain will pass on the first try regardless of whether it checks the right thing. Delete means delete.

### Common Rationalizations (reject all of these)

| Rationalization | Why it fails |
|---|---|
| "I'll write the test after — same coverage either way" | A test written against working code always passes on the first run. That proves the test doesn't crash, not that it verifies the right behavior. Only a test that failed first, for the stated reason, has been shown capable of catching a regression. |
| "I already manually verified it works" | Manual verification is not repeatable and leaves no regression guard. It answers "did this work once," not "will this keep working." |
| "This is too simple to need a test" | Simple code changes behavior just as easily as complex code. The Iron Law has no complexity threshold — it has the three named exceptions below and nothing else. |
| "I'll be pragmatic, not dogmatic, about TDD" | This is the rationalization, not an alternative to it. Every one of these tables' entries is someone being "pragmatic" about skipping the Red step. |
| "I already spent an hour on this, deleting it is wasteful" | Sunk cost. The hour is already spent whether you delete the code or keep it; keeping untested code doesn't recover that hour, it just adds an unverified regression risk on top of it. |

The only legitimate exceptions are named in `./references/bdd-best-practices.md` (one-off prototypes, generated code, config files) — and even those should be raised with the user, not silently assumed.

### Tests Written After the Fact Answer a Different Question

A test-first test encodes "this is what the system is contracted to do." A test-after test encodes "this is what the code I already wrote happens to do" — it will pass even if the code has the wrong behavior, because it was shaped to match that behavior rather than an independent specification. If you catch yourself writing a test against code you can already see, stop, delete the code, and write the test against the *behavior* instead.

## References

- `./references/bdd-best-practices.md` - BDD methodology, discovery, formulation, and automation
- `./references/gherkin-guide.md` - Gherkin scenario syntax, storage structure, and examples
- `./references/testing-anti-patterns.md` - Mocking pitfalls and other ways tests can pass without verifying real behavior

© FradSer · MIT · FradSer/dotclaude

Похожие скиллы

Все скиллы по теме «Тесты и QA» →
test-driven-development Jesse Vincent Скилл test-driven-development для Claude Code задаёт цикл TDD: тест, проверка падения, минимальный код и рефакторинг. Цикл охватывает новые функции, исправления и изменения поведения. CX Codex +1 259 292установок backend-development-test-automator Seth Hobson Субагент backend-development-test-automator генерирует модульные, интеграционные и E2E-тесты под стек проекта. Помогает писать тестовые наборы при разработке фич по методикам TDD и BDD. CX Codex ★ 42 780звёзд репо bdd-patterns TheBushidoCollective Скилл bdd-patterns для Claude Code помогает писать BDD-спецификации, сценарии и критерии приёмки в формате Given–When–Then. Создаёт тесты, понятные разработчикам и бизнесу. CX Codex +1 211установок bdd-scenarios TheBushidoCollective Скилл bdd-scenarios для Claude Code описывает поведение системы через BDD-сценарии, критерии приёмки и крайние случаи. Помогает согласовать требования до реализации. CX Codex +1 180установок gherkin-style-testing-cursorrules-prompt-file PatrickJS Правило gherkin-style-testing-cursorrules-prompt-file превращает технические тест-скрипты и ручные кейсы в Gherkin-сценарии на языке, понятном бизнесу и юристам. CX Codex +1 ★ 41 178звёзд репо principle-test-behavior-not-implementation backnotprop Скилл principle-test-behavior-not-implementation для Claude Code задаёт правила проверки кода через внешний интерфейс. Агент применяет его при написании, изменении или ревизии тестов. CX Codex +1 10 200установок

Из того же набора16

Весь набор →
patent-architect Скилл patent-architect ищет существующие патенты через SerpAPI или WebSearch и оформляет патентные заявки китайского образца. Пригодится при защите технических решений и проверке их новизны. CX Codex +1 622установок executing-plans Скилл executing-plans для Claude Code, Codex, Cursor и других платформ. Запускает реализацию готового плана разработки пачками задач через изолированных субагентов с финальным коммитом. CX Codex +1 126установок commit-and-push Скилл commit-and-push для Claude Code, Codex, Cursor и других платформ создаёт автоматические коммиты по стандарту Conventional Commits с помощью git-agent и отправляет их на удалённый репозиторий. CX Codex +1 126установок brainstorming Скилл brainstorming для Claude Code и ещё пяти платформ превращает сырые идеи в готовые BDD-спецификации. Запускает исследование репозитория и коммитит архитектурный дизайн без промежуточных расспросов. CX Codex +1 124установок writing-plans Скилл writing-plans для Claude Code, Codex, Cursor и других платформ превращает готовый дизайн в пошаговый план реализации. CX Codex +1 123установок refactor-project Скилл refactor-project для Claude Code, Codex, Cursor и других агентов запускает автоматический рефакторинг сразу по всем файлам проекта. Находит дубли, выравнивает стиль и убирает устаревший код за один прогон. CX Codex +1 122установок plugin-best-practices Скилл plugin-best-practices для проверки структуры, манифестов и архитектуры Claude Code плагинов по стандартам фреймворка. Помогает убедиться, что плагин соответствует требованиям до отправки в маркетплейс. CX Codex +1 121установок commit Скилл commit для Claude Code создаёт атомарные conventional-коммиты через git-agent. Оформляет изменения по краткому намерению. CX Codex +1 121установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой