Skip to content
gherkin logo

Gherkin Feature File Skill

gherkin

Create and format Gherkin feature files using BDD syntax. Use when creating feature files, scenarios, or writing behavioral specifications.

SKILL.md

Full skill instructions

Gherkin Feature File Skill

File Naming Convention

IMPORTANT: All Gherkin feature files MUST follow this naming pattern:

gherkin.feature_N.feature

Where N is a sequential number (1, 2, 3, etc.)

Examples:

  • gherkin.feature_1.feature
  • gherkin.feature_2.feature
  • gherkin.feature_42.feature

When Uncertain About Formatting

If you have questions about Gherkin syntax or formatting:

  1. First, check the examples below for common patterns
  2. If still unclear, refer to the official documentation at: https://cucumber.io/docs/gherkin/reference

Core Gherkin Structure

Basic Feature Template

@tag
Feature: Feature Name

  Background: (Optional - runs before each scenario)
    Given some common precondition

  Scenario: Scenario Name
    Given a precondition
    When an action occurs
    Then an expected outcome
    And another expected outcome

  Scenario Outline: Scenario with examples
    Given a user with <status>
    When they perform <action>
    Then they should see <result>

    Examples:
      | status | action | result  |
      | admin  | delete | success |
      | user   | delete | denied  |

Using Rules

Feature: Feature Name

  Rule: Business Rule Name

    Example: First scenario under this rule
      Given a precondition
      When an action
      Then an outcome

    Example: Second scenario under this rule
      Given another precondition
      When another action
      Then another outcome

  Rule: Another Business Rule

    Example: Scenario for second rule
      ...

Keywords Reference

  • Feature: High-level description of a software feature
  • Rule: Represents a business rule to implement (optional)
  • Example/​Scenario: Concrete example illustrating a business rule
  • Scenario Outline: Template scenario with multiple inputs via Examples table
  • Background: Steps to run before each scenario in the feature
  • Given: Describes the initial context (preconditions)
  • When: Describes an event or action
  • Then: Describes an expected outcome (postcondition)
  • And/​But: Additional steps for any of the above
  • @tag: Annotations for filtering/​organizing (e.g., @failing, @wip, @smoke)

Canonical Examples

Example 1: Simple Game Feature

@failing
Feature: Guess the word

  # The first example has two steps
  Scenario: Maker starts a game
    When the Maker starts a game
    Then the Maker waits for a Breaker to join

  # The second example has three steps
  Scenario: Breaker joins a game
    Given the Maker has started a game with the word "silky"
    When the Breaker joins the Maker's game
    Then the Breaker must guess a word with 5 characters

Example 2: Feature with Rules

# -- FILE: features/​gherkin.rule_example.feature
@failing
Feature: Highlander

  Rule: There can be only One

    Example: Only One -- More than one alive
      Given there are 3 ninjas
      And there are more than one ninja alive
      When 2 ninjas meet, they will fight
      Then one ninja dies (but not me)
      And there is one ninja less alive

    Example: Only One -- One alive
      Given there is only 1 ninja alive
      Then they will live forever ;-)

  Rule: There can be Two (in some cases)

    Example: Two -- Dead and Reborn as Phoenix
      ...

Best Practices

  1. Use descriptive feature names that clearly state the business capability
  2. Write scenarios from the user's perspective, not implementation details
  3. Keep scenarios independent - each should be able to run alone
  4. Use tags to organize and filter scenarios (@smoke, @wip, @failing, etc.)
  5. Comments can be added with # but use sparingly
  6. Rules help organize related scenarios under business rules
  7. Data tables can be used in steps for structured input
  8. Doc strings (triple quotes) can include multi-line text in steps

Common Patterns

Data Tables in Steps

Given the following users exist:
  | name  | email           | role  |
  | Alice | [email protected]  | admin |
  | Bob   | [email protected]    | user  |

Doc Strings

Given a blog post with content:
  """
  This is a multi-line
  blog post content
  """

Creating New Feature Files

When asked to create a Gherkin feature:

  1. Determine the next number by checking existing gherkin.feature_*.feature files
  2. Create the file with the correct naming convention
  3. Start with a Feature declaration including appropriate tags
  4. Use Rules if organizing multiple related scenarios
  5. Write clear, behavior-focused scenarios using Given/​When/​Then
  6. Add comments only where they clarify complex logic
  7. Review against examples above to ensure consistent style

Additional Resources

For complex questions about Gherkin syntax, step arguments, or advanced features:

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View