@pavp/storywright 1.4.0 → 1.6.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.
@@ -1,17 +1,17 @@
1
1
  ---
2
2
  name: story-generate
3
- description: Transform an ambiguous prompt, half-baked story, screenshot, or Figma link into a Jira-ready user story with acceptance criteria, DoD, edge cases, and risks. Ask only critical clarifying questions.
3
+ description: Transform an ambiguous prompt, half-baked story, screenshot, or Figma link into a Jira-ready user story. Cohn+Gherkin canonical. Asks clarifications ONLY in terminal.
4
4
  trigger: "/story-generate | generate a user story | write a user story | turn this into a story | crear historia de usuario"
5
- intent: Top-level orchestrator skill that drives the full story generation flow by composing component skills.
6
- version: 1.0.0
5
+ intent: Top-level orchestrator that drafts a fresh story from any input. Follows the same hard rules as story-refine v2.2 (Cohn philosophy, terminal-only Q, no mini-PRD, deterministic split gate).
6
+ version: 2.2.0
7
7
  inputs:
8
8
  - text
9
9
  - image
10
10
  - figma-link
11
11
  outputs:
12
- - story.jira-wiki.md
13
12
  - story.standard.md
14
- - clarifications.md
13
+ - story.jira-wiki.md
14
+ - .storywright-context.json
15
15
  composes:
16
16
  - _components/clarification-questions
17
17
  - _components/acceptance-criteria
@@ -26,7 +26,82 @@ composes:
26
26
 
27
27
  ## Purpose
28
28
 
29
- Take whatever the PM has — a one-liner, a half-baked story, a screenshot, a Figma link — and produce a story that an engineer can pick up and ship without follow-up questions. Always output two artifacts (Jira wiki + CommonMark).
29
+ Take whatever the PM has — a one-liner, a half-baked story, a screenshot, a Figma link — and produce a Cohn+Gherkin story an engineer can pick up and ship without follow-up questions. If the input is too broad, recommend `/story-split` instead of producing a mini-PRD.
30
+
31
+ ## Hard rules (no exceptions)
32
+
33
+ 1. **Terminal-only clarifications.** Never write any sidecar question file (no `clarifications.md`). All gap questions go through `AskUserQuestion` (batch in groups of ≤4). Non-blocking gaps → mark `⚠️ Assumed` inline.
34
+
35
+ 2. **Cohn + Gherkin canonical.** One Use Case block. One AC scenario per story (one Given chain, one `When`, one `Then`). If the input naturally needs >1 `When`/`Then` → STOP drafting, recommend `/story-split`.
36
+
37
+ 3. **No mini-PRDs.** Prohibited in story output:
38
+ - NFR blocks (a11y/i18n/perf/tokens) — these live in the team's DoD
39
+ - Edge Cases enumerations as a section — surface inside AC failure paths only
40
+ - Dependencies as prose — Jira links only
41
+ - Per-claim visual specs — use single banner (rule 5)
42
+ - Refinement logs >3 lines (>5 if SPLIT)
43
+
44
+ 4. **Output language matches the user's chat language**, not the input's. Auto-detect first (see rule 4a); only ask via `AskUserQuestion` if signals split.
45
+
46
+ 5. **Visual inference confidence — single banner only.** ONE banner at the top of the Design Reference block declares the source type. Claims under it inherit confidence:
47
+ - Raster source (PNG/JPG) → `**Source: raster mockup → all visual specs are pixel-derived, not token-confirmed.**`
48
+ - Figma source → `**Source: Figma → values can be tokenized at implementation.**`
49
+ - Design-token source → `**Source: design tokens → values are authoritative.**`
50
+ - Never assert hex / px / spacing from raster without the raster banner.
51
+
52
+ 6. **Sibling task IDs.** If the draft references "next task / future task / another story" → check `<output-folder>/.storywright-context.json` first. If unresolved, ask. Tentative slugs follow rule F.
53
+
54
+ 7. **Mockup chrome detection — closed list.** Chrome = `left nav rail / sidebar`, `top bar`, `footer`, `persistent toast/snackbar slot`, `persistent modal scrim`, `app-level tabs`. If image shows any AND the input does not mention them, ask via `AskUserQuestion` whether each is in-scope, sibling-scope, or out-of-scope. Anything not on the list is NOT chrome.
55
+
56
+ 8. **Anti-PRD is part of INVEST `Small`.** See `[[invest-checklist]]` Small criterion (line-count ceiling lives there).
57
+
58
+ 9. **Cross-skill context persistence.** When the skill resolves clarifications, write answers to `<output-folder>/.storywright-context.json`. Read only from the exact output folder of the current invocation; never search siblings or parents. Schema:
59
+ ```json
60
+ {
61
+ "version": 1,
62
+ "decided_at": "<ISO date>",
63
+ "decided_by_skill": "story-generate",
64
+ "language": "EN | ES | ...",
65
+ "chrome_scope": "in-scope | in-scope-placeholder | sibling | out-of-scope",
66
+ "siblings": "TODO | <list of IDs> | not-applicable",
67
+ "design_source": "raster | figma | tokens",
68
+ "naming_pattern": "<see rule F>",
69
+ "extra": {}
70
+ }
71
+ ```
72
+
73
+ 10. **Mixed input conflict detection.** When text + image + Figma disagree, surface as BLOCKING `AskUserQuestion`. Never silently pick a winner. (See source priority below.)
74
+
75
+ 11. **Passive-goal downstream prompt (G).** If `I want to` verb is observational (`view, see, read, browse, look at, inspect, monitor`) and `so that` lacks a follow-up user action → ask once via `AskUserQuestion`: "What does the user do with this?". Strengthen the `so that` accordingly.
76
+
77
+ ### 4a. Language auto-detect — expanded signals (E)
78
+
79
+ | Signal | Where | Weight |
80
+ |---|---|---|
81
+ | Gherkin keywords ("Given/When/Then") | AC block | high |
82
+ | Persona phrasing ("As a user" vs "Como un usuario") | Use Case | high |
83
+ | Column / field names ("Phone - primary", "Teléfono - principal") | AC bullets | medium |
84
+ | Domain verbs ("clicking" vs "hacer clic") | AC bullets | medium |
85
+ | Title language | header | low |
86
+
87
+ **Decision:**
88
+ - High+medium signals agree on M → adopt M silently. Mark inline `⚠️ Assumed: output language = <M> (auto-detected from <signals>)`.
89
+ - Signals split → ask once.
90
+ - Persist via rule 9.
91
+
92
+ ### Rule F. Naming pattern — ask once, persist
93
+
94
+ When the skill needs to invent a tentative ticket slug AND `.storywright-context.json` has no `naming_pattern`, ask once:
95
+ - kebab-case feature-action (`customer-search-bar-wire`)
96
+ - verb-noun (`wire-search-bar`)
97
+ - domain-action (`search.customer.wire-input`)
98
+ - Jira prefix + numeric (`CSB-001`)
99
+
100
+ Persist in `.storywright-context.json`. Reuse for all sibling slugs.
101
+
102
+ ### Rule D. Surface vs styling (deterministic)
103
+
104
+ A "named UI surface" counts as a separate outcome ONLY if it has its own user goal (verb where the user *does something with it*). If a noun is mentioned only in a styling context (color, padding, background) or as a sub-component of a parent surface (column inside a grid) → it is NOT a surface, it is styling. Count = 0.
30
105
 
31
106
  ## When to use
32
107
 
@@ -34,139 +109,155 @@ Take whatever the PM has — a one-liner, a half-baked story, a screenshot, a Fi
34
109
  - The user pastes a vague story and wants it production-ready.
35
110
  - The user drops an image/Figma link and asks for stories.
36
111
 
112
+ For inputs that clearly cover multiple outcomes → run the deterministic split gate (step 6 below) and recommend `/story-split` instead of drafting.
113
+
37
114
  ## Inputs & how to interpret each
38
115
 
39
116
  ### Text prompts
40
- Anything from a single phrase to a paragraph. If the prompt names only a feature, infer the implicit user goal.
117
+ Anything from a phrase to a paragraph. If only a feature is named, infer the implicit user goal and confirm via rule G if passive.
41
118
 
42
119
  ### Local images (PNG/JPG)
43
- Use vision. Extract:
44
- - UI elements (buttons, fields, navigation)
45
- - Visible states (loading, error, success)
46
- - Inferred flow (what does each element trigger?)
47
- - Confidence per inference (high / medium / low). Anything below high → add `> ⚠️ Assumed:` blockquote in the output and surface in clarifications.
120
+ Use vision. Extract UI elements, visible states, inferred flow, confidence per inference. Anything below high confidence → mark inline `⚠️ Assumed`. NEVER assert pixel-precise visual specs inline with each claim — use the single banner (rule 5).
48
121
 
49
122
  ### Figma links
50
- If MCP Figma is available (see `[[story-from-figma]]`), use it to enumerate frames, components, navigation. If not, fall back to asking the user to drop screenshots.
51
-
52
- ### Mixed inputs (text + image + Figma)
53
-
54
- The skill is designed to **fuse multiple sources** in a single invocation. Common pairings:
55
-
56
- - **Text + screenshot** — text states the goal, image shows the proposed UI. Use text for `User Story / Goal / Scope`, image for `Components / States / Edge cases / UX flow`.
57
- - **Text + Figma link** — text gives intent, Figma gives implementation surface. Use text for `User Story / Business goal`, Figma for `Technical considerations / Edge cases / Components / Multi-screen flows`.
58
- - **Text + image + Figma** — full triangulation. Highest fidelity; also highest chance of conflict.
123
+ If MCP Figma is available (see `[[story-from-figma]]`), use it. If not, fall back to asking the user for screenshots.
59
124
 
60
- **Source priority (when sources disagree):**
125
+ ### Mixed inputs (text + image + Figma) — source priority
61
126
 
62
127
  | Section | Primary | Secondary | Tertiary |
63
128
  |---|---|---|---|
64
- | User Story / Goal | Text | Figma (frame titles, callouts) | Image |
65
- | Business Rules / Scope | Text | Figma | Image |
129
+ | User Story / Goal | Text | Figma frame titles | Image |
130
+ | Scope | Text | Figma | Image |
66
131
  | UI Components / States | Figma | Image | Text |
67
- | Edge Cases | Figma + Image (states shown) | Text | — |
68
- | Technical Considerations | Figma (component naming, design system refs) | Text | Image |
69
- | Acceptance Criteria | Triangulate all three | — | — |
132
+ | AC observable outcomes | Triangulate | | — |
70
133
 
71
- **Conflict handling:**
134
+ **Conflicts → BLOCKING `AskUserQuestion`.** Never silently pick a winner.
72
135
 
73
- 1. **Detect the conflict explicitly.** Example: text says "Google only" but Figma shows Google + Facebook buttons.
74
- 2. **Do NOT silently pick a winner.** Surface the conflict in `clarifications.md` as a BLOCKING question: *"Text says X but design shows Y — which is canonical?"*
75
- 3. **If the user is in-session, ask immediately** before drafting. If running batch, mark the story `DRAFT` and write both options in scope/out-of-scope with `> ⚠️ Conflict:` annotation.
76
- 4. **Scope coverage check:** if Figma shows N flows but text describes 1, ask whether to (a) generate 1 story bounded to text, (b) generate N stories from Figma, or (c) generate 1 story + flag remaining flows as roadmap.
136
+ ## Canonical output shape
137
+
138
+ ```markdown
139
+ ### [Title]
140
+
141
+ #### Use Case
142
+ - **As a** [persona — never just "user"]
143
+ - **I want to** [action]
144
+ - **so that** [outcome with downstream action — rule G]
145
+
146
+ #### Preconditions (optional)
147
+ - ...
148
+
149
+ #### Out of Scope (optional)
150
+ - ...
151
+
152
+ #### Acceptance Criteria
153
+ - **Scenario:** [single-outcome scenario name]
154
+ - **Given:** [context — surface nouns drive downstream dep matrix]
155
+ - **and Given:** [context]
156
+ - **When:** [single trigger]
157
+ - **Then:** [single observable outcome]
158
+
159
+ #### Design Reference (optional)
160
+ **Source: <raster | figma | tokens> → <banner from rule 5>**
161
+ - [link or path]
162
+ - visual notes: [...]
163
+
164
+ #### INVEST
165
+ - I/N/V/E/S/T — one line each.
166
+ - **Verdict:** READY | SPLIT RECOMMENDED | NEEDS REFINEMENT | NOT A STORY
167
+
168
+ #### Generation log (≤3 lines; ≤5 if SPLIT)
169
+ - ...
170
+ ```
171
+
172
+ Nothing else. No NFR. No edge-cases enumeration. No deps prose. No Assumptions block.
77
173
 
78
174
  ## Application (step-by-step)
79
175
 
80
- 1. **Detect input types present** — text, image, figma-link, or any combination. Branch accordingly:
81
- - **Single source** → process as before.
82
- - **Mixed sources** → run the "Mixed inputs" protocol above, including source-priority lookup and explicit conflict detection BEFORE drafting.
83
- 2. **Intake gap check** — invoke `[[clarification-questions]]`. If it returns BLOCKING questions, **ask first** before drafting.
84
- 3. **Detect language** of input (es | en | other). Output in the input language.
85
- 4. **Draft skeleton** of the structured story (all 15 sections from the template).
86
- 5. **Fill the CORE first** (always required, in order):
87
- 1. **Title** — concise, ≤8 words.
88
- 2. **Summary** — single value-focused sentence ("Enable Google login for trial users to reduce signup friction"), NOT a feature label ("Add Google button"). Elevator pitch.
89
- 3. **User Story** (As a / I want to / so that).
90
- - **Persona check:** if role is "user" or "customer", push for sharper ("trial user", "Workspace admin"). Generic personas hide motivation.
91
- - **"So that" check:** outcome must be distinct from action. "So I can save my work" = restating; "So I don't lose progress if tab crashes" = real motivation.
92
- 4. **Acceptance Criteria** via `[[acceptance-criteria]]` — at minimum the happy path + one failure mode.
93
- 5. **Definition of Done** via `[[definition-of-done]]`.
94
-
95
- 6. **Fill OPTIONAL sections only if they have real content.** Drop any that would be empty or boilerplate:
96
- - Contexto / Business goal — include when there's a stated trigger or KPI
97
- - Scope / Out of scope — include when boundaries are non-obvious
98
- - `[[business-rules]]` — include when invariants exist beyond the ACs
99
- - Technical considerations — include when surface/SDK/flag matters
100
- - `[[edge-cases]]` — include when ≥3 high-impact edges exist
101
- - `[[analytics-events]]` — include when story has measurable funnel
102
- - `[[risks-and-dependencies]]` — include when there are real blockers or unknowns
103
-
104
- The bias is **less is more**. A clean 4-section story beats a 15-section one full of `N/A`.
105
- 6. **Run INVEST self-check** via `[[invest-checklist]]`:
106
- - `READY` → continue.
107
- - `NOT A STORY` (V failed) → STOP. Tell the user this is a tech task, not a user story. Suggest reframing or combining with user-facing work.
108
- - `NEEDS REFINEMENT` (T or N failed) → revise the failing sections in place.
109
- - `RUN A SPIKE` (E failed on unknowns) → recommend a 1–2 day investigation; do not split or generate yet.
110
- - `SPLIT RECOMMENDED` (I, E, or S failed) → STOP. Hand off to `[[story-split]]`. **Never auto-split.**
111
- 7. **Render outputs** via `[[jira-wiki-formatter]]`:
112
- - `story.jira-wiki.md` — Jira wiki markup
113
- - `story.standard.md` — CommonMark
114
- 8. **If clarifications remain unresolved** (user skipped them, or low-confidence visual inferences exist):
115
- - Emit `clarifications.md` with the outstanding questions
116
- - Mark the story output with a `DRAFT` banner at the top
117
- - Tell the user explicitly what would unblock promoting from DRAFT to READY
118
- 9. **Present both artifacts** as fenced code blocks. Ask the user whether to save to disk (offer paths under `./stories/<slug>/`).
176
+ 0. **Detect input types** — text / image / figma-link / combination. Run conflict detection (rule 10) BEFORE drafting. Run chrome detection (rule 7).
119
177
 
120
- ## Examples
178
+ 1. **Read prior context.** If `<output-folder>/.storywright-context.json` exists (exact folder only), load it.
121
179
 
122
- ### Good text prompt
123
- Input: *"Permitir login con Google"*
180
+ 2. **Language resolution** (rule 4 + 4a). Auto-detect using expanded signals; ask only on split.
124
181
 
125
- Flow:
126
- 1. Run gap check → 3 BLOCKING questions: scope of accounts, account linking, surface (web/mobile/both).
127
- 2. Ask the 3 questions, wait for answers.
128
- 3. Draft + fill all 15 sections.
129
- 4. INVEST → `READY`.
130
- 5. Render both outputs.
131
- 6. Done.
182
+ 3. **Persona sharpening.** If persona is "user" / "customer" / "person", ask via `AskUserQuestion` for the specific role (e.g., "Sales person", "Workspace admin"). Generic personas hide motivation.
132
183
 
133
- ### Good image input
134
- Input: screenshot of a dashboard with a filter sidebar.
184
+ 4. **Passive-goal check (rule G).** If `I want to` verb is observational + `so that` lacks downstream action → ask once.
135
185
 
136
- Flow:
137
- 1. Vision: extract filter categories, infer apply/reset actions.
138
- 2. Confidence on "filters persist across navigation" → MEDIUM → mark as `⚠️ Assumed` and surface in clarifications.
139
- 3. Run gap check → 1 BLOCKING (does this replace or augment current filters?).
140
- 4. Ask, draft, fill, INVEST, render.
186
+ 5. **Gap-check** via `[[clarification-questions]]`. BLOCKING gaps → `AskUserQuestion` batched ≤4. Non-blocking → fill inline `⚠️ Assumed`.
141
187
 
142
- ### Bad
188
+ 6. **Deterministic pre-split test.** Count outcomes using the same rule as `[[story-refine]]`:
189
+ - +1 per AC bullet with action verb at user level
190
+ - +1 per distinct `When [event]`
191
+ - +1 per named UI surface with its own user goal (rule D)
192
+ - 0 for styling, sub-components, passive layout assertions
193
+ - Count ≥2 → STOP. Recommend `/story-split`. List candidate children + per-pair dep notes (rule A) + V audit (rule C from refine).
143
194
 
195
+ 7. **Draft the canonical block** (Use Case + AC + Design Ref + INVEST). Preserve user wording where good.
196
+
197
+ 8. **Run INVEST** via `[[invest-checklist]]`.
198
+ - `READY` → render.
199
+ - `SPLIT RECOMMENDED` → STOP, recommend split.
200
+ - `NEEDS REFINEMENT` → iterate failing dimension, max 1 cycle, then STOP.
201
+ - `NOT A STORY` → tell user it's a tech task and stop.
202
+
203
+ 9. **Render** both outputs via `[[jira-wiki-formatter]]`. Files: `story.standard.md` + `story.jira-wiki.md`. Plus `.storywright-context.json`. No other files.
204
+
205
+ 10. **Generation log** ≤3 bullets (≤5 if SPLIT) at end of story.
206
+
207
+ ## Examples
208
+
209
+ ### Good — text prompt
210
+ Input: *"Permitir login con Google"*
211
+ 1. Language auto-detect → ES (persona "usuario", verbs "permitir").
212
+ 2. Persona sharpening → ask: trial user? admin? signed-out visitor?
213
+ 3. Pre-split count = 1 (one auth flow). Continue.
214
+ 4. Draft Use Case + 1 AC (happy path, failure as `and Given`).
215
+ 5. INVEST → READY.
216
+ 6. Render.
217
+
218
+ ### Good — image input
219
+ Input: dashboard screenshot with filter sidebar.
220
+ 1. Vision extracts filters; one inference at MEDIUM confidence → mark `⚠️ Assumed` inline.
221
+ 2. Pre-split count = 1 (one filter interaction surface).
222
+ 3. Draft + INVEST → READY.
223
+
224
+ ### Good — passive-goal prompt fires
225
+ Input: "As a user, I want to view list of customers, so that I find details."
226
+ - Detected: `view` (passive) + thin `so that`.
227
+ - Ask: "What does the user do with the customer they find?"
228
+ - User: "Call them."
229
+ - Refined `so that`: "so that I can find and call a customer to schedule a service."
230
+
231
+ ### Bad — broad input drafted as one story
144
232
  Input: *"Build the new dashboard"*
233
+ - Pre-split count ≥2 → STOP. Recommend `/story-split`. Do NOT draft a 15-section story.
145
234
 
146
- Don't draft. The scope is too broad. Run gap check → propose splitting into smaller stories at the **clarification step**, before the story is drafted. (Effectively delegates to `[[story-split]]` upfront.)
235
+ ### Bad clarifications.md
236
+ Writing any sidecar question file. Violates rule 1.
237
+
238
+ ### Bad — per-claim visual tag
239
+ `[mockup-pixel-derived]` on every line instead of the single banner. Violates rule 5.
147
240
 
148
241
  ## Common Pitfalls
149
242
 
150
- - Drafting before asking the critical questions. Always run intake first.
151
- - Ignoring confidence in image inferences. If you guessed, say so.
152
- - Auto-splitting. Never. Propose, wait, then split.
153
- - Mixing English and Spanish in the output. Pick the input language.
154
- - Skipping the `clarifications.md` file when assumptions remain.
243
+ - Drafting before running the deterministic split gate (step 6).
244
+ - Auto-splitting. Never. Propose, wait for `/story-split`.
245
+ - Mixing languages. Pick one via rule 4 + 4a.
246
+ - Re-asking questions already resolved in `.storywright-context.json`.
247
+ - Letting per-claim `[mockup-pixel-derived]` tags litter the output.
248
+ - Treating image visual specs as authoritative without the rule-5 banner.
155
249
 
156
250
  ## References
157
251
 
158
- - [[story-refine]] (use when input is an existing story to improve)
159
- - [[story-split]] (use when INVEST fails on Independent/Estimable/Small)
160
- - [[story-from-figma]] (use when input is a Figma link)
252
+ - [[story-refine]] (when input is an existing story)
253
+ - [[story-split]] (when INVEST fails on I/E/S)
254
+ - [[story-from-figma]] (when input is Figma URL)
161
255
  - [[clarification-questions]]
162
256
 
163
- ## Output templates
164
-
165
- See `templates/story.jira-wiki.md` and `templates/story.standard.md` in this skill's folder for the canonical section ordering and formatting.
166
-
167
257
  <claude-specific>
168
- - Use extended thinking for INVEST check and for vision confidence scoring.
169
- - Cache the 15-section taxonomy and component invocation order across calls.
170
- - When input includes images, attach them to the same message as the prompt to use Claude's native vision (do not describe-then-reason in two steps).
171
- - Use prompt caching on the component skill bodies (they're long and reused).
258
+ - Use extended thinking for INVEST + pre-split counting.
259
+ - Attach images in the same message for native vision; don't describe-then-reason in two steps.
260
+ - Read `.storywright-context.json` ONLY from the exact target output folder.
261
+ - Never call Write for any sidecar question file. Use `AskUserQuestion`.
262
+ - Treat step 6 (deterministic pre-split test) as a hard gate; do not skip even when the user wants a single story.
172
263
  </claude-specific>