skills/swe-gherkin-spec/SKILL.md
Write Gherkin BDD specs for a feature. Creates .feature files in tests/specs/ from requirements, user stories, or free-form descriptions.
npx skillsauth add earthmanweb/serena-workflow-engine swe-gherkin-specInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
If starting a new session, first read workflow initialization:
mcp__plugin_swe_serena__read_memory("wf/WF_INIT")
Follow WF_INIT instructions before executing this skill.
Write Gherkin BDD specifications for a feature. Creates .feature files in the project's tests/specs/ directory.
/swe-gherkin-spec # Interactive — prompts for feature and requirements
/swe-gherkin-spec AUTH # Spec the AUTH feature
/swe-gherkin-spec AUTH --slug login-flow # Spec with explicit filename slug
If $ARGUMENTS includes a feature key, use it. Otherwise:
mcp__plugin_swe_serena__read_memory("index/INDEX_FEATURES")
Present registered features and ask:
AskUserQuestion({
questions: [{
question: "Which feature should I write Gherkin specs for?",
header: "Feature",
options: [
// Populate from INDEX_FEATURES
],
multiSelect: false
}]
})
mcp__plugin_swe_serena__read_memory("feature/FEATURE_[KEY]")
Load all supporting memories from the feature's Related Memories table (DOM_, SYS_, ARCH_*).
Check for existing specs directory:
Glob(pattern="tests/specs/**/*.feature")
Glob(pattern="test/specs/**/*.feature")
Glob(pattern="spec/**/*.feature")
Convention: Use tests/specs/ as the default. If the project already has .feature files elsewhere, use that location instead.
If the directory doesn't exist, create it:
mkdir -p tests/specs
If specs already exist for this feature:
Glob(pattern="tests/specs/*[feature-key]*.feature")
Present them and ask whether to extend or create new.
Parse the user's request for behavioral requirements. Look for:
If the feature already has implementation, research it:
mcp__plugin_swe_serena__get_symbols_overview("[feature root path]", depth=1)
mcp__plugin_swe_serena__search_for_pattern(substring_pattern="...", relative_path="[feature path]")
Extract implicit requirements from existing code behavior.
Check DOM_* memories for behavioral rules that apply:
mcp__plugin_swe_serena__list_memories(topic="dom")
Read any that relate to this feature's domain.
Organize requirements into Gherkin features and scenarios:
Feature: [Feature name]
[Brief description of the feature's purpose]
Background:
[Common preconditions shared across scenarios]
Scenario: [Descriptive scenario name]
Given [precondition]
When [action]
Then [expected outcome]
And [additional assertion]
Scenario Outline: [Parameterized scenario name]
Given [precondition with <parameter>]
When [action with <parameter>]
Then [expected outcome with <parameter>]
Examples:
| parameter | expected |
| value1 | result1 |
| value2 | result2 |
.feature file covers one logical feature area@tag for grouping (e.g., @smoke, @regression, @wip)Every spec must include:
Present the draft spec with a coverage summary:
## Gherkin Spec Draft: [FEATURE_KEY] / [slug]
### File: `tests/specs/[feature-key]-[slug].feature`
[Full Gherkin content]
### Coverage Summary
| # | Scenario | Type | Requirement Source |
|---|----------|------|--------------------|
| 1 | [name] | Happy path | User request / DOM_* / Existing code |
| 2 | [name] | Error case | Inferred from domain rules |
| ...
### Questions
[Any ambiguities that need clarification before finalizing]
Wait for user approval before writing the file.
tests/specs/[feature-key]-[slug].feature
auth-login-flow, cart-checkout)Write(file_path="[project_root]/tests/specs/[feature-key]-[slug].feature", content="[gherkin content]")
Create a tracking memory for this spec:
mcp__plugin_swe_serena__write_memory("spec/SPEC_[KEY]_[SLUG]", "<content>")
Memory content:
# SPEC_[KEY]_[SLUG] - [Feature Name]: [Spec Title]
## Spec File
| Property | Value |
|----------|-------|
| **File** | `tests/specs/[feature-key]-[slug].feature` |
| **Feature Key** | [KEY] |
| **Created** | [date] |
| **Status** | draft |
## Coverage Map
| # | Type | Line | Implemented | Tested |
|---|------|------|-------------|--------|
| 1 | Given | [step text] | No | No |
| 2 | When | [step text] | No | No |
| 3 | Then | [step text] | No | No |
## Linked Artifacts
| Type | Path |
|------|------|
| Spec file | `tests/specs/[filename].feature` |
| Test file | _(not yet created)_ |
| Feature memory | `feature/FEATURE_[KEY]` |
If the feature memory has a Testing section, append the new spec reference:
mcp__plugin_swe_serena__edit_memory(
"feature/FEATURE_[KEY]",
"## Testing",
"## Testing\n\n| Suite | File | Focus |\n|...\n| Gherkin Spec | tests/specs/[filename].feature | [description] |",
"literal"
)
If the feature requires multiple spec files (large feature with distinct areas):
.feature file per logical areaSPEC_* memory per file@feature-key)## Skill Return
- **Skill**: swe-gherkin-spec
- **Status**: [success|needs_clarification]
- **Feature Key**: [KEY]
- **Spec Files Created**: [list of .feature file paths]
- **SPEC Memories Created**: [list of SPEC_* memory names]
- **Coverage**: [N scenarios, M steps total]
- **Next Step Hint**: WF_ARCH_REVIEW (plan implementation) or /swe-gherkin-dev (start TDD)
> **Skill /swe-gherkin-spec complete** - [N] spec(s) written to tests/specs/
development
TDD from Gherkin specs. Takes a .feature file or SPEC_* memory, builds a coverage map, implements both functionality and tests to achieve 100% compliance. Builds missing functionality, creates real tests (no fixme), follows all dev standards.
testing
Verify implementation against requirements and standards
development
Code exploration and research without making changes
development
Test-driven debugging for failing tests or bugs