BDD Specs with Gherkin & Cucumber

VerifiedSafe

Write disciplined BDD specs and Gherkin/Cucumber tests with clean step definitions and Vitest or Playwright integration.

Sby Skills Guide Bot
TestingIntermediate
11/8/2026
Claude CodeCursorWindsurfCopilotCodex
#bdd#gherkin#cucumber#acceptance-testing#living-documentation

Recommended for

Automated summary

Guides writing business-readable BDD specifications with Gherkin/Cucumber, including .feature files, scenarios, step definitions, and Vitest/Playwright integration notes.

Strengths

  • Enforces Gherkin discipline with a clear keyword-usage table and anti-patterns.
  • Covers Scenario Outline, Background, Rule, tags, and step definitions.
  • Provides guidance for refactoring imperative or UI-coupled feature files.
  • Includes dedicated references for Vitest and Playwright integration and setup.

Limitations

  • The visible body is high-level; implementation details depend on separate reference files not included here.
  • Focuses on BDD/Gherkin and explicitly excludes unit tests without a business contract, performance/load tests, and generic framework questions.
  • Assumes Three Amigos-style collaboration and genuine business value, which may be too heavy for simple cases or teams.
When to use it

Use when turning acceptance criteria into executable plain-English specs with Gherkin/Cucumber, or when refactoring feature files and step definitions.

When not to use it

Do not use for unit tests without a business-readable contract, performance/load tests, or generic test-framework questions unrelated to behavior specs.

Security analysis

Safe
Quality score92/100

The file is pure documentation/instruction content about writing Gherkin feature files and step definitions. It declares no tools and contains no commands, scripts, network calls, file writes, or obfuscated payloads. There are no instructions attempting to alter the auditor's role or exfiltrate data, so listing it presents no meaningful execution risk.

No concerns found

How this analysis is made

Examples

Write a guest checkout feature
Turn these guest checkout acceptance criteria into a Gherkin feature file with a Scenario Outline for regional tax, and propose the matching step definitions.
Refactor a UI-coupled feature file
Refactor this .feature file so it describes business behavior instead of UI clicks, and explain which steps should become step definitions.
Set up BDD with Playwright
Help me wire up BDD with Playwright and Cucumber, including the config and a minimal .feature file with step definitions.

name: bdd description: Write disciplined Behavior-Driven Development specs and tests with Gherkin / Cucumber. Use whenever the user mentions BDD, Gherkin, Cucumber, .feature files, Given/When/Then, scenarios, Scenario Outline, Background, step definitions, acceptance criteria, executable specifications, living documentation, the Three Amigos, or Example Mapping. Also trigger when the user asks to "write tests in plain English", convert acceptance criteria into tests, design step definitions, refactor an imperative or UI-coupled feature file, or wire up BDD with Vitest (unit/component) or Playwright (end-to-end). Do NOT use for pure unit tests with no business-readable contract, pure performance/load tests, or generic test-framework questions unrelated to behavior specs.

Behavior-Driven Development (BDD)

Produces feature files that read like behavior, step definitions that don't leak implementation, and an honest call on when BDD pays for itself. The body is tool-agnostic — load the relevant reference for Vitest or Playwright.

When to use this skill

  • The user names a BDD concept: BDD, Gherkin, Cucumber, .feature, Given/When/Then, Scenario Outline, Background, Rule, step definitions, executable specifications, living documentation, Three Amigos, Example Mapping.
  • The user wants to turn acceptance criteria into tests, write tests in plain English, or refactor a .feature file.
  • Vitest + BDD → also load references/vitest.md. Playwright + BDD → also load references/playwright.md.
  • Setting up either from zero → load references/install-vitest.md or references/install-playwright.md.

Skip for: unit tests with no business audience, performance/load tests, internal refactors, or generic test-framework questions.

Gherkin cheat sheet

@checkout                             # tag (selection + tagged hooks)
Feature: Guest checkout
  As a visitor                         # free-form preamble (not executable)
  ...
  Background:                          # Given steps run before every Scenario in this file
    Given the storefront is online

  Rule: Tax is applied per region      # Gherkin 6 — groups scenarios by business rule
    @smoke
    Scenario Outline: Tax for <region>
      When  Patty adds a "Bluetooth Speaker" to her cart
      And   she checks out shipping to "<region>"
      Then  the displayed tax rate is "<rate>"

      Examples:
        | region          | rate |
        | California, US  | 8.5% |
        | Berlin, DE      | 19%  |

| Keyword | Use for | Don't use for | |----------------------------------|----------------------------------------------------------------------------|--------------------------------------------------------------| | Rule: (Gherkin 6+) | Group scenarios that illustrate one business rule. | A feature with only one rule. | | Background: | Given steps shared by every scenario in the file/Rule. | Anything containing a When. | | Scenario: / Example: | One behavior. Example: preferred in Gherkin 6+. | Multiple outcomes glued by And. | | Scenario Outline: + Examples:| Same steps, varied by business-meaningful data with domain-named columns. | Exhaustive boundary testing; rows with technical column names like pw/result. | | Given / When / Then | Context / action / observable outcome. | More than one When per scenario. | | @tag | Selective execution, tagged hooks. | Control flow / if on tags inside steps. |

The three rules that move output quality

These are the patterns that distinguish disciplined BDD from "Gherkin-shaped" output. Each is what the model gets wrong by default if you don't insist.

1. Declarative + third-person voice

Steps describe what the system does, not how the user clicks. Voice is third-person/persona (she, Patty, a shopper) — never first-person I. Litmus test: would this wording change if the implementation changed? If yes, rewrite.

# ❌ Wrong — imperative, UI-coupled, first-person; breaks on a CSS rename
Scenario: User registers
  Given I navigate to "/signup"
  When  I enter "jane@acme.com" in the "#email" field
  And   I click the "Create account" button
  Then  the URL should be "/welcome"

# ✅ Right — declarative, third-person, survives UI rewrite
Scenario: A new visitor completes registration
  Given Jane is a new visitor
  When  she registers with a valid email and password
  Then  she is signed in

2. One behavior per scenario; Rule: to group

Multiple Whens usually mean two scenarios pretending to be one. Split them; use Rule: to make the policy structure explicit. The first-line test: if you'd write a scenario title containing "and", split it.

# ❌ Wrong — three orthogonal outcomes; one failure can't tell you which rule broke
Scenario: Checkout
  Given Patty has a cart with a $40 item
  When  she applies the coupon "SAVE10"
  And   she pays with her saved Visa
  Then  the order total is $36
  And   a confirmation email is sent
  And   the inventory count drops by 1

# ✅ Right — each rule gets its own scenario under a Rule: block
Rule: Coupons apply before payment
  Example: A valid coupon reduces the order total
    Given Patty has a cart with a $40 item
    When  she applies the coupon "SAVE10"
    Then  her order total is $36

Rule: Successful checkout notifies customer and warehouse
  Example: Confirmation email is sent on successful payment
    Given Patty has a paid order
    Then  she receives a confirmation email

3. Scenario Outline columns are domain-named, not technical

Use Outline when the steps are identical and each row is a business-meaningful variation. Column headers are domain concepts (missing requirement, region), not literal values dressed up (pw, result). When the table starts looking like fuzz-test input, push it to a unit test.

# ❌ Wrong — Outline as unit-test substitute; columns are technical
Scenario Outline: Password validation
  When I submit the password "<pw>"
  Then the result is "<result>"

  Examples:
    | pw         | result  |
    | a          | invalid |
    | Aaaaaaa1!  | valid   |
    | ...20 rows | ...     |

# ✅ Right — domain-named column; exhaustive cases go to a unit test
Rule: Passwords must satisfy the corporate strength policy
  Scenario Outline: Sign-up rejects a password that is <missing requirement>
    Given Jane is signing up
    When  she submits a password that is <missing requirement>
    Then  sign-up is rejected with a message about <missing requirement>

    Examples: Strength policy violations
      | missing requirement   |
      | too short             |
      | missing an uppercase  |
      | missing a digit       |
      | missing a symbol      |

Output contract

When generating BDD code:

  • Feature files: declarative, domain-language, third-person voice. No CSS selectors, no URLs, no UI verbs.
  • One behavior per scenario. Rule: to group; Example: preferred over Scenario: in Gherkin 6+.
  • Scenario Outline columns are domain-named. No pw/result-style technical columns.
  • State lives in the World / context / fixtures (per scenario), never module globals or file-level let.
  • Assertions only in Then. Setup in Given; the single state change in When.
  • Tags for selection (@smoke, @regression, @wip), not for control flow.
  • No external data files (CSV/Excel). Examples live in the feature file.

Reference quick map

| Task | Read | |---------------------------------------------------------------|-----------------------------------| | BDD/Gherkin principles, refactoring scenarios | this SKILL.md | | Install Vitest BDD in a project from zero | references/install-vitest.md | | Vitest + Gherkin (@amiceli/vitest-cucumber) — writing tests | references/vitest.md | | Install Playwright BDD in a project from zero | references/install-playwright.md | | Playwright + Gherkin (playwright-bdd) — writing tests | references/playwright.md |

If the user names a different runner (Cucumber-JVM, Cucumber.js, behave, SpecFlow), the principles in this file still apply — only the binding API differs. Translate the patterns rather than refusing.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/bdd-specs-with-gherkin-cucumber-mvj1obwi/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/bdd-specs-with-gherkin-cucumber-mvj1obwi' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/bdd-specs-with-gherkin-cucumber-mvj1obwi/download' --output '.skill-downloads/bdd-specs-with-gherkin-cucumber-mvj1obwi/SKILL.md.part' && mv '.skill-downloads/bdd-specs-with-gherkin-cucumber-mvj1obwi/SKILL.md.part' '.skill-downloads/bdd-specs-with-gherkin-cucumber-mvj1obwi/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/bdd-specs-with-gherkin-cucumber-mvj1obwi/SKILL.md' && test -s '.skill-downloads/bdd-specs-with-gherkin-cucumber-mvj1obwi/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/bdd' && cp -R '.skill-downloads/bdd-specs-with-gherkin-cucumber-mvj1obwi' '.claude/skills/bdd'

Cursor
test -f '.skill-downloads/bdd-specs-with-gherkin-cucumber-mvj1obwi/SKILL.md' && test -s '.skill-downloads/bdd-specs-with-gherkin-cucumber-mvj1obwi/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/bdd' && cp -R '.skill-downloads/bdd-specs-with-gherkin-cucumber-mvj1obwi' '.cursor/skills/bdd'

Codex
test -f '.skill-downloads/bdd-specs-with-gherkin-cucumber-mvj1obwi/SKILL.md' && test -s '.skill-downloads/bdd-specs-with-gherkin-cucumber-mvj1obwi/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/bdd' && cp -R '.skill-downloads/bdd-specs-with-gherkin-cucumber-mvj1obwi' '.agents/skills/bdd'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/bdd-specs-with-gherkin-cucumber-mvj1obwi'

openskills read 'bdd-specs-with-gherkin-cucumber-mvj1obwi'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/bdd-specs-with-gherkin-cucumber-mvj1obwi/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills