CLAUDE LABJP
NEST — Subagents can now spawn nested subagents up to depth 3 by default, up from 1, making research/build/verify pipelines practical without extra setupAPISKILL — The bundled claude-api skill now defaults to Claude Opus 5, with a documented migration path from Opus 4.8ENVVAR — ${VAR} entries in managed MCP allowlists and denylists now resolve from the startup environment and managed-settings env, not the settings-file envA11Y — A screen reader mode lets you follow a session with assistive tech, including announcements of deleted textVOICE — Voice mode now runs on Opus, Sonnet, and Haiku alike, reaches connected tools like Gmail and Slack, and supports many more languagesTEACH — Claude for Teachers launched on July 14, alongside a $10M commitment to Canadian AI researchNEST — Subagents can now spawn nested subagents up to depth 3 by default, up from 1, making research/build/verify pipelines practical without extra setupAPISKILL — The bundled claude-api skill now defaults to Claude Opus 5, with a documented migration path from Opus 4.8ENVVAR — ${VAR} entries in managed MCP allowlists and denylists now resolve from the startup environment and managed-settings env, not the settings-file envA11Y — A screen reader mode lets you follow a session with assistive tech, including announcements of deleted textVOICE — Voice mode now runs on Opus, Sonnet, and Haiku alike, reaches connected tools like Gmail and Slack, and supports many more languagesTEACH — Claude for Teachers launched on July 14, alongside a $10M commitment to Canadian AI research
Articles/Claude Code
Claude Code/2026-05-05Advanced

BDD with Claude Code in Production— From Gherkin Scenario Generation to Cross-Team Test Culture

A production-ready guide to Behavior-Driven Development with Claude Code. Learn how to auto-generate Gherkin scenarios, implement step definitions, integrate with Playwright/Cucumber, and build a cross-team test culture — all with working code examples.

Claude Code203BDDTesting2GherkinPlaywrightQuality AssuranceAutomation40

Premium Article

Have you ever tried introducing BDD (Behavior-Driven Development), only to hit a wall — scenarios you couldn't write, an explosion of step definitions to maintain, and a framework that only engineers ended up touching?

I've been there. Across multiple projects, I've attempted and then abandoned BDD. Learning Gherkin syntax was manageable, but writing scenarios that genuinely reflected business value from scratch was harder than expected, and the maintenance cost never felt worth it.

That changed when I started using Claude Code seriously. When you delegate scenario generation, step definitions, and test code automation to Claude Code, BDD transforms from something you write to something you cultivate. This guide walks you through that implementation with working, production-tested code.

What BDD Is — and Why Claude Code Changes Everything

BDD (Behavior-Driven Development) is a development methodology that describes application behavior in natural language, then uses that language as the specification for test code. Where TDD verifies code correctness, BDD documents business intent.

Using a DSL called Gherkin, scenarios look like this:

Feature: User Login
  Value: Only authenticated users can access the dashboard
 
  Scenario: Login succeeds with valid credentials
    Given the user has a registered account
    When they enter email "test@example.com" and password "SecurePass123"
    And they click the Login button
    Then they are redirected to the dashboard
    And the message "Welcome, Test User" is displayed
 
  Scenario: Login fails with incorrect password
    Given the user has a registered account
    When they enter email "test@example.com" and the wrong password "WrongPass"
    And they click the Login button
    Then the error message "Incorrect email or password" is displayed
    And they are not redirected to the dashboard

Writing these scenarios by hand becomes impractical as features grow in complexity. With Claude Code, you can auto-generate scenarios from requirements documents or user stories, and then automate the step definitions as well.

Project Setup

Installing Required Packages

Set up a BDD environment in your Next.js project:

# Build a BDD environment with Playwright + Cucumber.js
npm install --save-dev \
  @cucumber/cucumber \
  @playwright/test \
  playwright \
  @types/node
 
# Install Playwright browsers
npx playwright install chromium

Organize your project structure like this:

project-root/
├── features/                    # Gherkin scenario files
│   ├── auth/
│   │   └── login.feature
│   ├── dashboard/
│   │   └── overview.feature
│   └── support/
│       └── world.ts             # Cucumber World setup
├── steps/                       # Step definitions
│   ├── auth/
│   │   └── login.steps.ts
│   └── common/
│       └── navigation.steps.ts
└── cucumber.config.ts           # Cucumber configuration

Basic cucumber.config.ts configuration:

// cucumber.config.ts
import { defineConfig } from '@cucumber/cucumber';
 
export default defineConfig({
  default: {
    requireModule: ['ts-node/register'],
    require: ['steps/**/*.ts', 'features/support/**/*.ts'],
    format: [
      'progress-bar',
      'json:reports/cucumber-report.json',
      'html:reports/cucumber-report.html'
    ],
    formatOptions: { snippetInterface: 'async-await' },
    worldParameters: {
      baseUrl: process.env.BASE_URL || 'http://localhost:3000',
    },
    timeout: 30000,
    retry: 1,
  },
});

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
Developers stuck on BDD scenario design will be able to auto-generate Gherkin with Claude Code and start integrating it into real projects today
You'll gain a production-ready quality assurance system that integrates step definitions, E2E tests, and CI/CD pipelines in a single workflow
You'll learn how to design a test culture where non-engineers (POs, QA, designers) can actively participate — plus real team operating patterns
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Claude Code2026-07-25
Locking down Claude Code sandbox egress with strictAllowlist
Tightening automation egress with strictAllowlist in Claude Code v2.1.219, plus measured failure timings that tell a policy deny from DNS and real outages.
Claude Code2026-07-18
Branch with /fork, Delegate with /subtask — Two Commands That Traded Jobs
In Claude Code 2.1.212, /fork now clones your conversation into a background session, and in-session subagents moved to /subtask. Here is how I decide between them, and the budgets worth setting before you start branching freely.
Claude Code2026-07-17
The String I Approved Wasn't the String I Read — Testing a Relayed Permission Prompt with Deceptive Characters
I pushed bidi overrides and zero-width characters through my own approval relay. NFKC normalization caught 0%. Here is why, and the implementation that catches 100% with zero false positives.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →