Decomposition & BDD Prompting
Lab Playbook 4
Converting failed monolithic requirements into modular, AI-ready BDD stories
In this lab playbook, you will assume the role of an Agile Coordinator & Decomposition Analyst. Once you identify the gaps in a specification (as we did on Day 3), you must guide the agent to decompose the monolithic story into isolated, testable user stories using Behavior-Driven Development (BDD) Given-When-Then syntax. This guarantees that subsequent coding and testing tasks are scoped within clear boundary constraints.
backlog.md file in the repository.Feature Mapping (QE Setup)
To prepare our backlog, we will direct the agent to analyze the INVEST audit report we saved on Day 3 and map out distinct feature boundaries.
Read the INVEST audit results and gap analysis saved in './invest_report.md'. Map out the distinct feature boundaries and list them as separate, independent user stories.I have analyzed './invest_report.md'. Based on the identified gaps and boundaries, I recommend partitioning the monolith into three separate user stories: 1. **US-001: Vehicle Registration Lookup & Input Validation** - Focus: Enter registration number, trigger search, fetch Make/Model/Year, and validate form fields. 2. **US-002: Insurance Quote Calculation Engine** - Focus: Pricing algorithm based on usage type (Social, Business, Commute) and age multiplier. 3. **US-003: Stripe Checkout Integration** - Focus: Secure Stripe modal loading, credit card validation, and redirection to success/cancel pages.
Given-When-Then Synthesis (QE Instruction)
Now we instruct the agent to translate these feature boundaries into non-subjective, testable BDD Given-When-Then scenarios.
Translate US-001 (Vehicle Registration) and US-002 (Quote Calculation Engine) into concrete, testable BDD Given-When-Then scenarios. Eliminate all subjective terms and define exact validation thresholds.Here are the structured BDD scenarios for the first two user stories: ### US-001: Vehicle Registration Lookup & Input Validation **Scenario 1: Valid registration lookup** - **Given** a guest user is on the motor insurance quote form page - **When** they enter a valid UK registration number "AA11AAA" - **And** click the "Search" button - **Then** the system pre-populates Make, Model, and Year fields with retrieved data - **And** the "Next" button is enabled. **Scenario 2: Invalid registration format** - **Given** a guest user is on the quote form page - **When** they enter an invalid registration number "INVALID" - **Then** the system displays a validation error: "Please enter a valid UK registration number" - **And** the "Next" button remains disabled. ### US-002: Insurance Quote Calculation Engine **Scenario 1: Calculate quote for commuting usage** - **Given** the user has populated valid registration details - **When** they select "Commuting" as the usage type - **And** click "Calculate Quote" - **Then** the system returns a price calculated as: base price (Β£500) + commuting surcharge (Β£75) = Β£575.
Story Isolation (QE Instruction)
To prevent test suite coupling, we must ensure the agent writes these stories into separate, independent blocks with explicit pre-conditions.
Structure these BDD scenarios into distinct user story blocks. For each story, define:
1. Preconditions (e.g. state required to run this test)
2. Mock inputs
3. Expected assertions
Confirm that none of the stories depend on the execution of another.I have structured the stories to ensure maximum isolation. Here are the decoupled definitions: ### Decoupled Story Backlog #### US-001: Vehicle Registration Lookup - **Preconditions**: Base application is loaded, mock API lookup service is active. - **Mock Inputs**: UK Reg = "AA11AAA", Invalid Reg = "INVALID" - **Assertions**: - Valid reg pre-populates fields, Next button enabled. - Invalid reg shows error "Please enter a valid UK registration number", Next button disabled. - **Dependency Status**: Independent. Can be tested without calculation logic. #### US-002: Quote Calculation Engine - **Preconditions**: Form vehicle lookup data is set (injected via state/mocking), base rate is configured to Β£500. - **Mock Inputs**: Usage Type = "Commuting" - **Assertions**: - Commuting price is calculated as exactly Β£575. - **Dependency Status**: Isolated. Preconditions are mocked to bypass US-001 lookup.
Backlog Definition & State Preservation
Finally, we instruct the agent to save the structured backlog into our workspace and commit the changes to Git.
Save the isolated BDD user stories to a new file named './backlog.md'. Once saved, run git status to check the state.Saving BDD backlog to './backlog.md'... β File saved successfully. Checking git status: $ git status On branch qe/feature-login-tests Untracked files: (use "git add <file>..." to include in what will be committed) backlog.md nothing added to commit but untracked files present
Stage and commit './backlog.md' with the message "docs: add decomposed BDD backlog". Verify the commit history using git log.Staging backlog.md... $ git add backlog.md Committing backlog.md... $ git commit -m "docs: add decomposed BDD backlog" [qe/feature-login-tests a8c3f4a] docs: add decomposed BDD backlog 1 file changed, 35 insertions(+) create mode 100644 backlog.md Checking latest commits: $ git log -n 2 --oneline a8c3f4a docs: add decomposed BDD backlog 2be2c1a docs: add INVEST audit report and gap analysis β BDD backlog logged and committed successfully.
You have successfully mapped features from audited requirements, synthesized testable BDD Given-When-Then criteria, isolated story pre-conditions, and committed the final backlog to Git.