gherkin-generator-skill

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Skill: 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 file

Functional 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.md
.
Call 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
.feature
format.
阅读
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.md
.
Call 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/false
  • score: 0-100
  • issues: [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/false
  • score: 0-100
  • issues: [问题列表]
  • 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 note
iteration = 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:
  1. The final
    .feature
    file with syntax highlighting
  2. The reviewer's final score
  3. A summary of iterations performed
  4. (Optional) Save the file if the user requests it

向用户展示以下内容:
  1. 带语法高亮的最终.feature文件
  2. 评审Agent的最终评分
  3. 执行的迭代次数总结 4.(可选)如果用户要求,保存该文件

Approval criteria (summary)

评审通过标准(摘要)

The Reviewer Agent approves when all of the following are met:
CriterionMinimum requirement
Requirements coverage100% of functional requirements covered
Gherkin syntaxNo errors (Feature, Scenario, Given/When/Then)
Scenario independenceNo order dependency between scenarios
Step clarityNo technical ambiguities
Example dataScenario Outline + Examples tables when variants exist
LanguageConsistent 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
    .feature
    file per module/feature
  • Tags: add
    @smoke
    ,
    @regression
    ,
    @happy-path
    ,
    @edge-case
    as appropriate
  • Background: use only when ≥3 scenarios share the same Given steps
For implementation details of each agent, read:
  • agents/generator-agent.md
  • agents/reviewer-agent.md
  • references/gherkin-best-practices.md
  • 最大迭代次数:5次(用户可配置)
  • 语言:使用与输入需求相同的语言
  • 粒度:每个模块/功能对应一个.feature文件
  • 标签:根据情况添加
    @smoke
    @regression
    @happy-path
    @edge-case
  • Background:仅当≥3个场景共享相同的Given步骤时使用
关于每个Agent的实现细节,请阅读:
  • agents/generator-agent.md
  • agents/reviewer-agent.md
  • references/gherkin-best-practices.md