Requirements to Feature Files
Overview
Turn a raw requirement into a Gherkin feature tree that mirrors file system structure. Emphasize declarative business intent, rule-driven logic, and Behave-compatible syntax.
Workflow
- •
Locate the requirement in the feature tree
- •Decide whether this is a top-level feature or a sub-requirement of an existing feature.
- •Default root folder is
features/unless the user specifies another location.
- •
Define the output path using hierarchy parity
- •Each
.featurefile is treated as a folder. - •If a feature needs child requirements, create a folder named after the parent
.featurefile stem. - •Place child
.featurefiles inside that folder. - •For auth/permission scenarios, place them in a sibling feature file inside the parent folder. Example:
features/user_management.feature->features/user_management/user_management_auth.feature.
- •Each
- •
Extract business rules
- •Convert constraints, permissions, and edge conditions into
Ruleblocks. - •Keep each rule focused and testable.
- •Convert constraints, permissions, and edge conditions into
- •
Write Gherkin scenarios
- •Use
Feature, optionalBackground, andScenarioorExample. - •Keep steps declarative and domain-level; avoid UI details.
- •Use
Backgroundonly for shared context at the current feature level.
- •Use
- •
Provide a dry-run command
- •Always include a
behave <path> --dry-runcommand at the end.
- •Always include a
Guardrails
- •Do not describe UI interactions (clicks, buttons, pages, fields).
- •Prefer short, domain-specific step phrasing.
- •Use
Rulewhen logic is more than a simple happy path. - •Ensure the output is valid Gherkin for Behave.
- •Auth/permission-related scenarios must be written in a dedicated
*_auth.featurefile inside the parent feature folder (same level as the parent.feature).
Output Contract
- •State the save path before the Gherkin content.
- •Output only one feature file per request unless the user asks for multiple.
- •Include the dry-run command after the Gherkin content.
References
- •Example inputs and outputs: references/examples.md