Generating Test Cases from OpenSpec, Spec Kit, and Kiro

If your project describes behavior with OpenSpec, GitHub Spec Kit, or Kiro specifications, SpeQA can turn selected scenarios into test cases. Choose one .tc.md per scenario or one per requirement, then refine the generated cases in the SpeQA editor.

Generation is deterministic: it follows fixed rules, works offline, and does not use AI. The same spec, selection, mode, and defaults produce the same test cases.

Which Files Are Supported

SpeQA recognizes a file as an OpenSpec specification when it is named spec.md and lives in a capability folder under a specs folder inside an openspec folder. Both stable specs and change deltas work:

  • openspec/specs/auth/login/spec.md
  • openspec/changes/add-sso/specs/auth/login/spec.md

Other Markdown files, such as docs/spec.md, openspec/specs/spec.md (without a capability folder), or openspec/specs/auth/README.md, are not affected and show no generation controls.

GitHub Spec Kit feature specs and Kiro requirements and bugfix files are supported too. A Spec Kit file must be specs/<feature>/spec.md with a .specify folder next to specs; both can be at the project root or in a subfolder. A Kiro file must be .kiro/specs/<feature>/requirements.md or .kiro/specs/<feature>/bugfix.md; the .kiro folder can be at the project root or in a subfolder. See GitHub Spec Kit, Kiro, and Kiro Bugfix Specs below for how they are recognized and mapped.

Starting the Generation

There are two entry points. Both open the same dialog, only the initial selection differs.

  • Gutter icon - open a specification and click the SpeQA icon next to supported content:
    • next to ## Requirements, ## ADDED Requirements, or ## MODIFIED Requirements - all scenarios in that section are selected. These headings are matched without regard to case; empty sections and REMOVED / RENAMED sections have no icon;
    • next to #### Scenario: in OpenSpec - only that scenario is selected;
    • next to ## User Scenarios & Testing, ### User Story N, or a numbered acceptance scenario in GitHub Spec Kit - all scenarios of that section or story, or only that scenario, are selected;
    • next to ### Requirement: in OpenSpec, or ### Requirement N: in Kiro - all scenarios of that requirement are selected (requirements without scenarios have no icon);
    • next to a numbered acceptance criterion in Kiro - only that criterion is selected;
    • next to ## Bug Analysis, a behavior group heading, or a numbered statement in a Kiro bugfix file - all statements of the section or group, or only that statement, are selected.
  • Context menu - in the Project View, right-click a recognized spec.md, requirements.md, or bugfix.md, or its capability or feature folder when that folder directly contains the file, open New, and choose SpeQA Test Cases from Spec…. The dialog selects all scenarios. Inside the editor, right-click the open specification and choose Generate SpeQA Test Cases from Spec…. Preselection follows the most specific caret context: the current scenario, its requirement (when it has scenarios), or the enclosing eligible section (when it has scenarios). If the caret is inside a requirement without scenarios, preselection falls back to the enclosing eligible section or, if that section has no scenarios, to all scenarios. If the caret is elsewhere, all scenarios are selected.

The action has no default keyboard shortcut. You can assign one in Settings > Keymap.

The Generation Dialog

The Generate SpeQA Test Cases dialog shows:

  • One case per - a drop-down next to Select all and Clear above the tree. Choose Scenario for one test case per scenario or Requirement for one test case per requirement. The choice is remembered for the project and starts with Scenario.
  • Requirements and scenarios - a tree with a checkbox for every requirement and scenario. Each scenario shows how many steps it will produce. A scenario without any WHEN or THEN clause is marked No WHEN or THEN clauses; you can still generate it, and it gets one empty step. When the dialog opens, every requirement with a preselected scenario is expanded and the others stay collapsed. The first preselected scenario is selected and scrolled into view, so you can toggle it with Space right away.
  • Select all and Clear buttons for quick selection.
  • Destination folder - where the files are saved. The default is test-cases/<capability>/ for OpenSpec, or test-cases/<feature>/ for Spec Kit and Kiro. For example, openspec/specs/auth/login/spec.md uses test-cases/auth/login/, while specs/001-user-auth/spec.md and .kiro/specs/account-access/requirements.md use their feature folder under test-cases/. Use the browse button to pick another folder. The folder must be inside the project; otherwise the dialog shows an error and Create stays disabled. A missing folder is created automatically.
  • exists, will be overwritten - appears next to an existing scenario file in per-scenario mode, or on a requirement row with a selected scenario in per-requirement mode.
  • A summary next to the Create and Cancel buttons, for example 3 will be created, 1 overwritten. It counts output files, not scenarios.

Scenarios under ## REMOVED Requirements and ## RENAMED Requirements in change deltas are not listed.

Click Create to generate the files. The button is disabled while nothing is selected.

How a Scenario Becomes a Test Case

In One test case per scenario mode, each selected scenario creates a separate file and is mapped field by field:

In the specIn the test case
Scenario nameTitle and the file name
Requirement name and statementDescription
Path to the specA Links entry that opens the spec
GIVEN and the AND clauses after itPreconditions, one bullet per clause
WHENStarts a new step; its text is the step Action
AND after WHEN, before THENAnother line of the same action
THENThe Expected result of the current step
AND / BUT after THENMore lines of the expected result

A few more rules:

  • Several WHEN / THEN pairs in one scenario produce several steps.
  • A THEN without a preceding WHEN creates a step whose action is the scenario name.
  • Bold keyword markers such as **WHEN** are removed; any other inline Markdown in the clause text is kept.
  • Priority, Status, and Environment come from the SpeQA defaults in Settings > Tools > SpeQA (Normal and Draft unless you changed them). If no default environments are set, the file has no environment field.
  • Tags contain the last segment of the capability path for OpenSpec, or the feature folder name for Spec Kit and Kiro.
  • Each new case gets the next free ID.

The spec link is titled with the spec path from the project root and points to the spec with a path relative to the test case file. Click it in the Links section of the preview to open the spec in the IDE, or Cmd+click (Ctrl+click on Windows and Linux) it in the Markdown editor. When you create a test run with Links imported, the link is adjusted so it still opens the spec from the run file.

One Test Case per Requirement

In One test case per requirement mode, one file is created for each requirement with at least one selected scenario:

  • The case title and filename come from the requirement name. The description contains the requirement statement, if present.
  • Selected scenarios contribute steps in document order. A scenario with several WHEN clauses contributes several consecutive steps.
  • The first step of each scenario has a step-level Links entry titled with the scenario name. Use that link to open the corresponding scenario in the source spec; other steps of that scenario have no boundary link.
  • If all selected scenarios have the same ordered GIVEN clauses, they appear once in Preconditions. If their GIVEN lists differ, each scenario's clauses move to the beginning of that scenario's first step action as Given … and And … lines, followed by the original action. Scenarios without GIVEN clauses keep their action unchanged. If all scenarios have no GIVEN clauses, no Preconditions block is written.
  • A requirement with one selected scenario still creates one case titled with the requirement name.

The generated case does not add scenario headings or use the word Scenario as scenario content. The required Scenario: format marker remains unchanged.

Example

This scenario in openspec/specs/auth/login/spec.md:

### Requirement: User login

The system SHALL let registered users sign in with an email and a password.

#### Scenario: Successful login

- **GIVEN** a registered user
- **AND** the user is signed out
- **WHEN** the user submits a valid email and password
- **THEN** the dashboard opens
- **AND** the user's name appears in the header

produces test-cases/auth/login/successful-login.tc.md:

---
id: 12
title: "Successful login"
priority: normal
status: draft
tags:
  - "login"
---

Requirement: User login

The system SHALL let registered users sign in with an email and a password.

Links:

[openspec/specs/auth/login/spec.md](../../../openspec/specs/auth/login/spec.md)

Preconditions:

- a registered user
- the user is signed out

Scenario:

1. the user submits a valid email and password
   > the dashboard opens
   > the user's name appears in the header

Example: One Test Case per Requirement

Suppose the User login requirement has two selected scenarios with different GIVEN clauses. SpeQA creates test-cases/auth/login/user-login.tc.md:

---
id: 12
title: "User login"
priority: normal
status: draft
tags:
  - "login"
---

The system SHALL let registered users sign in with an email and a password.

Links:

[openspec/specs/auth/login/spec.md](../../../openspec/specs/auth/login/spec.md)

Scenario:

1. Given a registered user
   And the user is signed out
   The user submits a valid email and password
   > The dashboard opens
   > The user's name appears in the header

   Links: [Successful login](../../../openspec/specs/auth/login/spec.md)

2. Given a registered user
   The user submits a wrong password
   > An error is shown

   Links: [Wrong password](../../../openspec/specs/auth/login/spec.md)

If the selected scenarios had identical GIVEN lists instead, those clauses would appear once in Preconditions, not in the step actions.

File Names

In per-scenario mode, the file name is the scenario name in lowercase, with every run of characters other than letters and digits replaced by -, plus .tc.md. "Successful login" becomes successful-login.tc.md. In per-requirement mode, the requirement name determines the file name; "User login" becomes user-login.tc.md. If selected scenarios or requirements produce the same name in one run, the later files get -2, -3, and so on.

Overwriting Existing Cases

A file is treated as already generated when the output filename exists in the destination folder. If the selection includes such files, SpeQA lists them and asks what to do:

  • Overwrite - replace the existing files with freshly generated ones. Each overwritten file keeps its ID, so existing test runs still point to it.
  • Skip existing - leave the existing files untouched and create only the new ones.
  • Cancel - write nothing.

Overwriting replaces any manual edits you made in those files. In per-requirement mode, it also replaces the entire case with only the scenarios selected in the current dialog; scenarios that were not selected are removed from that generated case. Commit your changes to Git first if you want to compare or restore them.

After Generation

  • The first created test case opens in the editor.
  • A notification reports the result, for example Created 3 test cases in test-cases/auth/login.
  • All files are written as one command, so a single Undo reverts the whole batch.

Generation waits until the IDE finishes indexing, because IDs are assigned from the project index.

Limitations

  • Generation is one-way. Changing the spec later does not update the test cases; generate again and choose Overwrite or Skip existing.
  • One spec at a time. A Project View folder selection resolves only its direct spec.md, requirements.md, or bugfix.md; folders that contain specifications only in descendants are not searched. A Kiro feature folder that contains both requirements.md and bugfix.md opens requirements.md; right-click bugfix.md itself to generate from it.

GitHub Spec Kit

SpeQA recognizes a Spec Kit feature spec when it is named spec.md, lives directly in a feature folder under specs, and the folder that contains specs also has a .specify folder. That folder can be the project root or a subfolder: for example, specs/001-user-auth/spec.md is recognized next to .specify/, and services/api/specs/001-user-auth/spec.md is recognized next to services/api/.specify/ in a monorepo. Without a .specify folder next to specs, the same path is treated as regular Markdown.

The same gutter icons, context menu actions, and dialog are available. The spec is mapped as follows:

In the specIn SpeQA
## User Scenarios & TestingSection; its gutter icon selects all acceptance scenarios
### User Story N - Title (Priority: Pn)Requirement named after the title, or User Story N if there is no title
Story text before Acceptance ScenariosRequirement statement (with paragraph breaks preserved), used in the Description
Each numbered item under **Acceptance Scenarios**: or #### Acceptance ScenariosScenario named <story title> <item number>, for example Sign in with email 2
**Given**, **When**, **Then**, **And**, **But** in the itemClauses, mapped by the same rules as OpenSpec scenarios

A few more rules:

  • Priority: P1 produces major, P2 produces normal, and P3 or higher produces low. Without a valid priority label, the SpeQA default priority is used.
  • The default destination is test-cases/<feature folder>/, for example test-cases/001-user-auth/, and the feature folder name is added as a tag.
  • Level-4 subheadings (such as #### Independent Test or #### Notes) keep the current user story active; #### Acceptance Scenarios (plain or bold) starts scenario collection, while other level-4 or deeper subheadings pause scenario collection. Once Acceptance Scenarios starts, trailing prose and later subheadings do not enter the story statement.
  • A blank line or code block ends the current acceptance scenario. Indented notes (including nested numbered items) after a blank line are ignored through the next blank line without ending scenario collection; an unindented paragraph ends scenario collection. Nested numbered sublists indented to or past the top-level item's content column stay inside the active scenario, while smaller indents start sibling scenarios.
  • User stories without acceptance scenarios, Edge Cases, and Functional Requirements (FR-xxx) do not produce test cases.
  • Text inside code blocks is ignored.

For example, this story:

### User Story 1 - Sign in with email (Priority: P1)

**Acceptance Scenarios**:

1. **Given** a registered user, **When** they submit valid credentials, **Then** the dashboard opens

produces test-cases/001-user-auth/sign-in-with-email-1.tc.md with priority major, the tag 001-user-auth, the precondition a registered user, and one step with the expected result the dashboard opens.

Kiro

SpeQA recognizes a Kiro requirements file at .kiro/specs/<feature>/requirements.md. The .kiro folder can be at the project root or in a subfolder, for example services/api/.kiro/specs/<feature>/requirements.md in a monorepo. A Project View folder resolves only its direct requirements.md. Bugfix files are described in Kiro Bugfix Specs; design.md and tasks.md are not parsed for generation.

Only requirements under ## Requirements are considered. Each numbered requirement with numbered items under an Acceptance Criteria heading or bold label becomes a requirement with selectable scenarios:

In the specIn SpeQA
### Requirement N: TitleRequirement named after the title; Requirements N is also accepted
**User Story:** As a ..., I want to ...Requirement statement; if the heading has no title, the I want ... phrase supplies a capitalized title after a leading to or to be able to is removed
Each numbered acceptance criterionScenario named <requirement title> <item number>
WHILE or WHERE conditionGIVEN precondition
WHEN or IF conditionWHEN action
Response after THEN or SHALLTHEN expected result

A few more rules:

  • Both #### Acceptance Criteria (plain or bold, such as #### **Acceptance Criteria**) and bold **Acceptance Criteria**: labels start criteria collection.
  • EARS keywords are recognized only in uppercase; bold keywords such as **WHEN**, **THE**, and **SHALL** are accepted. Lowercase words such as when or shall stay plain text.
  • If THEN is absent before SHALL, SpeQA uses the last THE before SHALL only when it is not immediately after an EARS condition keyword and no comma follows it before SHALL; otherwise, it uses the last comma. If neither separator exists, the condition is all text before SHALL. If there is no SHALL, the whole criterion becomes a THEN clause.
  • A blank line, code block, or User Story label ends the current criterion. An indented note (including nested numbered items) after a blank line is ignored through the next blank line, and later top-level numbered criteria are still parsed. An unindented non-numbered paragraph ends criteria collection. Nonblank continuation lines and nested numbered sublists (indented to or past the top-level item's content column) before a blank line remain part of the current criterion, while smaller indents start sibling criteria.
  • Requirements without numbered acceptance criteria are skipped. Text inside Markdown code blocks is ignored.
  • Priority comes from the SpeQA default settings. The Kiro format does not override it.
  • The default destination is test-cases/<feature>/, and the feature folder name is added as a tag.

For example, this criterion in .kiro/specs/account-access/requirements.md:

## Requirements

### Requirement 1: Account lockout
**User Story:** As an administrator, I want to lock an account, so that unauthorized access is prevented.

#### Acceptance Criteria
1. WHILE the account is locked, WHEN the user signs in, THEN the system SHALL deny access

produces a scenario named Account lockout 1, using the configured priority, with the account-access tag under test-cases/account-access/.

Kiro Bugfix Specs

SpeQA recognizes a Kiro bugfix file at .kiro/specs/<feature>/bugfix.md. As with requirements files, the .kiro folder can be in a subfolder. Generated cases check the fix and guard against regressions:

In the specIn SpeQA
## Bug AnalysisSection; its gutter icon selects all expected and unchanged statements
### Expected Behavior (Correct)Requirement named <Feature title>: expected behavior
### Unchanged Behavior (Regression Prevention)Requirement named <Feature title>: unchanged behavior
### Current Behavior (Defect)Ignored: the expected statements already check the defect
Each numbered statement, such as 2.1Scenario named <requirement name> <number>
## IntroductionRequirement statement, used in the Description

A few more rules:

  • The feature title is the feature folder name with hyphens and underscores replaced by spaces, for example Grid view bugs for grid-view-bugs.
  • Statements are converted with the same EARS rules as Kiro acceptance criteria, including bold uppercase keywords such as **THE**. A leading CONTINUE TO (plain or bold) after SHALL is removed from the expected result.
  • Every case gets the feature folder name as a tag. Cases from unchanged behavior also get the regression tag.
  • A statement continues on the following lines until a blank line, a heading, or the next numbered statement. Text inside code blocks and other sections, such as ## Bug Condition (Formal), is ignored.
  • Priority comes from the SpeQA default settings, and the default destination is test-cases/<feature>/.

For example, this group in .kiro/specs/grid-view-bugs/bugfix.md:

### Unchanged Behavior (Regression Prevention)

3.1 WHEN a user clicks install in list view THEN the system SHALL CONTINUE TO show the install options

produces test-cases/grid-view-bugs/grid-view-bugs-unchanged-behavior-3-1.tc.md with the tags grid-view-bugs and regression, one step with the action a user clicks install in list view, and the expected result show the install options.

Generation or the Test Case Writer Skill?

Spec generationTest Case Writer skill
InputOpenSpec and Spec Kit spec.md scenarios, Kiro requirements.md criteria, or Kiro bugfix.md statementsSpecs, tickets, user stories, PR descriptions
How it worksFixed mapping rules, offlineAI writes and expands the cases
ResultPredictable cases, one per scenario or requirementRicher cases, may add negative and edge scenarios

You can combine both: generate test cases from the spec, then ask Codex or Claude Code to refine them.

What's Next?