--- name: to-stories description: 'This skill should be used to write wiki stories — Gherkin scenarios plus a first slice list — from either input: the current conversation, synthesized into a thin `plan/plan-{name}.md` with one `plan/{name}/story-N-{slug}.md` per story; or a promoted intent, elaborated into one story under the active plan with the intent linked and `promoted_to` reported back. Default `triage_state: needs-triage`. Does NOT interview — if intent is unclear it suggests `/intent` and stops. Use when the user says "turn this into a plan", "draft a PRD", "/to-stories", "write up what we discussed", "synthesize this into stories", "write the story for intent X", or "elaborate intent X". Reads `glossary.md` and existing ADRs to use the project''s vocabulary correctly.' --- # To Stories — Conversation or Intent into Wiki Stories Two inputs, one output shape. From the **current conversation**, a thin orchestration plan plus per-story files. From a **promoted intent**, one story under the active plan. Does not interview — synthesizes what is already established. If intent isn't clear, suggest `/intent` first and stop. ## Input B — a promoted intent When `/triage` promotes an intent, or the user names one: 1. Read `projects//intent/intent-.md` in full, then `glossary.md` and the ADRs it links. 2. Derive the story from the intent's sections — **Problem** and **Proposed outcome** become the User Story and the Problem line; the **Falsification** path becomes the first scenario, since it already names an observable outcome; **Affected** names the code paths for the slices; **Constraints** and **Open questions** land in the story's Decisions and scenarios respectively. 3. Write `projects//plan//story-N-.md` — next N in that plan — with `[[intent-]]` under References. No new plan for one story. 4. `triage_state` is what the operator chose at promotion: `ready-for-agent` when the brief is complete, `needs-triage` otherwise. 5. Add the Story Index row to the plan, then report the story slug back so triage writes `promoted_to` and archives the intent (the intent's frontmatter is triage's to close, not this skill's). Everything below is Input A — the conversation. ## Prerequisites - `WIKI_SCOPE: ` declared in the project instructions. If missing, suggest `/wiki` and stop. - `projects//index.md` exists. If missing, suggest `/intent` and stop. - The conversation has discussed a concrete piece of work (a feature, a refactor, a phase). If only abstract intent has been discussed, suggest `/intent` to nail it down first. ## What this skill produces ``` projects// ├── plan/ │ ├── plan-.md ← thin orchestration (~60-100 lines) │ └── / │ ├── story-1-.md ← Gherkin + slices (~40-60 lines) │ ├── story-2-.md │ └── story-3-.md ``` Each story file ships with `triage_state: needs-triage`. The user runs `/triage` next to evaluate readiness. ## Process ### 1. Read the wiki context - Call `prime()` via the wiki MCP, or `kmd prime ` where the harness exposes no MCP tools — get identity, primer, active ADRs, top tags, current plan. - Read `projects//glossary.md` if it exists — use canonical vocabulary throughout. - Read recent ADRs under `projects//adr/` to respect existing decisions. - Note any active plan — the new plan should not duplicate an in-flight one. ### 2. Synthesize (do not interview) From the conversation, extract: **Plan slug** — kebab-case, descriptive, ≤4 words. e.g. `billing-mvp`, `void-and-amend`, `auth-rewrite`. The slug becomes both the parent file (`plan-{slug}.md`) and the sub-folder (`{slug}/`). **Problem** — 1-3 sentences from the user's perspective. Use vocabulary from `glossary.md`. If you can't write this without inventing, the conversation hasn't established the problem — stop and suggest `/intent`. **Solution** — 2-3 sentences describing the approach. Reference existing specs/ADRs by wikilink (`[[spec-cart-model]]`, `[[adr-postgres]]`). **User stories** — extract from the conversation. Each story: - Has a clear actor, capability, benefit - Maps to a discrete piece of user value - Will fit in 1-5 vertical slices If you can identify <3 stories, the workstream may be too small. Two paths: (a) still create the parent `plan-{slug}.md` + `{slug}/` sub-folder + the 1-2 story files — architectural consistency wins (skills downstream don't have a special-case path), or (b) skip the plan entirely and write a single standalone story under an existing related plan. Default to (a) unless the user prefers (b). If you can identify >12 stories, the workstream is too large for one plan — propose splitting into multiple plans (`plan-billing-foundation` + `plan-billing-rollout`). **Out of Scope** — 3-5 bullets capturing things explicitly *not* part of this plan. Lift these from the conversation. ### 3. Identify spec/ADR gaps Walk the synthesized plan and ask: - Does the solution describe a system that doesn't yet have a `spec-{topic}.md`? → propose creating one. - Does the solution rely on a hard-to-reverse decision not yet captured in an ADR? → propose creating one (apply Matt's three-test: hard-to-reverse + surprising + real trade-off). Don't write specs/ADRs in this skill — flag the gaps and reference future skill work. Or, if the gap is small enough to fill inline (a single new term in `glossary.md`), do it now. ### 4. Write the parent plan Write `projects//plan/plan-.md` using `wiki://template/project/plan` (MCP resource, or `kmd resource `) as the frontmatter base, with body: ```markdown # ## Problem <1-3 sentences from the user's perspective.> ## Solution <2-3 sentences. Reference [[spec-X]] and [[adr-Y]] by wikilink.> ## Stories | # | Story | State | Category | |---|---|---|---| | 1 | [[story-1-]] | needs-triage | enhancement | | 2 | [[story-2-]] | needs-triage | enhancement | | 3 | [[story-3-]] | needs-triage | enhancement | ## Out of Scope - - - ## References - [[glossary]] — vocabulary - [[spec-]] — system overview - [[adr-]] — relevant decision ``` Frontmatter: ```yaml --- title: kind: plan scope: status: active summary: "" tags: [...] created: "" updated: --- ``` ### 5. Write each story file For each user story, write `projects//plan//story-N-.md` using `wiki://template/project/story` (MCP resource, or `kmd resource `). Body: ```markdown # ## User Story As a , I want , so that . ## Scenarios **Scenario: ** - Given - When - Then **Scenario: ** - Given - When - Then ## Slices - [ ] **Slice 1** — · `AFK` · [[spec-]] - [ ] **Slice 2** — · `AFK` · [[adr-]] ## References - [[spec-]] - [[adr-]] ``` Frontmatter: ```yaml --- title: kind: story scope: parent: plan- status: active triage_state: needs-triage category: enhancement blocked_by: [] tags: [...] sources: [] created: "" updated: --- ``` **Rules for scenarios:** - Each scenario describes ONE behavior end-to-end. - Use Given/When/Then, not free-form prose. - Cover the happy path first, then 1-2 edge cases per story. - Don't try to be exhaustive — the user can add scenarios during `/triage` if a story needs more clarity. **Rules for slices:** - A slice is a tracer-bullet **vertical** through every layer (schema · API · UI · tests). - Each slice should be independently demoable. - Mark each slice `AFK` (autonomous-runnable) or `HITL` (needs human judgment). - Default to AFK — push back if a user describes a slice that requires unavoidable human judgment. - 1-5 slices per story is normal. If a story needs 6+, the story is too coarse — split it. **Slice ownership across skills:** `/to-stories` writes a *rough* slice draft (1-3 slices, coarse, mostly to ground the story shape). `/to-issues` is the refinement pass — it validates vertical-slice rules, splits coarse slices into proper tracer bullets, sets `blocked_by` between stories, and (in GH/GitLab mode) mirrors `ready-for-agent` slices to remote issues. Don't over-invest in slice quality here; that's `/to-issues`'s job. ### 6. Sync the wiki After writing, confirm the resync: the posttool hook syncs automatically; if `kmd config`'s `synced` line did not advance, run `kmd validate` then `kmd sync`. This makes the new plan and stories searchable via `prime` and `search` (MCP tools, or `kmd prime` / `kmd search`). ### 7. Done — suggest next step > "Wrote `plan-` with N stories, all at `needs-triage`. Run `/triage` to evaluate readiness and move stories to `ready-for-agent` (AFK) or `ready-for-human`." ## Rules - **Do not interview.** Synthesize from conversation. If intent is unclear, suggest `/intent`. - **Do not auto-trigger `/triage`.** Stories ship at `needs-triage` and wait for the user to invoke triage explicitly. - **Use canonical vocabulary** from `glossary.md`. Don't invent terms. - **Reference existing specs and ADRs** via wikilinks rather than restating their content. - **One story file per user story.** Even if a story has just one slice, it gets its own file (architectural consistency). - **Quote prose-bearing frontmatter scalars** (`summary: "..."`) to avoid breaking the sync walker. - **Do not write specs or ADRs** in this skill — flag gaps and let `/intent` fill them. - **Update plan/story `updated:` field** after every edit. - **Set `created` once at creation; never bump it** — only `updated` changes on later edits.