gherkin-generator-skill
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSkill: Gherkin Generator (BDD)
技能:Gherkin生成器(BDD)
Converts functional requirements into valid, high-quality Gherkin scenarios through an
iterative cycle with two specialised agents.
通过双专业Agent的迭代循环,将功能需求转换为合规、高质量的Gherkin场景。
System Architecture
系统架构
Functional requirements
│
▼
┌─────────────────────┐
│ gherkin-generator │ ← Agent 1: generates/modifies the .feature file
│ -agent │
└────────┬────────────┘
│ Gherkin draft
▼
┌─────────────────────┐
│ gherkin-reviewer │ ← Agent 2: validates and proposes improvements
│ -agent │
└────────┬────────────┘
│
Approved?
NO ──────────────────► returns to Agent 1 with feedback
YES ─────────────────► delivers the final .feature fileFunctional requirements
│
▼
┌─────────────────────┐
│ gherkin-generator │ ← Agent 1: 生成/修改.feature文件
│ -agent │
└────────┬────────────┘
│ Gherkin draft
▼
┌─────────────────────┐
│ gherkin-reviewer │ ← Agent 2: 验证并提出改进建议
│ -agent │
└────────┬────────────┘
│
Approved?
NO ──────────────────► 携带反馈返回给Agent 1
YES ─────────────────► 交付最终.feature文件Step-by-step workflow
分步工作流程
Step 1 — Prepare the requirements
步骤1 — 准备需求
Before invoking the agents, extract from the user's input:
- Module / feature name (for the Feature name)
- List of functional requirements (numbered or in prose)
- Business context (actors, systems involved)
- Example data if available
If anything is ambiguous, ask the user before starting.
调用Agent前,从用户输入中提取以下信息:
- 模块/功能名称(用于Feature名称)
- 功能需求列表(编号或散文形式)
- 业务上下文(涉及的角色、系统)
- 示例数据(如果有)
如果存在不明确的内容,在开始前先询问用户。
Step 2 — Invoke the Generator Agent
步骤2 — 调用生成Agent
Read the full instructions in .
agents/generator-agent.mdCall the agent with:
INPUT:
requirements: <list of requirements>
context: <business context>
previous_feedback: <empty on first iteration>
previous_gherkin: <empty on first iteration>
iteration: <current iteration number>The agent returns a Gherkin block in format.
.feature阅读中的完整说明。
agents/generator-agent.md调用Agent时传入:
INPUT:
requirements: <需求列表>
context: <业务上下文>
previous_feedback: <首次迭代时为空>
previous_gherkin: <首次迭代时为空>
iteration: <当前迭代次数>Agent会返回.feature格式的Gherkin代码块。
Step 3 — Invoke the Reviewer Agent
步骤3 — 调用评审Agent
Read the full instructions in .
agents/reviewer-agent.mdCall the agent with:
INPUT:
gherkin: <output from the generator agent>
original_requirements: <user's original requirements>
iteration: <current iteration number>The agent returns an object with:
approved: true/falsescore: 0-100issues: [list of problems]suggestions: [list of concrete improvements]annotated_gherkin: <the gherkin with inline comments>
阅读中的完整说明。
agents/reviewer-agent.md调用Agent时传入:
INPUT:
gherkin: <生成Agent的输出内容>
original_requirements: <用户的原始需求>
iteration: <当前迭代次数>Agent会返回一个包含以下字段的对象:
approved: true/falsescore: 0-100issues: [问题列表]suggestions: [具体改进建议列表]annotated_gherkin: <带有内联注释的Gherkin内容>
Step 4 — Improvement loop
步骤4 — 改进循环
iteration = 1
maximum = 5 ← prevents infinite loops
WHILE iteration <= maximum:
gherkin = generator_agent(requirements, feedback, previous_gherkin)
review = reviewer_agent(gherkin, requirements)
IF review.approved == true OR review.score >= 85:
BREAK
feedback = review.suggestions + review.issues
previous_gherkin = gherkin
iteration += 1
IF iteration > maximum:
deliver the best gherkin obtained with a warning noteiteration = 1
maximum = 5 ← 防止无限循环
WHILE iteration <= maximum:
gherkin = generator_agent(requirements, feedback, previous_gherkin)
review = reviewer_agent(gherkin, requirements)
IF review.approved == true OR review.score >= 85:
BREAK
feedback = review.suggestions + review.issues
previous_gherkin = gherkin
iteration += 1
IF iteration > maximum:
交付已得到的最优Gherkin内容,并附带警告说明Step 5 — Delivery
步骤5 — 交付
Present to the user:
- The final file with syntax highlighting
.feature - The reviewer's final score
- A summary of iterations performed
- (Optional) Save the file if the user requests it
向用户展示以下内容:
- 带语法高亮的最终.feature文件
- 评审Agent的最终评分
- 执行的迭代次数总结 4.(可选)如果用户要求,保存该文件
Approval criteria (summary)
评审通过标准(摘要)
The Reviewer Agent approves when all of the following are met:
| Criterion | Minimum requirement |
|---|---|
| Requirements coverage | 100% of functional requirements covered |
| Gherkin syntax | No errors (Feature, Scenario, Given/When/Then) |
| Scenario independence | No order dependency between scenarios |
| Step clarity | No technical ambiguities |
| Example data | Scenario Outline + Examples tables when variants exist |
| Language | Consistent throughout the file |
当所有以下条件满足时,评审Agent会通过:
| 评审标准 | 最低要求 |
|---|---|
| 需求覆盖率 | 100%覆盖所有功能需求 |
| Gherkin语法 | 无语法错误(Feature、Scenario、Given/When/Then) |
| 场景独立性 | 场景之间无顺序依赖 |
| 步骤清晰度 | 无技术歧义 |
| 示例数据 | 存在变体时使用Scenario Outline + Examples表格 |
| 语言一致性 | 文件内语言保持一致 |
Implementation notes
实现说明
- Maximum iterations: 5 (configurable by the user)
- Language: use the same language as the input requirements
- Granularity: one file per module/feature
.feature - Tags: add ,
@smoke,@regression,@happy-pathas appropriate@edge-case - Background: use only when ≥3 scenarios share the same Given steps
For implementation details of each agent, read:
agents/generator-agent.mdagents/reviewer-agent.mdreferences/gherkin-best-practices.md
- 最大迭代次数:5次(用户可配置)
- 语言:使用与输入需求相同的语言
- 粒度:每个模块/功能对应一个.feature文件
- 标签:根据情况添加、
@smoke、@regression、@happy-path@edge-case - Background:仅当≥3个场景共享相同的Given步骤时使用
关于每个Agent的实现细节,请阅读:
agents/generator-agent.mdagents/reviewer-agent.mdreferences/gherkin-best-practices.md