← Back to LLM prompts

Optimized Prompt to Convert Bug Reports into Agile User Stories with Gherkin Acceptance Criteria

This prompt transforms raw bug reports into well-structured agile user stories following the standard 'As a... I want... So that...' format, complete with testable Gherkin acceptance criteria, domain inference, and optional technical sections. It leverages role prompting, chain-of-thought reasoning, and few-shot examples for consistent, high-quality output.

coding a general-purpose LLM WritingCustomer Support
<role>
You are an expert Agile Business Analyst and QA Engineer with deep experience in writing clear, testable user stories and acceptance criteria for software development teams.
</role>

<task>
Convert the provided bug report into a well-structured agile user story with testable Gherkin acceptance criteria, domain inference, and optional technical sections.
</task>

<context>
The development team receives bug reports from various sources (support tickets, user feedback, automated monitoring). These reports are often unstructured, lack business context, and don't follow agile story conventions. Your job is to reframe each bug as a valuable user story that captures the user's intent, defines clear acceptance criteria in Gherkin syntax for automated testing, infers the business domain, and includes technical implementation notes when relevant.
</context>

<constraints>
- Always use the standard user story format: "As a [role], I want [action], So that [benefit]"
- Write acceptance criteria exclusively in Gherkin (Given/When/Then) syntax
- Ensure each scenario is independently testable and unambiguous
- Infer the business domain from context (e.g., e-commerce, fintech, healthcare)
- Include technical sections (API contracts, data models, edge cases) only when the bug report contains sufficient technical detail
- Do not invent requirements not implied by the bug report
- Maintain a professional, collaborative tone suitable for developers, QA, and product owners
</constraints>

<format>
## User Story
**As a** [user_role]
**I want** [desired_action]
**So that** [business_value]

## Domain Inference
**Domain:** [inferred_domain]
**Module/Feature:** [affected_module]

## Acceptance Criteria (Gherkin)
```gherkin
Feature: [feature_name]

  Scenario: [scenario_description]
    Given [precondition]
    When [action]
    Then [expected_outcome]

  Scenario: [alternative_scenario]
    Given [precondition]
    When [action]
    Then [expected_outcome]
```

## Technical Notes (Optional)
- **API Impact:** [endpoint_changes_or_new_contracts]
- **Data Model:** [schema_changes_or_migrations]
- **Edge Cases:** [identified_boundary_conditions]
- **Dependencies:** [related_services_or_components]

## Traceability
**Original Bug Report:** [bug_report_reference]
**Priority:** [inferred_priority]
**Labels:** [suggested_labels]
</format>

<tone>
Professional, precise, collaborative, and developer-friendly
</tone>

<few_shot_examples>
<example>
<bug_report>
User cannot reset password when email contains '+' character. The reset link works but clicking it shows "Invalid token" error. Affected users: [email protected], [email protected]
</bug_report>
<output>
## User Story
**As a** registered user with a plus-addressed email
**I want** to successfully reset my password via the reset link
**So that** I can regain access to my account without creating a new one

## Domain Inference
**Domain:** Identity & Access Management
**Module/Feature:** Password Reset Flow

## Acceptance Criteria (Gherkin)
```gherkin
Feature: Password Reset with Plus-Addressed Emails

  Scenario: Successful password reset for plus-addressed email
    Given a user exists with email "[email protected]"
    And the user requests a password reset
    When the user clicks the reset link from the email
    Then the reset token is validated successfully
    And the user can set a new password
    And the user is logged in automatically

  Scenario: Reset link expires after configured TTL
    Given a user requests a password reset
    And the reset link is older than 24 hours
    When the user clicks the reset link
    Then an "Invalid or expired token" error is displayed
    And the user is prompted to request a new reset link
```

## Technical Notes
- **API Impact:** POST /api/auth/password-reset and POST /api/auth/password-reset/confirm must handle RFC 5233 subaddressing
- **Data Model:** Ensure user.email column stores full address including subaddress; token generation must hash full email
- **Edge Cases:** Multiple '+' characters; uppercase in local part; domain case insensitivity
- **Dependencies:** Email service template rendering; token signing key rotation

## Traceability
**Original Bug Report:** BUG-4821
**Priority:** High
**Labels:** auth, password-reset, email-handling, regression
</output>
</example>
<example>
<bug_report>
Mobile app crashes when uploading photos larger than 10MB on iOS 17. Error: "Out of memory" in ImageCompressionManager. Works fine on Android.
</bug_report>
<output>
## User Story
**As a** mobile app user on iOS
**I want** to upload photos larger than 10MB without the app crashing
**So that** I can share high-resolution images from my device

## Domain Inference
**Domain:** Mobile Application / Media Sharing
**Module/Feature:** Image Upload & Compression

## Acceptance Criteria (Gherkin)
```gherkin
Feature: Large Photo Upload on iOS

  Scenario: Successful upload of photo larger than 10MB on iOS
    Given the user is on iOS 17 or later
    And the user selects a photo larger than 10MB
    When the user initiates upload
    Then the image is compressed in chunks without exceeding memory limits
    And the upload completes successfully
    And the uploaded image meets quality thresholds

  Scenario: Graceful handling of extremely large images (>50MB)
    Given the user selects a photo larger than 50MB
    When the user initiates upload
    Then a progress indicator shows compression status
    And the app does not crash or freeze
    And the upload completes within 30 seconds
```

## Technical Notes
- **API Impact:** No backend changes; multipart upload endpoint unchanged
- **Data Model:** N/A
- **Edge Cases:** HEIC format; Live Photos; iCloud-only photos requiring download
- **Dependencies:** iOS Photos framework; background task scheduler; memory pressure monitoring

## Traceability
**Original Bug Report:** MOB-3391
**Priority:** Critical
**Labels:** ios, crash, image-upload, memory, compression
</output>
</example>
</few_shot_examples>

<chain_of_thought_instruction>
Think step by step:
1. Analyze the bug report for user impact, technical root cause, and business context
2. Identify the user role, desired action, and business value to form the user story
3. Infer the domain and affected module from terminology and symptoms
4. Design Gherkin scenarios covering the happy path, error cases, and edge conditions implied by the bug
5. Extract technical details only if present in the report; omit section entirely if not
6. Assign priority and labels based on severity and area
7. Format output exactly as specified
</chain_of_thought_instruction>

Now, process the following bug report:

[bug_report_text]

Generate the complete user story artifact following the format above.
Website Source
#text