需求导出与格式转换Skill export

这个技能用于将收集的软件需求自动导出到多种规范格式,如规范格式、EARS、Gherkin、Markdown、YAML、JSON等。支持按域、格式和过滤器(如优先级、类别、置信度)进行导出,便于需求管理、文档生成和下游开发流程。关键词:需求导出、规范格式、EARS、Gherkin、需求管理、软件开发。

需求分析 0 次安装 0 次浏览 更新于 3/11/2026

name: export description: 将收集的需求导出到规范格式。支持规范、EARS、Gherkin等格式。 argument-hint: [–domain <域名>] [–to <格式>] [–filter <过滤选项>] allowed-tools: Read, Glob, Grep, Write, Skill

导出命令

将收集的需求导出到规范格式,以便下游处理。

用法

/requirements-elicitation:export
/requirements-elicitation:export --domain "authentication" --to canonical
/requirements-elicitation:export --to ears --filter "priority:must"
/requirements-elicitation:export --to gherkin --domain "checkout"

参数

参数 必需 描述
–domain 要导出的域(默认:当前/全部)
–to 导出格式:canonicalearsgherkinmarkdownyamljson(默认:canonical
–filter 过滤需求:priority:mustcategory:functionalconfidence:high

支持的格式

规范格式

转换为规范规范格式:

# 输出:.specs/{feature}/spec.md
---
id: SPEC-{feature}
title: "{功能名称}"
version: 1.0.0
status: draft
---

# {功能名称}

## 概述
{从合成摘要生成}

## 需求

### 功能需求

#### REQ-F-001: {标题}
**优先级:** MUST
**来源:** 与产品经理的访谈

系统应 {需求文本}。

**接受标准:**
- 给定 {上下文},当 {动作},然后 {结果}

EARS(简单需求语法方法)

转换为EARS模式:

# 输出:.requirements/{domain}/exports/EARS-{timestamp}.md

## 普遍需求
- 系统应 {能力}。

## 事件驱动需求
- 当 {触发器},系统应 {响应}。

## 状态驱动需求
- 当 {状态},系统应 {行为}。

## 不希望行为需求
- 如果 {条件},那么系统应 {响应}。

## 可选功能需求
- 当 {功能启用},系统应 {行为}。

Gherkin(BDD)

转换为Gherkin特征文件:

# 输出:.requirements/{domain}/exports/{feature}.feature

Feature: {功能名称}
  作为 {角色}
  我想要 {能力}
  以便 {利益}

  Scenario: {从接受标准来的场景}
    给定 {前置条件}
    当 {动作}
    然后 {预期结果}

Markdown

人类可读的文档格式:

# {域} 需求

## 执行摘要
{生成的概述}

## 功能需求
| ID | 需求 | 优先级 | 来源 |
|----|-------------|----------|--------|
| REQ-F-001 | {文本} | Must | 访谈 |

## 非功能需求
...

YAML/JSON

机器可读的格式,用于集成:

# 输出:.requirements/{domain}/exports/requirements.yaml
domain: "{域}"
exported: "{ISO-8601}"
format_version: "1.0"

requirements:
  - id: REQ-F-001
    text: "{需求}"
    category: functional
    priority: must
    source: interview
    confidence: high

工作流程

步骤1:加载合成需求

.requirements/{domain}/synthesis/文件夹读取。

步骤2:应用过滤器

如果指定了–filter:

  • 按优先级过滤(must、should、could)
  • 按类别过滤(functional、non_functional、constraint)
  • 按置信度过滤(high、medium、low)
  • 按来源过滤(interview、document、simulation、research)

步骤3:转换格式

应用特定格式的转换:

transformations:
  canonical:
    - 将优先级映射到MoSCoW
    - 从需求生成接受标准
    - 创建spec.md结构

  ears:
    - 按EARS模式分类需求
    - 用EARS语法重写
    - 按模式类型分组

  gherkin:
    - 从接受标准提取场景
    - 生成Given/When/Then结构
    - 创建特征文件

步骤4:质量检查

验证导出质量:

  • 包含所有需求
  • 格式合规
  • 保留可追溯性

步骤5:保存输出

保存到适当位置,具有清晰的文件名。

示例

导出到规范格式

/requirements-elicitation:export --domain "authentication" --to canonical

输出:

导出:authentication
格式:canonical

加载合成:SYN-20251225-160000.yaml
找到需求:32

转换为规范格式...
  功能需求:20
  非功能需求:8
  约束:3
  假设:1

质量检查:
  ✓ 所有需求已映射
  ✓ 优先级转换为MoSCoW
  ✓ 为18/20功能需求生成了接受标准
  ⚠ 2个需求需要手动接受标准

保存到:.specs/authentication/spec.md

下一步:根据需要审查和完善规范

导出到EARS格式

/requirements-elicitation:export --domain "checkout" --to ears

输出:

导出:checkout
格式:EARS

加载合成:SYN-20251225-163000.yaml
找到需求:28

按EARS模式分类...
  普遍:8
  事件驱动:12
  状态驱动:4
  不希望行为:3
  可选功能:1

保存到:.requirements/checkout/exports/EARS-20251225-170000.md

示例转换:
  原始:"Users must be able to add items to cart"
  EARS:"系统应允许用户将商品添加到购物车。"

  原始:"Show error when payment fails"
  EARS:"如果支付处理失败,那么系统应向用户显示错误消息。"

导出到Gherkin

/requirements-elicitation:export --domain "user-registration" --to gherkin

输出:

导出:user-registration
格式:Gherkin

加载合成:SYN-20251225-164500.yaml
找到需求:15

生成特征文件...
  user_registration.feature:8个场景
  email_verification.feature:4个场景
  profile_setup.feature:3个场景

保存到:.requirements/user-registration/exports/features/

示例场景:
  Feature: User Registration
    Scenario: Successful registration with valid email
      Given I am on the registration page
      When I enter a valid email "user@example.com"
      And I enter a password meeting complexity requirements
      And I click the Register button
      Then I should see a verification email sent message
      And a verification email should be sent to "user@example.com"

过滤导出

/requirements-elicitation:export --domain "inventory" --to yaml --filter "priority:must,confidence:high"

输出:

导出:inventory
格式:YAML
过滤器:priority=must, confidence=high

加载合成:SYN-20251225-165000.yaml
总需求:42
过滤后:18

保存到:.requirements/inventory/exports/requirements-must-high.yaml

过滤摘要:
  功能:12
  非功能:4
  约束:2

输出位置

output_locations:
  canonical: ".specs/{domain}/spec.md"
  ears: ".requirements/{domain}/exports/EARS-{timestamp}.md"
  gherkin: ".requirements/{domain}/exports/features/*.feature"
  markdown: ".requirements/{domain}/exports/requirements-{timestamp}.md"
  yaml: ".requirements/{domain}/exports/requirements-{timestamp}.yaml"
  json: ".requirements/{domain}/exports/requirements-{timestamp}.json"

质量门

在导出完成前,验证:

quality_gates:
  traceability:
    check: "所有需求都有来源归属"
    action_if_fail: "警告用户,继续执行"

  completeness:
    check: "合成中没有关键缺口"
    action_if_fail: "警告用户,建议先填补缺口"

  conflicts:
    check: "没有未解决的冲突"
    action_if_fail: "警告用户,导出时带有冲突标记"

  acceptance_criteria:
    check: "功能需求有接受标准"
    action_if_fail: "生成基本标准,标记供审查"

错误处理

error_handling:
  no_synthesis:
    message: "未找到域的合成需求"
    action: "首先运行 /discover 以收集需求"

  empty_after_filter:
    message: "没有需求匹配过滤器条件"
    action: "建议更广泛的过滤器或显示可用选项"

  format_unsupported:
    message: "导出格式未识别"
    action: "列出支持的格式"