Comprehensive BDD testing with Cucumber and Gherkin syntax. Use when writing feature files (.feature), step definitions, hooks, or implementing Behaviour-Driven Development. Covers Gherkin keywords (Feature, Scenario, Given/When/Then, Background, Scenario Outline, Rule), step definition patterns for Ruby/JavaScript/Java/Python, hooks (Before/After/BeforeAll/AfterAll), tags, data tables, doc strings, and best practices. Triggers on cucumber, gherkin, BDD, feature files, step definitions, acceptance testing, executable specifications.
BDD testing framework with Gherkin syntax. Helps write executable specifications, step definitions, and hooks for Ruby, JavaScript, Java, or Python when creating feature files or acceptance tests.
/plugin marketplace add el-feo/ai-context/plugin install ruby-rails@jebs-dev-toolsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/best-practices.mdreferences/gherkin-syntax.mdreferences/hooks-config.mdreferences/step-definitions.mdBDD testing framework with plain-text executable specifications. Gherkin syntax with step definitions in Ruby, JavaScript, Java, or Python.
Cucumber reads executable specifications in plain text and validates software behavior. Gherkin is the structured grammar making plain text machine-readable.
┌────────────┐ ┌──────────────┐ ┌───────────┐
│ Steps │ │ Step │ │ │
│ in Gherkin ├──matched with──>│ Definitions ├───manipulates──>│ System │
└────────────┘ └──────────────┘ └───────────┘
Feature: Short description
Optional multi-line description explaining the feature.
Background:
Given common setup steps for all scenarios
Rule: Business rule grouping (Gherkin 6+)
Scenario: Concrete example illustrating the rule
Given an initial context (past tense, setup)
When an action occurs (present tense, trigger)
Then expected outcome (assertion)
And additional step
But negative assertion
Scenario Outline: Parameterized scenario
Given there are <start> items
When I remove <remove> items
Then I should have <remaining> items
Examples:
| start | remove | remaining |
| 12 | 5 | 7 |
| 20 | 5 | 15 |
| Keyword | Purpose | Example |
|---|---|---|
Given | Setup/precondition | Given I am logged in as "admin" |
When | Action/trigger | When I click the submit button |
Then | Assertion/outcome | Then I should see "Success" |
And | Continue previous type | And I have 3 items in my cart |
But | Negative continuation | But I should not see "Error" |
* | Bullet-style step | * I have eggs |
Data Tables - tabular data:
Given the following users exist:
| name | email | role |
| Alice | alice@example.com | admin |
| Bob | bob@example.com | user |
Doc Strings - multi-line text:
Given a blog post with content:
"""markdown
# My Post Title
This is the content of my blog post.
"""
@smoke @critical
Feature: User authentication
@wip
Scenario: Login with valid credentials
...
@slow @database
Scenario: Bulk user import
...
Tag expressions: @smoke and not @slow, @gui or @api, (@smoke or @critical) and not @wip
Match Gherkin steps to code. Use Cucumber Expressions (preferred) or Regular Expressions.
Given('I have {int} cucumbers in my belly') do |count|
@belly = Belly.new
@belly.eat(count)
end
When('I wait {int} hour(s)') do |hours|
@belly.wait(hours)
end
Then('my belly should growl') do
expect(@belly.growling?).to be true
end
# With data table
Given('the following users exist:') do |table|
table.hashes.each do |row|
User.create!(row)
end
end
const { Given, When, Then } = require('@cucumber/cucumber');
Given('I have {int} cucumbers in my belly', function(count) {
this.belly = new Belly();
this.belly.eat(count);
});
When('I wait {int} hour(s)', async function(hours) {
await this.belly.wait(hours);
});
Then('my belly should growl', function() {
expect(this.belly.isGrowling()).toBe(true);
});
// With data table
Given('the following users exist:', async function(dataTable) {
for (const row of dataTable.hashes()) {
await User.create(row);
}
});
public class StepDefinitions {
@Given("I have {int} cucumbers in my belly")
public void iHaveCucumbersInMyBelly(int count) {
belly = new Belly();
belly.eat(count);
}
@When("I wait {int} hour(s)")
public void iWaitHours(int hours) {
belly.wait(hours);
}
@Then("my belly should growl")
public void myBellyShouldGrowl() {
assertTrue(belly.isGrowling());
}
}
Built-in parameter types: {int}, {float}, {word}, {string}, {} (anonymous)
Optional text: cucumber(s) matches "cucumber" or "cucumbers"
Alternative text: color/colour matches "color" or "colour"
# Ruby
Before do |scenario|
# runs before each scenario
end
After do |scenario|
# runs after each scenario
screenshot if scenario.failed?
end
// JavaScript
const { Before, After } = require('@cucumber/cucumber');
Before(async function(scenario) {
// runs before each scenario
});
After(async function(scenario) {
// runs after each scenario
if (scenario.result.status === 'FAILED') {
await this.screenshot();
}
});
Before('@database') do
DatabaseCleaner.start
end
After('@database') do
DatabaseCleaner.clean
end
Before({ tags: '@browser and not @headless' }, async function() {
this.browser = await launchBrowser();
});
BeforeAll do
# once before any scenario
end
AfterAll do
# once after all scenarios
end
Good (declarative):
When "Bob" logs in
Then he sees his dashboard
Avoid (imperative):
When I visit "/login"
And I enter "bob" in "username"
And I enter "secret" in "password"
And I click "Login"
Then I should see "Dashboard"
# Ruby
bundle exec cucumber
cucumber --tags "@smoke and not @wip"
cucumber features/login.feature:10 # specific line
# JavaScript
npx cucumber-js
npx cucumber-js --tags "@smoke"
# Java (with Maven)
mvn test -Dcucumber.filter.tags="@smoke"
For comprehensive details, see reference files:
references/gherkin-syntax.md - Complete Gherkin language referencereferences/step-definitions.md - Step definition patterns by languagereferences/hooks-config.md - Hooks, configuration, and runnersreferences/best-practices.md - Anti-patterns and advanced patternsThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.