agentme 0.33.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,91 @@
1
+ ---
2
+ skill: 150-refine-plan-mode
3
+ skill-version: "2.7"
4
+ ---
5
+
6
+ ## Test Scenarios
7
+
8
+ ### Scenario 1: New feature implementation
9
+
10
+ **Trigger / Input**
11
+
12
+ "Add pagination to the user listing endpoint."
13
+
14
+ **Expected Behaviour**
15
+
16
+ The skill activates plan mode immediately. Before writing any code or editing any file, it: (1) states the goal and scope in Phase 1; (2) runs Phase 2 (Requirements Qualification) — restates understanding, scans the 6 areas for missing information, loops asking follow-up questions until convergence, then runs the scope item 3-check review; (3) per the Phase navigation rule, loops on each dependency or context item in Phase 3 (Research, Dependencies, and Draft Plan) until it converges before moving to the next; (4) runs iterative consistency checks in Phase 4, each round asking 1–5 questions across one or more checks (a–i), applying the Phase navigation rule convergence signal to stop; (5) generates a diagram in Phase 5 and loops until the human explicitly confirms it; (6) analyzes all 18 challenge angles in Phase 6 applying the Phase navigation rule per angle; (7) verifies the Phase 7 Pre-Execution Readiness checklist before approving execution.
17
+
18
+ **Simulated Human Responses**
19
+ 1. "Yes, goal and scope match exactly."
20
+ 2. "Route handler conventions look correct. Database query pattern is right."
21
+ 3. "No contradictions. The approach covers the edge cases."
22
+ 4. "Confirmed — no new issues."
23
+ 5. "The diagram matches my mental model."
24
+ 6. "Everything in scope as requested. No security concerns."
25
+ 7. "Success means all list responses include a `next` cursor and respect `limit`. Side effects are acceptable."
26
+ 8. "The caching layer is the most fragile assumption. The approach is otherwise sound."
27
+ 9. "All five scenarios work. Output is internally consistent."
28
+
29
+ **Assertions**
30
+
31
+ - [ ] Skill does not write or edit any file before Phase 7 is complete.
32
+ - [ ] Skill runs Phase 2 (Requirements Qualification) before Phase 3: restates understanding, scans 6 areas, loops asking follow-up questions, and runs scope item 3-check review.
33
+ - [ ] Each human interaction round across all phases contains 1–5 questions grouped together.
34
+ - [ ] Skill applies the Phase navigation rule convergence signal rather than a fixed round cap.
35
+ - [ ] Skill generates a diagram in Phase 5 (Visual Consistency Validation) and loops until the human explicitly confirms it.
36
+ - [ ] All 18 challenge angles in Phase 6 are analyzed; related angles may share a round.
37
+ - [ ] Phase 7 Pre-Execution Readiness checklist is verified before execution is approved.
38
+
39
+ ### Scenario 2: Well-structured input still triggers full Phase 2 Requirements Qualification
40
+
41
+ **Trigger / Input**
42
+
43
+ "Add a `/health` endpoint to the API server that returns HTTP 200 with `{status: 'ok'}` and the current UTC timestamp."
44
+
45
+ **Expected Behaviour**
46
+
47
+ Despite the input being detailed and well-structured, the skill runs Phase 2 (Requirements Qualification) in full. It restates the current understanding, scans all 6 areas for missing information, and asks follow-up questions. At minimum it asks: who the consumer of the endpoint is, whether authentication is required, what the expected response content-type is, and whether any existing health-check infrastructure must be integrated. After convergence on Step 3, it runs the scope item 3-check review.
48
+
49
+ **Simulated Human Responses**
50
+ 1. "Consumer is the load balancer. No auth required. Content-type JSON. No existing health-check infrastructure."
51
+ 2. "No edge cases beyond what was asked. No conflicting constraints."
52
+
53
+ **Assertions**
54
+
55
+ - [ ] Skill does not skip Phase 2 (Requirements Qualification) because the input appears complete.
56
+ - [ ] Skill scans all 6 areas in Phase 2 Step 2 regardless of input detail level.
57
+ - [ ] Skill runs the scope item 3-check review in Phase 2 Step 4.
58
+ - [ ] Skill applies the Phase navigation rule convergence signal before advancing to Phase 3.
59
+
60
+ ### Scenario 3: Overconfident agent wants to skip planning
61
+
62
+ **Trigger / Input**
63
+
64
+ "I already know exactly how to implement this caching layer — let's skip planning and just implement it."
65
+
66
+ **Expected Behaviour**
67
+
68
+ The skill explicitly states that agent confidence is not a substitute for consistency checks and proceeds with all 7 phases regardless of the expressed certainty level.
69
+
70
+ **Assertions**
71
+
72
+ - [ ] Skill does not skip any phase because the agent expressed confidence.
73
+ - [ ] Skill explicitly states the Questioning rule: confidence does not replace consistency checks.
74
+ - [ ] Phase 1 is still executed — goal and scope are stated; Phase 2 (Requirements Qualification) is run to qualify requirements.
75
+
76
+ ### Scenario 4: Agent resolves a subjective output design decision without asking the human
77
+
78
+ **Trigger / Input**
79
+
80
+ During angle 10 (output scenario dry runs), a scenario reveals that documentation can be structured in two ways — a single long document or a set of short quick-reference cards. The agent picks the single long document and proceeds to angle 11 without asking.
81
+
82
+ **Expected Behaviour**
83
+
84
+ The skill flags this as a violation of the Questioning rule and the HITL requirement. Subjective output design decisions must be surfaced to the human as a clarifying question — the agent must not resolve them unilaterally. The skill pauses, presents the two options, and asks the human to decide before continuing.
85
+
86
+ **Assertions**
87
+
88
+ - [ ] Skill does not proceed past a subjective design decision without asking the human.
89
+ - [ ] Skill explicitly frames the question as a clarifying question, not a confirmation request.
90
+ - [ ] Skill waits for the human's answer before continuing to the next angle.
91
+ - [ ] Violation is noted if the agent attempted to self-resolve a subjective decision.
@@ -0,0 +1,396 @@
1
+ ---
2
+ name: 151-refine-user-story
3
+ description: >
4
+ Refine, elaborate, study or develop the contents of a user story used to create a unit of work
5
+ for an agile team. Use when you need to write, refine, clarify requirements, ask follow-up
6
+ questions, cover edge cases, and split large requests into vertical slices so they are clear,
7
+ complete, and ready for implementation.
8
+ metadata:
9
+ author: flaviostutz
10
+ version: "2.0"
11
+ ---
12
+
13
+ ## Overview
14
+
15
+ Turns a vague request or rough draft into an implementation-ready user story by running a structured 7-phase refinement process: understanding the request, qualifying requirements with a scope size check, researching existing context and drafting a story skeleton, checking consistency and scope completeness, validating visually with a user journey diagram, challenging from 9 user-perspective angles, and producing a final ready-to-implement story with a readiness checklist.
16
+
17
+ Activate when:
18
+ - The request is vague, incomplete, or internally inconsistent.
19
+ - The acceptance criteria are missing or too shallow.
20
+ - The change may affect multiple parts of a system and needs a vertical-slice check.
21
+ - A requirement needs to be refined into a clear, testable story.
22
+
23
+ ## Instructions
24
+
25
+ ### Core Rules
26
+
27
+ - Start from the user input that exists today. Do not assume missing details are acceptable.
28
+ - Ask targeted follow-up questions until no material ambiguity remains.
29
+ - **HARD GATE: Do not output any story or acceptance criteria while any open decision, unresolved assumption, or ambiguous rule exists — even if the input looks detailed. Embedding an unresolved decision in the output (e.g. "rule X or Y — to be decided") is forbidden; resolve it through questions first.**
30
+ - A detailed or well-structured input does NOT exempt you from the question loop. Treat apparent completeness as a signal to look harder for hidden ambiguities.
31
+ - Analyze all affected parts of the system together before deciding whether the story is small enough.
32
+ - If the request is too large, output only the split implementation-ready stories.
33
+ - Split by independently valuable end-to-end slices, not by technical layers.
34
+ - Produce exactly one recommended result: one final story when feasible, otherwise the final split stories.
35
+
36
+ **Phase navigation rule**: Governs loop control, convergence, and phase transitions across all phases:
37
+ - **Loop**: within each phase, loop asking questions until convergence or Skip. Convergence means the last 2 consecutive rounds produced only single-sentence answers with no new issues surfaced — do not stop on a round count alone; stop only when checks genuinely have nothing left to surface. Explicit human confirmation that the phase output is correct also counts as convergence.
38
+ - **Checklist gate**: after convergence, verify any completion checklist — if items are unmet, ask those specifically (targeted questions, not a full loop restart) before advancing.
39
+ - **Skip**: when the human invokes Skip, stop the loop, record all open items as named Deferred Risks (visible in the story, carried forward), suspend the hard gate for those items, and advance immediately.
40
+ - **Backtracking**: when any finding touches goals, scope, requirements, or assumptions from an earlier phase, explain to the human which phase is affected and why, and re-run that phase's loop focused on the new information; backtracking overrides any prior skip; Phase 1 concerns re-route to Phase 2 Step 1.
41
+
42
+ **Phase gate UI rule**: At every point where the skill requires human confirmation before advancing to the next phase — any instruction that says "Wait for the answer before continuing" or requires the human to confirm convergence — use `vscode_askQuestions` to present the gate. Always include a clearly labeled recommended option such as "Continue to Phase N — [phase name]" and allow free text so the human can provide corrections, ask follow-up questions, or redirect instead. Do not present a text prompt alone and wait for freeform input — the human must always have a visible, labeled UI option to advance.
43
+
44
+ ---
45
+
46
+ ### Phase 0: Plan Document Context
47
+
48
+ Before beginning refinement, determine the working context and where output will be saved.
49
+
50
+ **Inline reference — Epic / Feature / User Story structure** (self-contained; no external policy file required to run this skill):
51
+ - **Epic** — A plan document at `[scope]/bdrs/operations/plans/NNN-epic-slug.md`. Represents a group of features toward a well-defined objective (1–12 months). Heading: `# [scope]-bdr-plan-NNN: [Epic Title]`.
52
+ - **Feature** — A `### Milestone N: [Feature Name]` section inside the epic plan. One Milestone per Feature. Duration: 2 weeks – 6 months.
53
+ - **User Story** — A key task inside a Milestone, always as a link: `- [Brief description]{.assets/userstory-NNN-slug.md}`. Pending stories append ` — pending` to the link text and have `**Status:** to-be-refined` in the file. Refined stories have the full title. Duration: < 2 weeks; stories exceeding this MUST be split.
54
+ - **User story detail file** — `.assets/userstory-NNN-slug.md` inside the epic plan's `.assets/` folder. NNN restarts at 001 per epic. Filenames always lowercase.
55
+
56
+ **Step 1 — Detect XDRS scope**
57
+
58
+ Scan the workspace for a `.xdrs/` directory. Proceed to Step 2a, 2b, or 2c based on what is found.
59
+
60
+ **Step 2a — Plan document explicitly provided or referenced:**
61
+ 1. Parse all `### Milestone` sections (Features) and collect all task entries that link to `.assets/userstory-*.md` files.
62
+ 2. For each linked file, read it and check for `**Status:** to-be-refined`. Collect only those as pending stories.
63
+ 3. Use `vscode_askQuestions` to list all pending stories (by their link text and file name) plus a "New story — I will describe it" option.
64
+ 4. If the user picks a pending story:
65
+ - Read the placeholder file. Extract the NNN and slug from its `**Story ID:**` line. Carry any notes, context, or related-story links from the placeholder into Phase 1 as starting context.
66
+ - Use the placeholder's title and notes as the subject for Phase 1.
67
+ 5. If the user picks "New story", ask which Milestone to place it in; offer to add the Milestone if it does not exist. The slug and NNN for the new story are assigned in Phase 7.
68
+
69
+ **Step 2b — XDRS scope found but no plan document provided:**
70
+ 1. Search for files matching `*/bdrs/operations/plans/*-epic-*.md`.
71
+ 2. Use `vscode_askQuestions` to ask the user to: pick an existing epic plan, create a new epic plan, or start fresh (no plan context).
72
+ 3. If an existing plan is picked, proceed as Step 2a.
73
+ 4. If **create a new epic plan** is chosen, run a guided Q&A using `vscode_askQuestions` to collect: Epic Title, one-sentence objective, Expected end date (YYYY-MM-DD), and name of the first Feature/Milestone. Then:
74
+ - Derive the epic slug by kebab-casing the title, keeping at most 7 words.
75
+ - Determine the epic NNN by scanning `[scope]/bdrs/operations/plans/` for existing plan files and using the next available number (start at 001).
76
+ - Create the file at `.xdrs/[scope]/bdrs/operations/plans/NNN-epic-slug.md` with the required `_core-adr-policy-007` sections:
77
+ ```markdown
78
+ # [scope]-bdr-plan-NNN: [Epic Title]
79
+
80
+ ## Executive Summary
81
+ [To be completed.]
82
+
83
+ ## Context and Problem Statement
84
+ [one-sentence objective collected above]
85
+
86
+ ## Proposed Solution
87
+ [To be completed.]
88
+
89
+ Expected end date: YYYY-MM-DD
90
+
91
+ ## Milestones
92
+
93
+ ### Milestone 1: [First Feature Name]
94
+ Owner: TBD
95
+ Due date: TBD
96
+
97
+ **Key tasks:**
98
+ ```
99
+ - Proceed as Step 2a (the new plan is now the active plan context, Milestone 1 is the target).
100
+ 5. If "start fresh" is chosen, continue to Phase 1 with no active plan context; Phase 7 will handle deferred stories.
101
+
102
+ **Step 2c — No XDRS scope found:**
103
+ Skip Phase 0. Proceed directly to Phase 1. Phase 7 will ask where to save output.
104
+
105
+ **Plan context record:** note the active plan file path (or none) and the target Milestone name; carry these into Phase 7.
106
+
107
+ ---
108
+
109
+ ### Phase 1: Understand the Request
110
+
111
+ 1. Announce that you are activating the refine-user-story skill. State the story goal in one sentence: what the user wants to accomplish and what value it should deliver.
112
+ 2. **Classify the input.** Decide whether the input is a vague request, partial draft, or near-complete story. State the classification explicitly.
113
+ 3. **Restate current understanding** in 2–3 lines before asking any questions.
114
+ 4. **Identify missing information.** Scan across 6 areas:
115
+
116
+ | Area | Questions to resolve |
117
+ |---|---|
118
+ | Problem and value | What problem is being solved? Who benefits? What user or business value should exist after the change? |
119
+ | Scope | What behavior is explicitly in scope? What is explicitly out of scope? What should remain unchanged? |
120
+ | Requirements | What must the system do? What inputs, outputs, or contracts matter? What constraints shape the solution? |
121
+ | Flow and interactions | What is the main end-to-end flow? Which actors, systems, or interfaces are involved? Are there state transitions or lifecycle rules? |
122
+ | Edge cases | What unusual but valid scenarios must work? What invalid inputs or error paths must be handled? What happens on retries, duplicates, partial failure, or missing data? |
123
+ | Dependencies | What upstream or downstream systems affect the change? Are there required approvals, sequencing, or external decisions? Does any migration, rollout, or compatibility concern exist? |
124
+
125
+ Use `vscode_askQuestions` to ask at most 4–5 tightly related questions from the initial scan. Apply the Phase navigation rule.
126
+
127
+ Then use `vscode_askQuestions` (per Phase gate UI rule) with at least these options:
128
+ - **"Continue to Phase 2 — Requirements Qualification"** (recommended when initial understanding is sufficient)
129
+ - **"Re-run Phase 1 — deeper pass"** — revisit classification and 6-area scan with fresh eyes, then re-present this gate.
130
+ - **"Add a comment or correction"** (open box) — re-run Phase 1 treating the comment as additional context, then re-present this gate.
131
+
132
+ ---
133
+
134
+ ### Phase 2: Requirements Qualification
135
+
136
+ #### Step 1 — Ask follow-up questions
137
+
138
+ Loop asking questions across the 6 areas from Phase 1. After each answer, evaluate whether new ambiguities surfaced before continuing. Apply the Phase navigation rule.
139
+
140
+ - **Always use `vscode_askQuestions`** when available. Never dump questions as plain text.
141
+ - Ask at most 4–5 tightly related questions per call. Do not batch many unrelated questions together.
142
+ - Use `options` whenever the answer space is bounded. Use free-form text only when truly open-ended.
143
+ - **Do not proceed to Step 2 while any open decision, unresolved assumption, or ambiguous rule exists.** If you find yourself wanting to write "or X" / "TBD" / "to be documented" anywhere, that is a sign you skipped a question.
144
+ - **Interface and integration scan**: before closing Step 1, explicitly check for: external APIs invoked (endpoints, HTTP methods, request/response payloads, authentication, behavior); input/output data (field names, types, formats, valid values, meanings, constraints); documentation links (specs, API references, runbooks); contact names and roles (owners of external systems or business rules); process rules or business logic tied to the story. Ask targeted questions for any missing details.
145
+
146
+ #### Step 2 — Scope size evaluation
147
+
148
+ Assess whether the request as currently scoped is suitable for a single focused story. A request is likely too large if two or more of the following are true (a single criterion alone is not sufficient):
149
+ - More than approximately 10 distinct scope items resulted from questioning.
150
+ - Multiple independent user outcomes each of which stands alone as releasable value.
151
+ - Three or more qualitatively different user flows each requiring substantial independent analysis.
152
+ - Multiple distinct actor groups experiencing the feature in non-overlapping ways.
153
+
154
+ If too large, propose a split into 2–4 vertical slices where each slice delivers independent end-to-end releasable value. Present the proposed split with a brief rationale for each slice's boundary. Use `vscode_askQuestions` with:
155
+ - **"Accept split — start refining [Slice 1 name]"** (recommended) — restart from Phase 1 with the narrower scope; record all deferred slices in a **Deferred Stories** list so they can be tracked for future runs.
156
+ - **"Keep original scope — continue"** — proceed without splitting; note the human explicitly accepted the larger scope.
157
+ - Free text to adjust the proposed slice boundaries before deciding.
158
+
159
+ If the human accepts the split, restart the entire process from Phase 1 with the new narrower scope.
160
+
161
+ #### Step 3 — Feature summary and phase gate
162
+
163
+ Present a brief feature summary — a short bullet list of what will be built or changed, written in plain language the requester can validate at a glance.
164
+
165
+ Then use `vscode_askQuestions` (per Phase gate UI rule) with at least these options:
166
+ - **"Continue to Phase 3 — Context & Story Draft"** (recommended when requirements are clear and agreed)
167
+ - **"Re-run Phase 2 — deeper pass"** — repeat all steps with fresh eyes, prioritising areas not yet fully explored, then re-present this gate.
168
+ - **"Add a comment or correction"** (open box) — re-run Phase 2 in full treating the comment as additional context, then re-present this gate.
169
+
170
+ ---
171
+
172
+ ### Phase 3: Context & Story Draft
173
+
174
+ 1. **Research existing context**: inspect relevant workspace files, existing user stories or tickets, prior decisions, established conventions, and analogous patterns already in place. Ask questions about any non-trivial context items found. Apply the Phase navigation rule.
175
+ 2. **Draft a story skeleton** — a rough but structured version of the output template — incorporating context found. The skeleton must include at minimum: Title, User Story, Scope, and Acceptance Criteria as first drafts (not final).
176
+ 3. Present the draft skeleton and use `vscode_askQuestions` (per Phase gate UI rule) with at least these options:
177
+ - **"Continue to Phase 4 — Consistency & Scope Review"** (recommended when the draft matches intent)
178
+ - **"Re-run Phase 3 — explore deeper"** — repeat the research pass looking for context, decisions, or constraints not yet surfaced, then re-present this gate.
179
+ - **"Add a comment or correction"** (open box) — re-run Phase 3 treating the comment as additional context, then re-present this gate.
180
+ 4. If the draft reveals gaps or contradictions, return to Phase 2 before continuing.
181
+
182
+ ---
183
+
184
+ ### Phase 4: Consistency & Scope Review
185
+
186
+ #### Step 1 — Consistency check
187
+
188
+ Look for contradictions between goal, scope, and acceptance criteria:
189
+ - Cross-check the evolving story against any context provided by the user.
190
+ - If workspace docs or code are relevant, inspect them to confirm terminology, constraints, and affected parts.
191
+ - Verify: requirements don't contradict each other; acceptance criteria prove the requirements; terminology is consistent; no assumptions remain unresolved.
192
+
193
+ Ask questions about all findings. Apply the Phase navigation rule.
194
+
195
+ #### Step 2 — Scope item review
196
+
197
+ For every item listed under **Scope**, loop through these four checks before moving on:
198
+
199
+ | Check | What to look for |
200
+ |---|---|
201
+ | Completeness | Is the item fully described? Are inputs, outputs, triggers, and expected behavior clear enough for autonomous implementation without guessing? |
202
+ | Edge cases | Does this item have unusual paths — errors, empty states, boundary values, retries, or concurrency — not yet captured? Add any found. |
203
+ | Technical constraints | Does this item imply or conflict with an existing technical constraint (e.g. API contract, data model, performance budget, auth model)? Flag any that must be honored. |
204
+ | Missing attachments | Would a screenshot, mockup, flow diagram, or reference document make this item unambiguous? If so, ask for it explicitly before proceeding. |
205
+ | Detailed Specs | Did refinement surface any external APIs, data contracts, documentation links, or contact names relevant to this item? If yes, are they fully recorded? If anything is missing, ask targeted questions. If none apply, note it explicitly so the N/A can be recorded in the output. |
206
+
207
+ Do **not** advance while any scope item fails a check. If a check reveals a new gap, return to Phase 2 and ask the follow-up question.
208
+
209
+ After all checks converge, use `vscode_askQuestions` (per Phase gate UI rule) with at least these options:
210
+ - **"Continue to Phase 5 — Visual Validation"** (recommended when all items pass all checks)
211
+ - **"Re-run Phase 4 — deeper pass"** — repeat all consistency and scope checks with fresh eyes, then re-present this gate.
212
+ - **"Add a comment or correction"** (open box) — re-run Phase 4 treating the comment as additional context, then re-present this gate.
213
+
214
+ ---
215
+
216
+ ### Phase 5: Visual Validation
217
+
218
+ 1. **Choose a diagram type** that best externalizes the user journey for this story:
219
+ - **Flowchart** — step-by-step user decision flows and happy / error paths
220
+ - **Sequence diagram** — interactions between user and system over time
221
+ - **State diagram** — lifecycle states and transitions visible to the user
222
+ - **Activity diagram** — parallel user and system activities
223
+
224
+ 2. **Generate the diagram.** The diagram must show at minimum: the actor, the trigger, the main steps, the outcome, and at least one error or edge path.
225
+
226
+ 3. Use `vscode_askQuestions` (per Phase gate UI rule) to ask: "Does this diagram match your mental model of the user journey?" Present at least these options:
227
+ - **"Continue to Phase 6 — User-Perspective Challenge"** (recommended when the diagram matches)
228
+ - **"Re-run Phase 5 — try a different diagram type"** — choose a different type or regenerate with a different framing, then re-present this gate.
229
+ - **"Add a comment or correction"** (open box) — re-run Phase 5 treating the comment as additional context, then re-present this gate.
230
+
231
+ 4. If the diagram reveals gaps or inconsistencies not yet surfaced, return to Phase 4 before continuing.
232
+
233
+ ---
234
+
235
+ ### Phase 6: User-Perspective Challenge
236
+
237
+ Each angle is an analysis step. Run the angle and present findings. Ask questions about all findings per the Phase navigation rule. Only skip asking when a finding is trivially obvious and carries no decision weight. Loop on each angle until no new questions surface before marking it complete. Do not resolve choice points unilaterally.
238
+
239
+ **1. User journey completeness**
240
+ Does the story cover the full user journey from trigger to completion, including what happens immediately after? Identify any step the user must take that is not covered by the story.
241
+
242
+ **2. Pain point alignment**
243
+ Does solving this actually address the real underlying pain, or does it address only a surface symptom? What is the root cause the user is experiencing, and does the story eliminate it?
244
+
245
+ **3. Emotional experience**
246
+ How does the user feel at each touchpoint in the journey — when initiating, waiting, receiving feedback, encountering errors? Are frustration, confusion, or delight anticipated and addressed?
247
+
248
+ **4. Mental model match**
249
+ Does the interaction described in the story match how users naturally expect the system to behave? Where will users be surprised, confused, or forced to adapt their mental model?
250
+
251
+ **5. Value clarity and timing**
252
+ Is the value the user receives immediate and perceivable, or is it delayed or indirect? Will users understand why this feature helps them, or does its value require explanation?
253
+
254
+ **6. Accessibility and inclusion**
255
+ Can users with different abilities (visual, motor, cognitive), language backgrounds, device types, or technical literacy levels complete this story's user journey successfully?
256
+
257
+ **7. Edge user scenarios**
258
+ How are these user profiles served: a first-time user unfamiliar with the feature; a power user who already knows what they want; a user trying to recover from an error; a user under time pressure? Are all adequately served?
259
+
260
+ **8. Trust and safety**
261
+ Are there data privacy, error recovery, or safety implications from the user's perspective? Will users trust the system's behavior during this interaction, especially for error states and data handling?
262
+
263
+ **9. Learnability**
264
+ Can a new user complete this story's scenario without reading documentation? What is the first-use experience? Are there onboarding moments, tooltips, or self-describing UI elements needed?
265
+
266
+ After all 9 angles converge, use `vscode_askQuestions` (per Phase gate UI rule) with at least these options:
267
+ - **"Continue to Phase 7 — Story Output & Readiness"** (recommended when all angles have converged and no open questions remain)
268
+ - **"Re-run Phase 6 — deeper pass"** — repeat all angles with fresh challenge questions, prioritising angles not yet fully explored, then re-present this gate.
269
+ - **"Add a comment or correction"** (open box) — re-run Phase 6 treating the comment as additional context, then re-present this gate.
270
+
271
+ ---
272
+
273
+ ### Phase 7: Story Output & Readiness
274
+
275
+ Before producing the final story, verify ALL items in the checklist below. If any item cannot be checked, return to the relevant phase and resolve it first.
276
+
277
+ - [ ] Problem, intended user value, and beneficiary unambiguous.
278
+ - [ ] Scope boundaries explicit (in / out / unchanged).
279
+ - [ ] Requirements, flow, edge cases, dependencies known or explicitly deferred as named Deferred Risks.
280
+ - [ ] Every in-scope item passes the 5-check review (completeness, edge cases, technical constraints, attachments, detailed specs) with no open findings.
281
+ - [ ] No contradictions between goal, scope, and acceptance criteria.
282
+ - [ ] Story is either one thin vertical slice or a clean set of split slices, each delivering complete releasable value.
283
+ - [ ] All 9 user-perspective challenge angles completed with human input received for every ambiguity and subjective decision.
284
+ - [ ] Diagram generated and confirmed by the human.
285
+ - [ ] No unresolved human questions outstanding.
286
+ - [ ] For every in-scope item where integration or interface details exist: `## Detailed Specs` is populated or explicitly marked N/A; the story contains enough detail to begin architecture or implementation without further business clarification.
287
+
288
+ Once all items are checked or explicitly marked N/A, **produce the final result** using the output template below.
289
+ - If one story is feasible, output one refined story.
290
+ - If the work is too large, output only the split stories using the same template.
291
+ - Acceptance criteria must be a plain checklist.
292
+
293
+ If any stories or features were placed in the **Deferred Stories** list during Phase 2 Step 2 (scope split), or any items were recorded as named **Deferred Risks** during a Skip, present a **Deferred Items summary** — a bulleted list of each deferred item with a one-line description of what it covers and why it was deferred.
294
+
295
+ **When an XDRS plan doc is active** (Phase 0 selected or created a plan): skip this prompt entirely. Deferred slices are handled as placeholder files with task links in the plan doc by the Plan document integration section below.
296
+
297
+ **When no XDRS plan doc is active**: use `vscode_askQuestions` with:
298
+ - **"Save to BACKLOG.md"** (recommended) — append the list under a `## Deferred Stories` heading in `BACKLOG.md` at the workspace root (create the file if it does not exist), so the items can be planned for future refinement runs.
299
+ - **"Save to a different file"** (open box) — human specifies the file path; append there instead.
300
+ - **"Skip — do not save"** — proceed without saving.
301
+
302
+ This step is skipped if no stories were deferred and no Deferred Risks were recorded.
303
+
304
+ ### Plan document integration
305
+
306
+ After producing the final story output, persist it according to the active plan context from Phase 0.
307
+
308
+ **When an XDRS plan doc is active (Phase 0 selected or created a plan):**
309
+ 1. Determine the NNN and slug for the story detail file:
310
+ - **Placeholder story** (Phase 0 picked a pending story): extract the NNN and slug from the placeholder file's `**Story ID:**` line. Reuse them for the refined file.
311
+ - **New story** (Phase 0 chose "New story" or a new epic was created): use the next available NNN in the plan's `.assets/` folder (list existing `userstory-NNN-*.md` files, increment the highest; start at 001 if empty). Derive the slug by kebab-casing the refined `## Title`, keeping at most 7 words, e.g. `save-payment-method-future-checkouts`.
312
+ 2. Write the refined story as `.assets/userstory-NNN-slug.md` inside the plan's `.assets/` folder using the output template, including the `**Story ID:** userstory-NNN-slug` line at the top (no `**Status:**` line — absence of the status field indicates a refined story).
313
+ 3. In the plan doc, update the task entry link text in the active Milestone: change `[Brief description — pending]` to `[Refined Story Title]` (keep the same `.assets/userstory-NNN-slug.md` path). For new stories, insert a new task entry `- [Refined Story Title]{.assets/userstory-NNN-slug.md}`.
314
+ 4. When splitting: for each non-chosen slice, create a placeholder file at `.assets/userstory-NNN-slug.md` containing:
315
+ - `**Story ID:** userstory-NNN-slug`
316
+ - `**Status:** to-be-refined`
317
+ - A `## Title` with the preliminary description of the slice.
318
+ - A `## Notes from intake` section with any relevant context captured in this session: split rationale, relationship to the current story, any API or business details already known.
319
+ - A `## Related` section linking to the current story being refined.
320
+ Assign NNNs sequentially after the highest existing one in `.assets/` (the current story's file already written by step 2 counts as existing). Insert a task entry `- [Slice description — pending]{.assets/userstory-NNN-slug.md}` in the same Milestone (or a new Milestone if the split reveals a distinct Feature). Do NOT offer BACKLOG.md for deferred slices.
321
+ 5. Add a back-link to the epic plan at the bottom of the story detail file: `**Epic plan:** [NNN-epic-slug.md]{../NNN-epic-slug.md}` (the `../` resolves from `.assets/` up to `plans/`).
322
+
323
+ **When no XDRS plan doc is active ("start fresh" or no XDRS scope):**
324
+ - Ask the user where to save the refined story (default: `userstory-NNN-slug.md` at workspace root).
325
+ - If split/deferred stories exist, use `vscode_askQuestions` to ask whether to add them to an existing epic plan, create a new epic plan, or save to `BACKLOG.md`. Apply the chosen action.
326
+
327
+ ### Output Template
328
+
329
+ ```
330
+ **Story ID:** userstory-NNN-slug
331
+
332
+ ## Title
333
+ [required — max 10 words, outcome-focused, e.g. "Add fraud-check endpoint for payment processing"]
334
+
335
+ ## User Story
336
+ [required — max 50 words]
337
+ As a [role], I want to [action], so that [benefit].
338
+
339
+ ## Scope
340
+ [required — max 200 words. List features, behaviors, screens, or services in scope with key characteristics and points of attention.]
341
+ - [feature or behavior — characteristic / point of attention]
342
+
343
+ ## Edge Cases
344
+ [optional — max 50 words. Known edge cases and how each should be handled.]
345
+ - [edge case — expected handling]
346
+
347
+ ## Out of Scope
348
+ [optional — max 30 words. What will not be touched; deferred to later or handled elsewhere.]
349
+ - [out-of-scope item]
350
+
351
+ ## Constraints
352
+ [optional — max 30 words. Any rule, technology, regulatory, or business constraint that must be respected.]
353
+ - [constraint]
354
+
355
+ ## Detailed Specs
356
+ [Required when any API, integration, or data detail was discovered. Mark N/A if none.
357
+ A story lacking sufficient detail here is not ready for implementation.]
358
+ - [External API / integration: endpoint, method, payload, auth, behavior]
359
+ - [Data field: type, format, valid values, meaning, constraints]
360
+ - [Doc link: URL or file path — what it covers]
361
+ - [Contact: name/role — what they own or can clarify]
362
+ - [Process rule or business constraint not captured in Constraints above]
363
+
364
+ ## Acceptance Criteria
365
+ [required — max 50 words. Verifiable checklist confirming the story is done.]
366
+ - [ ] [verifiable outcome]
367
+
368
+ ## Attachments
369
+ [highly desirable — screenshots, mockups, or diagrams illustrating the feature.]
370
+ - [attachment]
371
+ ```
372
+
373
+ ---
374
+
375
+ ## Examples
376
+
377
+ **Input:** "Add a search bar to the product page."
378
+
379
+ **Clarifying questions asked:** Who performs the search? What data is searched? Should results filter the current page or navigate elsewhere? What happens on no results?
380
+
381
+ **Output:** A refined story scoped to keyword search on product name and description, filtering the current product list in place, with an empty-state message when no results match, and no pagination changes in scope.
382
+
383
+ **Phase 6 example (angle 3 — Emotional experience):** "When search returns no results, the user may feel confused or assume the product doesn't exist. The story needs an empty-state message that reassures the user and offers a next action." → Question asked: "Should the empty state suggest alternative search terms or link to a 'browse all products' view?"
384
+
385
+ ## Edge Cases
386
+
387
+ - **Input already contains detailed acceptance criteria**: do not skip the question loop; look harder for hidden ambiguities in scope boundaries and edge cases.
388
+ - **User refuses to answer a clarifying question**: note it as an unresolved assumption and do not produce output until it is resolved.
389
+ - **Request spans multiple independent user outcomes**: always split into separate vertical-slice stories rather than merging into one broad story.
390
+ - **Diagram cannot be generated**: describe the user journey in a plain-language step-by-step walkthrough. The intent of Phase 5 is to externalize the journey — the medium is secondary.
391
+
392
+ ## References
393
+
394
+ - [`agentme-edr-012`](../../012-continuous-xdr-enrichment.md) — Continuous XDR enrichment policy
395
+ - [`agentme-edr-017`](../../017-skill-testing.md) — Skill testing mandate
396
+ - [`agentme-bdr-401`](../../../../bdrs/operations/401-epic-feature-story-planning.md) — Epic/feature/user story planning structure (policy source for the inline reference in Phase 0)