vinta-ai-workflows 0.1.7

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +830 -0
  2. package/LICENSE +21 -0
  3. package/README.md +547 -0
  4. package/package.json +27 -0
  5. package/schemas/README.md +84 -0
  6. package/schemas/mcp-preflight-cache.v1.schema.json +50 -0
  7. package/schemas/prs-context-comments.v1.schema.json +51 -0
  8. package/schemas/prs-context-frontmatter.v1.schema.json +77 -0
  9. package/schemas/sub-agent.v1.schema.json +105 -0
  10. package/schemas/vinta-ai-workflows-config.v1.schema.json +283 -0
  11. package/skills/vinta-analyze-codebase/SKILL.md +325 -0
  12. package/skills/vinta-bootstrap-ai-tools/SKILL.md +375 -0
  13. package/skills/vinta-bootstrap-ai-tools/resources/stacks/README.md +50 -0
  14. package/skills/vinta-bootstrap-ai-tools/resources/stacks/django/notes.md +52 -0
  15. package/skills/vinta-bootstrap-ai-tools/resources/stacks/medplum/notes.md +45 -0
  16. package/skills/vinta-bootstrap-ai-tools/resources/stacks/nextjs-app-router/notes.md +35 -0
  17. package/skills/vinta-bootstrap-ai-tools/resources/stacks/python-package/notes.md +31 -0
  18. package/skills/vinta-bootstrap-ai-tools/resources/stacks/typescript-monorepo/notes.md +32 -0
  19. package/skills/vinta-derive-skills/SKILL.md +200 -0
  20. package/skills/vinta-derive-skills/resources/amend-plan-template.md +355 -0
  21. package/skills/vinta-derive-skills/resources/foundation-skills/add-one-off-script/SKILL.md +292 -0
  22. package/skills/vinta-derive-skills/resources/foundation-skills/add-one-off-script/resources/one_off_script_base.py +602 -0
  23. package/skills/vinta-derive-skills/resources/foundation-skills/add-one-off-script/resources/one_off_script_base.ts +624 -0
  24. package/skills/vinta-derive-skills/resources/foundation-skills/create-qa-use-cases/SKILL.md +232 -0
  25. package/skills/vinta-derive-skills/resources/foundation-skills/create-spec/SKILL.md +235 -0
  26. package/skills/vinta-derive-skills/resources/foundation-skills/open-pr-from-context/SKILL.md +78 -0
  27. package/skills/vinta-derive-skills/resources/foundation-skills/open-pr-from-context/scripts/open-pr.sh +357 -0
  28. package/skills/vinta-derive-skills/resources/foundation-skills/plan-feature/SKILL.md +418 -0
  29. package/skills/vinta-derive-skills/resources/implement-plan-template.md +375 -0
  30. package/skills/vinta-derive-skills/resources/prs-context-template.md +91 -0
  31. package/skills/vinta-derive-skills/resources/systematic-debugging-mcp-tools.md +125 -0
  32. package/skills/vinta-derive-skills/resources/systematic-debugging-template.md +167 -0
  33. package/skills/vinta-derive-subagents/SKILL.md +192 -0
  34. package/skills/vinta-install-ai-tools-setup/SKILL.md +138 -0
  35. package/skills/vinta-install-ai-tools-setup/resources/setup-ai-tools.mjs +392 -0
  36. package/skills/vinta-migrate-plans-specs/SKILL.md +229 -0
  37. package/skills/vinta-sync-ai-tools/SKILL.md +184 -0
  38. package/skills/vinta-update-project-skills/SKILL.md +178 -0
  39. package/skills/vinta-write-agents-md/SKILL.md +192 -0
  40. package/vinta-ai-workflows.mjs +316 -0
@@ -0,0 +1,232 @@
1
+ ---
2
+ name: create-qa-use-cases
3
+ description: Bootstrap a project's `QA_USE_CASES.md` from scratch using the canonical pattern (immutable PA###/PR### ids, role table, per-app numbered sections with role-tagged checklists). Invoked from inside [plan-feature](../plan-feature/SKILL.md) when the project has no `QA_USE_CASES.md` yet — the active feature's spec + plan are already in hand. Seeds the file with use cases from those two documents only; does not sweep prior plans. Asks the user for the few gaps spec/plan don't answer (app boundaries, role list, prefix conventions). Project-agnostic — works in any repo that adopts this skill set.
4
+ ---
5
+
6
+ # Bootstrap `QA_USE_CASES.md`
7
+
8
+ The doc maps 1:1 to e2e test specs by an immutable id. It's the QA team's manual-test checklist and the spec filename source of truth. [add-e2e-test](../add-e2e-test/SKILL.md) appends entries; this skill creates the file the first time, **seeded from the active feature** that triggered the bootstrap.
9
+
10
+ ## When to use
11
+
12
+ - Project has no `QA_USE_CASES.md` at the repo root.
13
+ - [plan-feature](../plan-feature/SKILL.md) is in flight for a specific feature — its spec + plan are the seed material.
14
+ - A UI-flow phase in that plan needs an e2e id but the file doesn't exist yet.
15
+
16
+ If `QA_USE_CASES.md` already exists, **do not overwrite**. Stop and route the user to [add-e2e-test](../add-e2e-test/SKILL.md) for appending entries. Bootstrap is one-shot.
17
+
18
+ ## Source: the active feature only
19
+
20
+ This skill runs **inside** the plan-feature flow, so the active spec + plan are already loaded into the conversation. Seed the file from those two documents — **do not** sweep `ai-plans/` for prior specs. Older features that pre-date this doc will be added later via [add-e2e-test](../add-e2e-test/SKILL.md) as they need test coverage; bootstrapping with the entire history is noise.
21
+
22
+ Extract from the active feature's docs:
23
+
24
+ 1. **Use cases** from the spec's **Decisions → Use-cases** section (one PA/PR entry per user-facing flow). UI-affecting phases from the plan's **Phased Rollout** that aren't already in the spec's **Use-cases** get an entry too.
25
+ 2. **Role list** from the spec's **Business Context** / **Decisions → Use-cases** actors + the plan's **Guiding Decisions**.
26
+ 3. **App boundaries** if the spec/plan name them; otherwise ask.
27
+
28
+ If invoked standalone (not from plan-feature), ask the user *"Which spec + plan should I seed from?"* via `AskUserQuestion` and load only those two files. Don't go fishing.
29
+
30
+ ## Decision questions
31
+
32
+ For everything **not** answered by the active spec/plan, ask via `AskUserQuestion`. Closed-form questions go through the tool; open narrative questions iterate one at a time. Same convention as [plan-feature](../plan-feature/SKILL.md) and [create-spec](../create-spec/SKILL.md).
33
+
34
+ ### Questions to ask (skip when source docs answer)
35
+
36
+ **A. App boundaries**
37
+ 1. How many apps does this project have, and what are their names? (e.g. `Patient App`, `Provider App`, `Admin Console`, single SaaS app named `<Product>`.)
38
+ 2. ID prefix per app — typically a 2-letter abbreviation. Defaults: `PA` for "patient/public app", `PR` for "provider/admin app". Confirm or override.
39
+ 3. Does any app have unauthenticated routes that need use-case entries (registration, public referral, marketing landing)? Those entries note `(unauthenticated)` in the role.
40
+
41
+ **B. Roles**
42
+ 1. List of roles that perform actions in any app. Each role: name + which app(s) it logs into + one-sentence description.
43
+ 2. Is there an "Admin" or "Super-Admin" role distinct from regular users? Many projects' permission docs distinguish project-admin (`ProjectMembership.admin === true`) from role-coded admins — both belong in the table if both exist.
44
+ 3. Are external actors (referring providers, integration partners) ever actors in a use case? Note as `(unauthenticated)` or `(external — no login)`.
45
+
46
+ **C. Active-feature coverage**
47
+ 1. From the active spec + plan, here's the use-case list I extracted: `<list>`. Anything missing or mis-scoped? (`AskUserQuestion` with `Looks good` / `Some corrections (I'll list)` / `More to add` / `Stop, rethink`.)
48
+ 2. For each use case, who's the role? If the source says "Care Coordinator, Physician" pick one default and note the others. Multi-role use cases are normal — comma-separate them in the entry.
49
+
50
+ **D. ID assignment**
51
+ 1. Order: append in the order use cases appear in the active spec (**Decisions → Use-cases** first, then any plan-only phases). Don't reshuffle.
52
+ 2. Default starting numbers `PA001` / `PR001`. Confirm or override.
53
+
54
+ ### Clarity loop
55
+
56
+ Same as the other interview skills. After each `AskUserQuestion` round, re-scan: did the answer reveal a new role? A use case that needs splitting? An app boundary I missed? Open another batch. Exit conditions:
57
+
58
+ - Every app named + prefix assigned.
59
+ - Every role listed with app + description.
60
+ - Every spec use case mapped to one or more roles + assigned an id.
61
+ - No "we'll figure that out later" in the role table — that's a live ambiguity, ask now.
62
+
63
+ Final read-back via `AskUserQuestion`: *"Anything I got wrong before I write the file?"* with `Looks good` / `Some corrections (I'll list)` / `More to clarify` / `Stop, rethink`. Only write on `Looks good`.
64
+
65
+ ## File structure (canonical)
66
+
67
+ ```markdown
68
+ # {Project Name} Use Cases
69
+
70
+ IDs (`PA###` for {patient app name}, `PR###` for {provider app name}) are immutable. When
71
+ adding a new use case, pick the next unused number — never reshuffle, renumber,
72
+ or reuse a retired ID. The e2e spec filenames mirror these IDs one-to-one.
73
+
74
+ ## Roles
75
+
76
+ | Role | App | Description |
77
+ |------|-----|-------------|
78
+ | **{Role 1}** | {App} | {One-sentence description} |
79
+ | **{Role 2}** | {App} | {…} |
80
+ | …
81
+
82
+ ---
83
+
84
+ ## {Patient / First App}
85
+
86
+ ### PA001. {Use Case Title}
87
+
88
+ **Role:** {Role(s) — comma-separated if multi-role; add `(unauthenticated)` for public flows}
89
+
90
+ - [ ] {First step the user takes}
91
+ - [ ] {Next step}
92
+ - [ ] {Verify {observable outcome}}
93
+ - {Sub-bullet for branched outcomes — e.g. eligible vs ineligible paths}
94
+
95
+ ### PA002. {…}
96
+
97
+ …
98
+
99
+ ---
100
+
101
+ ## {Provider / Second App}
102
+
103
+ ### PR001. …
104
+
105
+ …
106
+ ```
107
+
108
+ ### Step-list rules per entry
109
+
110
+ - **Verb-led, present tense.** "Navigate to /settings", "Click Save", "Verify the success toast appears". Not "User navigates", not "Should click".
111
+ - **Checkboxes (`- [ ]`)** because the doc doubles as a manual-test checklist. QA ticks them off in PRs.
112
+ - **One observable assertion per branch.** "Verify eligibility result: If eligible → redirected to /onboarding. If ineligible → error message shown." Mirrors how the e2e spec is structured.
113
+ - **Reference URL paths exactly** as the app routes them (`/settings`, `/onboarding/{uniqueId}`). Reviewer can follow without context.
114
+ - **Never include implementation details.** No domain model names, API endpoints, table names, or library specifics. Doc is read by QA, product, support — keep it user-language.
115
+
116
+ ### Multi-app projects
117
+
118
+ - One `## ` section per app, separated by `---`.
119
+ - Section heading = exact app name as it appears in the role table.
120
+ - Prefix per app is consistent within the section: PA-section uses `PA001…`, PR-section uses `PR001…`.
121
+ - Don't interleave apps under one section.
122
+
123
+ ### Single-app projects
124
+
125
+ Skip the `---`-separated sections. Single `## Use Cases` heading, one prefix (e.g. `UC001`).
126
+
127
+ ## Checklist
128
+
129
+ ### 1. Confirm no existing file
130
+
131
+ If `QA_USE_CASES.md` exists at repo root, **stop**. Tell the user the file already exists and route them to [add-e2e-test](../add-e2e-test/SKILL.md) for appending. Bootstrap doesn't merge or migrate — that's manual work, not a skill output.
132
+
133
+ ### 2. Pull from the active spec + plan only
134
+
135
+ The active feature's spec + plan are already in the conversation (handed in by [plan-feature](../plan-feature/SKILL.md), or pointed to by the user when invoked standalone). Extract:
136
+ - Use cases from the active spec's **Decisions → Use-cases**.
137
+ - UI-facing phases from the active plan's **Phased Rollout** that aren't already in the spec's **Use-cases**.
138
+ - Roles from the active spec's **Business Context** / **Decisions → Use-cases** actors.
139
+
140
+ **Do not** sweep `ai-plans/` for older specs. Pre-existing features that pre-date the doc get added later via [add-e2e-test](../add-e2e-test/SKILL.md) when they need test coverage.
141
+
142
+ ### 3. Run the interview
143
+
144
+ Ask only for what the source docs don't already answer. Closed-form via `AskUserQuestion` (batched per group). Open-ended (extra context, narrative) iterate one at a time. Read back, confirm, loop until stable.
145
+
146
+ ### 4. Write the file
147
+
148
+ Output to repo root: `QA_USE_CASES.md`. Use the canonical structure above. Plug in:
149
+ - Project name in the title.
150
+ - App names in the section headings + the immutable-ids note.
151
+ - Role table with every role from the interview.
152
+ - Numbered entries, ids in source-doc order, role line, step checklist.
153
+
154
+ ### 5. Tell the user what's next
155
+
156
+ After writing:
157
+ - Point to [add-e2e-test](../add-e2e-test/SKILL.md) for adding e2e specs that mirror these ids.
158
+ - If [plan-feature](../plan-feature/SKILL.md) is in flight, remind the user that each UI-flow phase needs an entry here matched 1:1 to the spec it ships.
159
+ - If new use cases come up later, append — never insert in the middle, never renumber.
160
+
161
+ ## Worked example (for shape only — not actual content)
162
+
163
+ ```markdown
164
+ # Acme Sleep Use Cases
165
+
166
+ IDs (`PA###` for Patient App, `PR###` for Provider App) are immutable. When
167
+ adding a new use case, pick the next unused number — never reshuffle, renumber,
168
+ or reuse a retired ID. The e2e spec filenames mirror these IDs one-to-one.
169
+
170
+ ## Roles
171
+
172
+ | Role | App | Description |
173
+ |------|-----|-------------|
174
+ | **Patient** | Patient App | End-user receiving sleep care services |
175
+ | **Provider: Care Coordinator (RN)** | Provider App | Coordination + admin |
176
+ | **Provider: Physician (MD)** | Provider App | Clinical authority |
177
+ | **Provider: Clinical Ops (Admin)** | Provider App | System administrator |
178
+
179
+ ---
180
+
181
+ ## Patient App
182
+
183
+ ### PA001. Self-Referral Registration
184
+
185
+ **Role:** Patient (unauthenticated)
186
+
187
+ - [ ] Navigate to the landing page
188
+ - [ ] Click "Register"
189
+ - [ ] Fill out the self-referral intake form
190
+ - [ ] Submit
191
+ - [ ] Verify eligibility:
192
+ - If eligible: redirected to `/onboarding/{uniqueId}`
193
+ - If ineligible: error message shown with "Go Back" option
194
+
195
+ ### PA002. …
196
+
197
+ ---
198
+
199
+ ## Provider App
200
+
201
+ ### PR001. Provider Sign In
202
+
203
+ **Role:** All Providers
204
+
205
+ - [ ] Navigate to the provider app landing page
206
+ - [ ] Click "Sign In"
207
+ - [ ] Enter credentials
208
+ - [ ] Verify redirect to the patient list
209
+ ```
210
+
211
+ ## Pitfalls
212
+
213
+ - **Overwriting an existing file.** Bootstrap is one-shot. If the file exists, append via add-e2e-test, don't regenerate — existing ids are referenced by spec filenames + bug tickets and can't move.
214
+ - **Inventing use cases from project name alone.** If the spec/plan doesn't describe a flow, don't add a stub. Empty checklist + no real flow = noise. Ask the user; if they don't have one, leave it out.
215
+ - **Mixing role-coded admin with project-admin.** Many systems have both (a "Clinical Ops" role + a flag like `ProjectMembership.admin === true`). List both rows in the role table if both apply — they map to different storage states / permission paths in tests.
216
+ - **Putting implementation details in steps.** "Create QuestionnaireResponse with linkId=first-name" reads to QA as gibberish. "Fill out the intake form" is the right level. Implementation details belong in the e2e spec or seed helper, not here.
217
+ - **Numbering by importance.** Numbers reflect order of arrival, not priority. PA047 isn't more important than PA003 — it just came later. Don't try to keep "core" use cases at low numbers; that path leads to renumbering.
218
+ - **Skipping the `(unauthenticated)` annotation.** Public flows (registration, password reset, public referral) need it explicitly so reviewers know which storage state the e2e spec uses.
219
+ - **Sweeping `ai-plans/` for older specs.** This skill seeds from the **active feature only**. Backfilling the doc with every historical feature creates phantom test obligations. Pre-existing features get added later via [add-e2e-test](../add-e2e-test/SKILL.md) when they actually need coverage.
220
+ - **Generating without reading the active spec/plan.** The whole point is to inherit decisions, not re-derive them. If the active spec/plan are visible, read them. If they aren't, ask the user to point at them — don't guess.
221
+
222
+ ## Verification
223
+
224
+ After writing the file:
225
+
226
+ 1. Open it. Render in a markdown previewer — table renders, sections appear in order, no broken markdown.
227
+ 2. Cross-check: every use case from every spec's **Decisions → Use-cases** appears as a numbered entry. None missing.
228
+ 3. Cross-check: every role mentioned anywhere in the entries appears in the role table.
229
+ 4. Cross-check: ids start at `001` per app prefix, ascend with no gaps.
230
+ 5. Run `grep -c '^### P[AR][0-9]' QA_USE_CASES.md` — count matches your interview tally.
231
+
232
+ If [plan-feature](../plan-feature/SKILL.md) is in flight, the next step is creating one e2e spec per UI-flow phase — see [add-e2e-test](../add-e2e-test/SKILL.md). Each spec filename mirrors the id you just assigned.
@@ -0,0 +1,235 @@
1
+ ---
2
+ name: create-spec
3
+ description: Turn raw feature prompt into structured spec doc at `ai-plans/YYYY-MM-DD-FEATURE_NAME_SPEC.md`. Sections fixed — Business Context, Hypothesis, Objectives, Decisions (Use-cases / State transitions & edge cases / Acceptance scenarios / Negative scope), Alternatives considered (optional), Open questions, Risks assumed. Use when user asks "write a spec", "draft a spec doc", "turn this idea into a spec", or hands one-line / paragraph feature description needing structure before plan. Skill ALWAYS interviews requester before drafting — never turn vague prompt into plausible-sounding spec by guessing.
4
+ ---
5
+
6
+ # Spec Document
7
+
8
+ Spec **frame problem + solution boundaries** before plan. Precedes [plan-feature](../plan-feature/SKILL.md): spec answer *"what + why?"*; plan answer *"how, in what order, with what tests"*. Different artefact, different audience (spec → product + eng leadership; plan → implementer).
9
+
10
+ Output: `ai-plans/YYYY-MM-DD-FEATURE_NAME_SPEC.md` (uppercase + underscores, today date prefix). Structure fixed; content from interview, not inference.
11
+
12
+ ## Step 0 — Interrogate before drafting (NON-NEGOTIABLE)
13
+
14
+ Biggest failure: AI take one-liner ("add tags to orders") + confidently produce three pages of plausible-sounding context, hypothesis, acceptance criteria requester didn't say. **Don't.** Even when prompt look self-explanatory, ask. Even when answer feel obvious — your "obvious" is training-data average; theirs is *their* business.
15
+
16
+ Ask below in batched, numbered chunks. Skip group only when prompt **explicitly** answers it; never because you can plausibly fill in.
17
+
18
+ For finite-set answers, **list options**. Provide one-sentence **why** so they understand implications.
19
+
20
+ ### Use `AskUserQuestion` for finite-choice questions
21
+
22
+ Every interview question with discrete answer set — yes/no, named option, finite enum, hypothesis-vs-known-requirement, idempotency mode, concurrency rule — **must** issue via `AskUserQuestion` tool. Use plain prose only when answer genuinely open-ended (problem narrative, walking through journey, free-form motivation, hard deadline date).
23
+
24
+ Pattern per group:
25
+
26
+ - One `AskUserQuestion` call per group, batch multiple questions into same call when tool supports (each question carry own option set).
27
+ - Short label per option; rationale ("default: per-user — confirm or override") goes in question header, not option label.
28
+ - Open-ended sub-questions in same group → fall back to plain prose for those, send closed-form ones via `AskUserQuestion`. Don't force finite list when genuinely free text.
29
+
30
+ If `AskUserQuestion` in deferred-tool list + not yet schema-loaded, call anyway — tool name fixed + harness surfaces it. **Never** flatten ten questions into one prose paragraph because tool not pre-loaded; that failure mode this skill exists to prevent.
31
+
32
+ ### Clarity loop — keep asking until done
33
+
34
+ Step 0 isn't one-pass. After each round of answers, **scan for new gaps**: contradictions between answers, follow-ups one answer surfaces, decisions left vague another decision depends on. Open another batch for those. Repeat.
35
+
36
+ Loop exit conditions (all required):
37
+ - Every group A–I either fully answered or explicitly waived.
38
+ - Every answer's downstream questions also asked + answered.
39
+ - No "we'll figure that out later" — that's **Open questions** material; either has recommended default + owner + unblock condition, or resolved now.
40
+ - Can write each **Decisions → Use-cases** entry (actor + trigger + flow + outcome) without inventing.
41
+ - Can write **Decisions → Acceptance scenarios** without making up Given/When/Then.
42
+
43
+ Any condition fails → another `AskUserQuestion` round. Don't shortcut to drafting just because you've done one batch.
44
+
45
+ After answers stabilize: **read back one-paragraph summary** of every load-bearing decision. Then issue one final `AskUserQuestion` — single question *"Anything I got wrong before I draft?"* with options `Looks good`, `Some corrections (I'll list)`, `More to clarify`, `Stop, rethink`. `More to clarify` → another loop iteration. Only draft when user picks `Looks good`.
46
+
47
+ User say *"just write the spec, I'll fix it"*: comply but mark every unverified inference under **Open questions** (preferred) or **Risks assumed** (when guess about how world is). Don't let assumptions hide inside Business Context or Decisions.
48
+
49
+ ### A — Problem & customer
50
+
51
+ 1. **Problem we solving — for whom?** Specific actor: tenant admins editing orders, ops staff fixing data, end users in dashboard, external integration partners, internal team.
52
+ *Why: "the customer" rarely single bucket; mixing them = optimize wrong workflow.*
53
+ 2. **What customer do today?** Manual workaround, support ticket, doesn't bother, leaves platform — name path + pain.
54
+ *Why: no current pain → no demand to validate. "Leaves platform" different objective than "saves 10 minutes/week".*
55
+ 3. **Cost today?** Lost revenue, support volume, churn risk, manual hours, compliance risk, integration breakage. Rough estimate fine.
56
+ *Why: becomes success metric in **Objectives**. Without it, "did this work?" has no answer.*
57
+ 4. **Who else care about this landing?** Other teams, integration partners, support, sales engineering, named stakeholder. Anyone who block rollout if not looped in.
58
+ *Why: surface hidden veto points before plan written.*
59
+
60
+ ### B — Hypothesis (falsifiable)
61
+
62
+ 1. **Change in behavior or metric expected?** State as `if we do X, then Y will improve by Z (within timeframe)`. Metric doesn't move → what tells us we wrong?
63
+ *Why: spec without falsifiable hypothesis = wish list. plan-feature requires this for rollout/soak window.*
64
+ 2. **Hypothesis or known requirement?**
65
+ - **Hypothesis** — "we think this improves X, but unsure". Validation matter; may roll back.
66
+ - **Known requirement** — "must do for compliance / customer / deadline". Correctness + timing matter, not validation.
67
+ - **Mixed** — both gates apply.
68
+ *Why: hypothesis-driven features need smaller gated rollouts + explicit kill criteria; known requirements need scope discipline + deadline awareness instead.*
69
+ 3. **What "validated" look like — concrete signal, source, threshold?** *(Hypothesis only.)* E.g. "support ticket volume drops 50% in 60 days, measured in Zendesk tag X".
70
+ *Why: vague "we'll see" doesn't survive contact with reality. Naming source up front prevent post-hoc cherry-picking.*
71
+ 4. **Failed validation — what then?** Roll back, iterate, accept + move on, deprecate?
72
+ *Why: force commitment to kill criterion before sunk-cost kicks in.*
73
+
74
+ ### C — Use cases
75
+
76
+ 1. **Walk through 1–3 concrete user journeys** end-to-end. Concrete: who initiate, what they click/send, what they see back, what side-effects fire.
77
+ *Why: abstract descriptions miss conditions making features hard. Concrete journeys force decisions about ordering, defaults, error states.*
78
+ 2. **Integration-driven (no human) flows hitting same path?** Webhook from upstream SaaS, scheduled function, batch import.
79
+ *Why: flows working for humans often break for integrations (omit-vs-empty, retry semantics, idempotency).*
80
+ 3. **Alternative entry points?** UI button + API + admin + Slack — anywhere same feature reachable.
81
+ *Why: each entry point may need own permissions, validation, audit log.*
82
+
83
+ ### D — State, edges, idempotency
84
+
85
+ 1. **States / lifecycle?** Name them + allowed transitions. Sketch as `Draft → Active → Archived` if unsure.
86
+ *Why: most "small" features turn out to have state machine. Drawing it out reveal forbidden transitions needing explicit handling.*
87
+ 2. **Edge cases, even half-formed?** Empty inputs, deleted parents, concurrent edits, partial failures, stale data, duplicates, oversized payloads, very-many-of-X.
88
+ *Why: requester know their business; their "weird thing once a month" exactly where bug live.*
89
+ 3. **Idempotency**: same request twice (retry, double-click, replay)?
90
+ - **Idempotent** — second is no-op, final state matches.
91
+ - **Append/duplicate** — only OK when duplicates are desired semantic (logging clicks).
92
+ - **Reject** — second errors with "already done".
93
+ *Why: most APIs here idempotent by default (bulk-upsert with last_updated_at guard). Drift cause data corruption expensive to recover.*
94
+ 4. **Concurrency**: two actors hit simultaneously on same entity? Resolution: last-write-wins, first-write-wins, optimistic lock with conflict surfaced?
95
+ *Why: silent last-write-wins eat user work; surface explicitly.*
96
+ 5. **Time-bounded behavior**: TTL, expiry, soak window, scheduled re-evaluation, "if user doesn't act within X, do Y"?
97
+ *Why: time-based rules need explicit specs or become invisible bugs.*
98
+
99
+ ### E — Acceptance scenarios
100
+
101
+ 1. **3–7 scenarios proving works**, in Given/When/Then form (or close — "if X, then Y"). At minimum:
102
+ - One happy path.
103
+ - One error / negative path (invalid input rejected with useful message).
104
+ - One edge case from D.
105
+ - One integration-driven flow if there is one.
106
+ *Why: become acceptance lines on plan phases + test matrix downstream.*
107
+
108
+ ### F — Negative scope
109
+
110
+ 1. **What might reasonable person assume in scope but you want excluded?** Be petty.
111
+ *Why: non-goals save most time. Without them, scope creep invisible until Phase 6.*
112
+ 2. **Deferred to v2 / v1.x?** Name each + reason (cost, complexity, no signal, blocked by something else).
113
+ *Why: deferred-with-reason only honest deferral. "Maybe later" usually mean "never, but I don't want to argue".*
114
+ 3. **What other systems / workflows should NOT change?** Existing endpoints whose contract must hold byte-for-byte, dashboards whose query shapes can't shift, integration payloads locked.
115
+ *Why: changes that look additive often touch shared infra. Calling out hands-off zones set rollback contract.*
116
+
117
+ ### G — Alternatives considered (optional)
118
+
119
+ 1. **What other approaches considered — why rejected?** Cost, risk, scope creep, doesn't solve real problem, regulatory blocker, unproven, vendor change. One sentence each.
120
+ *Why: make spec defensible six months later. No alternatives? Say so: "alternatives considered: none" valid signal.*
121
+
122
+ ### H — Constraints, deadlines, dependencies
123
+
124
+ 1. **Hard deadlines?** Compliance, customer commitments, partner integrations cutting over, regulatory window.
125
+ *Why: change urgency math; may force phases to overlap risk normally sequential.*
126
+ 2. **Existing systems / data we can't touch?** Frozen table, deprecated endpoint kept alive for one customer, contract under review.
127
+ *Why: usually appear as Phase-3 surprises.*
128
+ 3. **External dependencies** — integration partners (third-party SaaS APIs), other internal services / repos, other teams' deliverables. Who has to do what before this lands?
129
+ *Why: define deploy ordering. Spec ignoring slowest-moving dep ship late.*
130
+
131
+ ### I — Risks & assumptions
132
+
133
+ 1. **What could go wrong, how bad?** Migration data loss, user confusion, integration regression, perf regression on hot path, breakage of unrelated feature.
134
+ *Why: every spec has risks; question is which team willing to live with.*
135
+ 2. **What you assuming that might not hold?** "no tenant has more than 200 of these"; "integrations send X within 24h"; "schema can change without multi-step migration".
136
+ *Why: landmines if not surfaced. Once written, team can validate, design around, or accept.*
137
+ 3. **Reversibility**: roll back if goes badly? At what cost? One-way doors (DB migrations, breaking API changes, customer-visible names)?
138
+ *Why: shape rollout + feature-flag scope.*
139
+
140
+ After interview: read back load-bearing decisions in one paragraph (problem, customer, hypothesis or known-requirement framing, primary use cases, key states, hard deadlines, biggest risk). Ask *"anything I got wrong before I draft?"*. Only after explicit confirmation, write to disk.
141
+
142
+ ## Spec structure (fixed)
143
+
144
+ Use these sections in order. No new top-level sections. Skip only when genuinely doesn't apply (rare).
145
+
146
+ ```markdown
147
+ # {Feature Name} — Spec
148
+
149
+ ## 1. Business Context
150
+ The why. Customer, problem, cost of doing nothing, stakeholder pressure. Plain prose, 5–15 lines. Cite numbers when given; mark estimates as estimates.
151
+
152
+ ## 2. Hypothesis (to be validated)
153
+ Falsifiable: "if we do X, we expect Y to improve by Z within T". Known requirement instead? Say so: "Not a hypothesis — known requirement driven by {reason}". Don't skip; framing matters.
154
+
155
+ ## 3. Objectives (and how to validate Hypothesis)
156
+ Numbered. For each:
157
+ - Metric or signal that proves it.
158
+ - Data source.
159
+ - Threshold or direction of change.
160
+ - Timeframe to evaluate.
161
+ - Kill criterion (if hypothesis-mode): what counts as failed + what we do.
162
+
163
+ Known-requirement: replace "validate hypothesis" with "definition of done" — still concrete + measurable.
164
+
165
+ ## 4. Decisions
166
+ Resolved questions go here. Ambiguous → **Open questions** section.
167
+
168
+ ### 4.1 Use-cases
169
+ Numbered. Each: actor, trigger, flow (2–6 numbered steps), outcome.
170
+
171
+ ### 4.2 State transitions & edge cases
172
+ - State machine if any (lifecycle states, allowed/forbidden transitions).
173
+ - Edge cases from interview, each with decided handling.
174
+ - Idempotency rule.
175
+ - Concurrency rule.
176
+ - Time-bounded rules (TTL, expiry, soak windows).
177
+
178
+ ### 4.3 Acceptance scenarios
179
+ 3–7 Given/When/Then. Minimum: happy, error, edge, integration-driven (when applicable). Become plan's test matrix.
180
+
181
+ ### 4.4 Negative scope
182
+ Bulleted, one-line reason each: deferred to v2 (link if exists), unrelated workflow, hands-off contract. Be petty.
183
+
184
+ ## 5. Alternatives considered (optional)
185
+ Each: short paragraph, what it was, why rejected. None? Say so: "Alternatives considered: none — only viable path because {reason}." Don't omit silently.
186
+
187
+ ## 6. Open questions
188
+ Each: question, recommended default, who can answer, what unblocks if answered.
189
+
190
+ ## 7. Risks assumed
191
+ Bulleted. Each: risk, assumption (which if violated makes risk real), mitigation (or "accepted, no mitigation — see **Open questions**"), rough likelihood/severity (low/medium/high).
192
+ ```
193
+
194
+ ## Filename + date
195
+
196
+ `ai-plans/YYYY-MM-DD-FEATURE_NAME_SPEC.md`. Today's date ISO. `FEATURE_NAME` `UPPERCASE_WITH_UNDERSCORES`. Matching plan file use same prefix with `_IMPLEMENTATION_PLAN.md` so spec/plan pair groupable in `ls`.
197
+
198
+ ## Style rules
199
+
200
+ - **Plain English over jargon.** Read by product, design, sales engineering, on-call. Acronyms expanded on first use.
201
+ - **No code.** No SQL, migration snippets, class skeletons, JSON contracts beyond what customer literally agreed to. Code lives in plan. Exception: typed interface client team committed to (Bookmarks spec's `IBookmarkBarFolderItem` TypeScript) belongs in **Decisions → Use-cases** or **Decisions → Acceptance scenarios** — as literal contract, not implementation guidance.
202
+ - **No file paths or app names.** "We'll add this to `core/sales/models/order.py`" plan-level.
203
+ - **No estimates.** Sizing belongs in plan.
204
+ - **No marketing language.** "Seamlessly", "robust", "best-in-class", "delightful" — strike.
205
+ - **Decisions decided; assumptions flagged.** Solid-feeling but unverified → move to **Open questions** or **Risks assumed**.
206
+ - **One feature per spec.** Multiple loosely-coupled features → multiple specs.
207
+ - **Illustrate with examples + diagrams, not prose.** "For example, if tenant admin clicks 'Add tag' button on order details page, then..." better than "tenant admins should be able to add tags to orders in UI". State machine diagram better than "orders have lifecycle states: Draft, Active, Archived". Diagrams must use mermaidjs syntax to ensure stay up to date with reality.
208
+
209
+ ## Will not
210
+
211
+ - **Generate spec from one-liner without interviewing.** Even with 200 words pasted, interview still runs. Only override is explicit *"just write the spec, I'll fix it"*; then every assumption goes in **Open questions** or **Risks assumed**.
212
+ - **Use existing spec files in `ai-plans/` as structural templates.** Prior-art prompts, not specs in this skill's form. Read only if user explicitly asks.
213
+ - **Pre-decide implementation strategy.** Storage shape, partitioning, API surface, feature-flag mechanics — plan-level. Spec stops at "what" + "why".
214
+ - **Skip Open questions when real unknowns exist.** Spec with no open questions on non-trivial feature suspicious.
215
+ - **Pretty up rough thinking.** "I dunno, maybe we add tags" → don't paraphrase as "to enable tenants to enrich order metadata for downstream routing decisions". Either ask for the why or quote them: "Stated motivation: 'I dunno, maybe we add tags' — see **Open questions**, item 1."
216
+ - **Never use `§N` shorthand for section references.** Use section names verbatim — `Business Context`, `Hypothesis`, `Objectives`, `Decisions`, `Decisions → Use-cases`, `Decisions → Acceptance scenarios`, `Decisions → Negative scope`, `Alternatives considered`, `Open questions`, `Risks assumed`. `§4.3` makes the reader count headings and breaks when the spec evolves.
217
+
218
+ ## Checklist
219
+
220
+ - [ ] Step 0 interview run; load-bearing decisions echoed back; user confirmed before drafting.
221
+ - [ ] Filename: `ai-plans/{YYYY-MM-DD}-{FEATURE_NAME}_SPEC.md`.
222
+ - [ ] All seven sections in order.
223
+ - [ ] **Business Context** cites stakeholders + rough cost-of-doing-nothing.
224
+ - [ ] **Hypothesis** falsifiable — or known-requirement with driver named. Not silently both.
225
+ - [ ] **Objectives** has metric, source, threshold, timeframe, kill criterion (when hypothesis-mode).
226
+ - [ ] **Decisions → Use-cases** each: actor + trigger + step-by-step flow + outcome.
227
+ - [ ] **Decisions → State transitions & edge cases** covers state machine, edge cases, idempotency, concurrency, time-bounded rules where applicable.
228
+ - [ ] **Decisions → Acceptance scenarios** has 3–7 scenarios covering happy / error / edge / integration paths.
229
+ - [ ] **Decisions → Negative scope** exhaustive enough to surprise user.
230
+ - [ ] **Alternatives considered** present (or explicit "none" with reason).
231
+ - [ ] **Open questions** lists every unresolved item with default, owner, unblocks-on.
232
+ - [ ] **Risks assumed** has assumption + mitigation + likelihood/severity.
233
+ - [ ] Body has no code, no file paths, no app names, no time estimates, no marketing language.
234
+ - [ ] Every unverified inference in **Open questions** or **Risks assumed** — not in **Business Context** through **Decisions**.
235
+ - [ ] No `§N` section references anywhere in the spec body. Use section names.
@@ -0,0 +1,78 @@
1
+ ---
2
+ name: open-pr-from-context
3
+ description: Publish one `.vinta-ai-workflows/prs-context/{feature-name}/{phase-name}.md` file as a real PR + inline review comments by invoking the bundled [open-pr.sh](scripts/open-pr.sh) shell script. The script handles all parsing + CLI calls (`gh` for GitHub, `glab` for GitLab); this skill is a thin wrapper that picks the file, runs the script, and reports the result. Use after `implement-plan` has pushed a phase branch + written the context file, or any time afterwards to publish a `status: pending` file. Does nothing else — no diff editing, no extra checks, no skill-side parsing.
4
+ ---
5
+
6
+ # Open PR from context
7
+
8
+ [implement-plan](../implement-plan/SKILL.md) writes per-phase PR drafts to `.vinta-ai-workflows/prs-context/{feature-name}/{phase-name}.md` ([template](../../prs-context-template.md)) and (when a PR CLI is detected) calls this skill to publish them. When the runtime had no PR CLI at write time, the file sits as `status: pending` until someone runs this skill in an environment with the CLI.
9
+
10
+ The mechanical work — parse frontmatter, detect CLI, open PR, post each inline comment, rewrite frontmatter to `published`, append publish log — lives in [`scripts/open-pr.sh`](scripts/open-pr.sh). This SKILL.md just wires the agent to it.
11
+
12
+ ## Dependencies
13
+
14
+ The script needs: `bash 4+`, `git`, `yq` (Mike Farah's), `jq`, and one of `gh` / `glab`. Install via the project's package manager / Homebrew / apt:
15
+
16
+ - macOS: `brew install yq jq gh` (or `glab`).
17
+ - Debian/Ubuntu: `apt install yq jq` + `gh` from cli.github.com (or `glab` from gitlab.com).
18
+ - Inside CI runners: ensure these are present in the image.
19
+
20
+ The script bails early with `missing dependency: <name>` if any are absent. Surface the install command — don't auto-install.
21
+
22
+ ## Steps
23
+
24
+ ### 1. Pick the file
25
+
26
+ If the user passed a file path → use it.
27
+
28
+ Otherwise list candidates: `find .vinta-ai-workflows/prs-context -type f -name '*.md'`, read each one's frontmatter `status` field, prefer `status: pending`. Use `AskUserQuestion` to confirm if more than one is pending.
29
+
30
+ ### 2. Run the script
31
+
32
+ ```bash
33
+ bash ai-tools/skills/open-pr-from-context/scripts/open-pr.sh <file>
34
+ ```
35
+
36
+ (The script has the executable bit set, so `./ai-tools/skills/open-pr-from-context/scripts/open-pr.sh <file>` also works.)
37
+
38
+ Optional flags:
39
+
40
+ - `--cli gh|glab` — force a specific PR CLI. Default: auto-detect (`gh` first, then `glab`).
41
+ - `--dry-run` / `-n` — print what would be posted; touch nothing remote and don't rewrite the file.
42
+
43
+ Pass through whatever the user explicitly asked for; otherwise no flags.
44
+
45
+ ### 3. Report the result
46
+
47
+ Read the script's stdout + exit code:
48
+
49
+ - **Exit 0** — PR opened (or pre-existing detected); all comments posted. File rewritten to `status: published` + `pr_url`. Surface the URL to the user; you're done.
50
+ - **Exit 1** — PR opened, but one or more inline comments failed. The script's stderr lists which `(file:line)` failed. Forward the failures verbatim. Most common cause: a force-push between branch push and now invalidated the line position — re-run after pushing.
51
+ - **Exit 2** — Hard failure (file invalid, branch not pushed, CLI missing/unauthed, missing dependency). Forward the script's error message; do **not** improvise (don't push the branch, don't install CLIs, don't auth on the user's behalf).
52
+
53
+ ## Inputs the script expects
54
+
55
+ The bundled [prs-context-template.md](../../prs-context-template.md) documents the file shape. The script verifies:
56
+
57
+ - Frontmatter: `branch`, `base` (required); `status`, `pr_url` (read + written).
58
+ - `# Title` section: single line, non-empty.
59
+ - `# Description` section: markdown, non-empty.
60
+ - `# Comments` section: a single fenced ```yaml list (may be empty — clean phases are valid).
61
+
62
+ A file at `status: published` with a populated `pr_url` is a no-op — the script prints the URL and exits 0 without touching anything.
63
+
64
+ ## What this skill / script do NOT do
65
+
66
+ - **Do not push the branch.** `implement-plan` already pushed it. If the script reports `branch not pushed`, that's a setup bug — surface it.
67
+ - **Do not edit the diff.** Comment placement is informational only.
68
+ - **Do not re-run tests / lint.** Those happened in `implement-plan` before push.
69
+ - **Do not draft new descriptions or comments.** The file is the source of truth — edit the file (or re-run `implement-plan` for that phase) before re-invoking.
70
+ - **Do not install or authenticate CLIs.** Surfaces the gap, stops.
71
+ - **Do not delete the PR-context file.** `implement-plan` cleans up at plan end; until then the file is durable history.
72
+
73
+ ## Pitfalls
74
+
75
+ - **Stacked phases.** PR base is the previous phase's branch, not `main`. The file's `base` field has the right value; the script trusts it. Don't override.
76
+ - **Force-pushed branch.** Inline comments target a SHA. If the branch was force-pushed between PR open and comment posting, GitHub/GitLab may reject specific lines as "no longer in the diff". Per-comment failures are reported but don't abort the run — the surviving comments still post. Re-run after pushing if you want the failed ones.
77
+ - **Empty `# Comments`.** Valid; clean phases produce few or zero comments. Script no-ops the comment loop, still rewrites status to `published`.
78
+ - **Missing `yq` / `jq`.** Script bails with `missing dependency: yq` (or `jq`) before doing anything. Install the missing tool, re-run.