# How to Generate Test Scenarios from User Stories Using pm-skills

> Learn to generate test scenarios from user stories with pm-skills. This framework transforms user stories into structured QA tests, including pre-conditions and coverage analysis. Get markdown documentation easily.

- Repository: [Pawel Huryn/pm-skills](https://github.com/phuryn/pm-skills)
- Tags: how-to-guide
- Published: 2026-06-11

---

**The pm-skills framework converts user stories into structured QA test scenarios through a deterministic six-step pipeline defined in the `test-scenarios` skill, producing markdown documentation with pre-conditions, step matrices, and coverage analysis.**

The **pm-skills** repository provides a chat-oriented CLI for product management workflows. When you need to **generate test scenarios from user stories**, the built-in **Test-Scenarios** skill transforms raw input into actionable QA documents without requiring external dependencies or hidden code logic.

## The Test-Scenarios Skill Architecture

The **Test-Scenarios** skill is located at **[`pm-execution/skills/test-scenarios/SKILL.md`](https://github.com/phuryn/pm-skills/blob/main/pm-execution/skills/test-scenarios/SKILL.md)** and exposed through the **`/test-scenarios`** command defined in **[`pm-execution/commands/test-scenarios.md`](https://github.com/phuryn/pm-skills/blob/main/pm-execution/commands/test-scenarios.md)**. This architecture separates the declarative generation logic from the user interface, allowing the runtime engine to parse markdown metadata and render outputs dynamically.

The skill accepts three key arguments: **`$PRODUCT`** (optional context), **`$USER_STORY`** (the core requirement text), and **`$CONTEXT`** (additional constraints). When invoked, the command wrapper formats the skill’s response into a structured markdown table ready for test engineers.

## The Six-Step Generation Pipeline

The skill processes input through a deterministic pipeline defined in the **Scenario Template** (see lines 27-50 of [`SKILL.md`](https://github.com/phuryn/pm-skills/blob/main/SKILL.md)):

### Input Parsing and Argument Injection

The runtime extracts the user-supplied story, acceptance criteria, or PRD fragment and injects it into the skill’s argument placeholders. This stage captures the raw intent and any boundary conditions specified in the `$CONTEXT` variable.

### Objective Definition and Story Analysis

The skill analyzes the narrative to create explicit **test objectives** that map directly to business value. It identifies the core functionality being tested and validates that acceptance criteria are measurable and specific.

### State Setup and Role Identification

The generator enumerates required **pre-conditions**, including system state, data setup, and the specific **user role** that will execute the test. This ensures scenarios reflect real-world access patterns and permission levels.

### Granular Action Decomposition

The user flow is broken into discrete steps, each paired with an **expected result**. This creates a traceable matrix where every action has a verifiable outcome, forming the core of the test procedure.

### Edge-Case and Error Path Expansion

Automatically (step 7 of the internal process), the skill appends **boundary-condition scenarios**, invalid inputs, and failure paths. This guarantees comprehensive coverage beyond the happy path without manual specification.

### Template Rendering and Output Formatting

Finally, the skill renders the **Scenario Template** into a complete markdown document. The output includes a **Coverage Matrix** and **Test Data Requirements** section, making the result immediately executable by QA teams.

## Invoking the /test-scenarios Command

### Basic CLI Invocation

Pass a concise user story directly to the command:

```text
/test-scenarios User can reset their password via email link

```

### Complex Story Input

For detailed requirements, provide full acceptance criteria:

```text
/test-scenarios
As a shopper,
I want to view a “Recently viewed” section on product pages,
so that I can quickly return to items I’ve seen before.

**Acceptance Criteria**
- The section shows the last 4 products viewed, excluding the current one.
- Each product card displays thumbnail, title, price, and “viewed X minutes ago”.
- The section loads within 2 seconds.

```

## Anatomy of the Generated Output

The skill produces a markdown document containing:

- **Scenario headers** linking back to the source user story
- **Pre-conditions** and **user roles** required for execution
- **Step/action matrices** with expected results
- **Coverage analysis** categorizing tests as Happy Path, Edge Cases, or Error Handling
- **Test Data Requirements** specifying environmental needs

Example output excerpt:

```markdown

## Test Scenarios: Password Reset

**Source**: User can reset their password via email link
**Total scenarios**: 3
**Coverage**: Happy Path, Edge Cases, Error Handling

### Scenario 1: Successful password reset

**Tests**: User can reset their password via email link
**Preconditions**: User has a validated account, email service is operational
**User role**: End-User

| Step | Action                       | Expected Result                    |
|------|------------------------------|------------------------------------|
| 1    | Click “Forgot password”      | Reset form appears                 |
| 2    | Submit email address         | Email with reset link sent         |
| 3    | Click link in email          | Password reset page loads          |
| 4    | Enter new password & confirm | Password updated, user redirected  |

```

## Customization and Extensibility

Because the logic resides entirely in static markdown files, teams can extend the skill by editing **[`pm-execution/skills/test-scenarios/SKILL.md`](https://github.com/phuryn/pm-skills/blob/main/pm-execution/skills/test-scenarios/SKILL.md)**. For example, you can add security-scenario blocks or domain-specific validation steps by modifying the template sections (refer to lines 53-78 for the example test scenario structure). The **pm-skills** runtime interprets these changes immediately without requiring code compilation or external library updates.

## Summary

- The **Test-Scenarios** skill lives in `pm-execution/skills/test-scenarios/` and maps to the **`/test-scenarios`** command.
- It accepts **`$PRODUCT`**, **`$USER_STORY`**, and **`$CONTEXT`** arguments to generate comprehensive test plans.
- The six-step pipeline automatically handles objective definition, state setup, action decomposition, and edge-case expansion.
- Output includes structured markdown tables, **Coverage Matrices**, and **Test Data Requirements**.
- The static markdown architecture allows easy customization by editing [`SKILL.md`](https://github.com/phuryn/pm-skills/blob/main/SKILL.md) without coding.

## Frequently Asked Questions

### What arguments does the test-scenarios skill accept?

The skill accepts three parameters defined in the **Arguments** section of [`SKILL.md`](https://github.com/phuryn/pm-skills/blob/main/SKILL.md): **`$PRODUCT`** for optional product context, **`$USER_STORY`** for the main requirement text, and **`$CONTEXT`** for additional constraints or acceptance criteria. These variables are injected into the generation pipeline at runtime.

### How does the skill handle edge cases and error paths?

During step 7 of the internal process, the skill automatically expands the test plan to include **boundary-condition scenarios**, invalid inputs, and failure paths. This ensures the output covers security violations, data validation errors, and system unavailability states without manual specification.

### Can I customize the scenario template for my team?

Yes. Because the generation logic is declarative markdown in [`pm-execution/skills/test-scenarios/SKILL.md`](https://github.com/phuryn/pm-skills/blob/main/pm-execution/skills/test-scenarios/SKILL.md), you can modify the **Scenario Template** (lines 27-50) to add sections like security testing or performance benchmarks. The **pm-skills** runtime will render your custom template immediately upon the next command invocation.

### Where is the test-scenarios skill defined in the repository?

The core logic resides in **[`pm-execution/skills/test-scenarios/SKILL.md`](https://github.com/phuryn/pm-skills/blob/main/pm-execution/skills/test-scenarios/SKILL.md)**, while the CLI command wrapper is located at **[`pm-execution/commands/test-scenarios.md`](https://github.com/phuryn/pm-skills/blob/main/pm-execution/commands/test-scenarios.md)**. Together these files define how user stories transform into QA-ready documentation.