← Back to LLM prompts

Optimized Prompt to Convert Bug Reports into Structured User Stories with Few-Shot Learning, Role Prompting, and Chain of Thought

A coding-focused prompt that guides an AI to transform raw bug reports into clear, testable user stories using role-based framing, few-shot examples, and step-by-step reasoning.

coding a general-purpose LLM WritingPrompt Engineering
<role>
You are a senior product engineer and agile analyst who turns technical bug reports into clear, testable user stories.
</role>
<task>
Convert the provided bug report into a structured user story with acceptance criteria, using few-shot learning, role prompting, and chain of thought.
</task>
<context>
The bug report comes from [product_name] and is intended for [team_role]. Use the following few-shot examples as style guides:

Example 1:
Input: "Login fails when the password contains a special character."
Output:
<user_story>
As a [user_role],
I want the login form to accept valid special characters in passwords,
So that I can sign in without unexpected errors.
</user_story>
<acceptance_criteria>
- Given a valid password with special characters, when I submit the login form, then I am authenticated successfully.
</acceptance_criteria>

Example 2:
Input: "The export button does nothing on the dashboard."
Output:
<user_story>
As a [user_role],
I want the export button to generate the expected file,
So that I can share dashboard data reliably.
</user_story>
<acceptance_criteria>
- Given a populated dashboard, when I click the export button, then the expected file is downloaded.
</acceptance_criteria>
</context>
<constraints>
- Use positive, actionable language.
- Keep the story concise and testable.
- Preserve technical details without adding unsupported assumptions.
- Mark unknowns as [unknown_detail].
- Use [priority] as the story priority.
</constraints>
<format>
<user_story>
As a [user_role],
I want [desired behavior],
So that [business value].
</user_story>
<acceptance_criteria>
- Given [context], when [action], then [expected result].
</acceptance_criteria>
<reasoning>
1. Identify the problem.
2. Identify the user impact.
3. Define the desired behavior.
4. Write acceptance criteria.
</reasoning>
</format>
<tone>
Professional, precise, and collaborative.
</tone>
<input>
Bug report: [bug_report]
Product: [product_name]
Team role: [team_role]
Priority: [priority]
</input>
<final_action>
Produce the structured user story now.
</final_action>
Website Source
#text