# Create User Story in YouTrack

Automated user-story creation workflow. Topic/hint: `$ARGUMENTS`

This is the **NowChess-Frontend** repo (Angular 20 / TypeScript). Stories raised
here usually belong to project `NCWF`, but routing in Step 5 still applies.

## Step 1 — Gather Context

Use `AskUserQuestion` tool to ask the user (max 4 questions at once):

1. **Domain** — Is this frontend (UI/UX) work, or does it touch backend/infrastructure?
2. **User type** — Who is the actor? (e.g. player, spectator, admin, anonymous visitor)
3. **Action** — What should the user be able to do?
4. **Goal/value** — Why? What outcome does it enable?

If `$ARGUMENTS` already answers some of these, skip those questions.

## Step 2 — Research (if needed)

If the topic involves unfamiliar UI flows, component structure, or technical constraints:
- Search the repo for relevant code under `src/app/` (use `Grep`/`Bash`).
- Use `WebSearch` if the topic involves Angular APIs, external standards or protocols.
- Do NOT guess. Surface findings before drafting.

## Step 3 — Draft Story

Compose the full story using this template:

```
As a [type of user]
I want to [perform an action]
So that [achieve a goal or value]


Description

[Additional context or business logic for this story.]


Acceptance Criteria

[List the specific, measurable criteria that define when this story is done:]

- Criterion 1
- Criterion 2
- Criterion 3


Implementation Notes

[Technical notes, component/service references, design refs, or constraints.]
```

Rules:
- User story line: plain English, present tense, from user's perspective.
- Acceptance criteria: testable, unambiguous, one condition each.
- Implementation notes: optional — only include if there are known constraints, related tickets, or design refs.

## Step 4 — Clarify Acceptance Criteria

Show the draft to the user.
**Use `AskUserQuestion` tool to ask:**
- Are the acceptance criteria complete and correct?
- Any implementation constraints to add?
- Priority (if known)?

Incorporate feedback. Repeat until user approves.

## Step 5 — Determine Project

> **Project routing rules (always apply these):**
> - Frontend code (UI, UX, web app, components, services) → `NCWF`
> - Backend code (game engine, bots, API, services, coordinator) → `NCS`
> - Infrastructure (Kubernetes, pipelines, CI/CD, DB setup, cloud infra) → `NCI`

- Frontend / UI / UX → project: `NCWF` (default for this repo)
- Backend / coordinator / systems / bot / engine → project: `NCS`
- Kubernetes, pipelines, CI/CD, infrastructure → project: `NCI`

If still ambiguous, ask the user.

## Step 6 — Create Issue

Call `mcp__youtrack__create_issue` with:
- `project`: determined in Step 5
- `summary`: concise title derived from the "I want to" clause (≤72 chars, sentence case)
- `description`: full formatted story from Step 3 (Markdown)
- `type`: `Feature` (or `Task` if purely technical with no user-facing value)

## Step 7 — Link Issues

After creation, ask the user (use `AskUserQuestion` if interactive, otherwise infer from context):

> Are there related issues to link? (skip if none)

Collect any issue IDs the user mentions. For each, determine the correct relation and call `mcp__youtrack__link_issues`:

| Situation | Relation to use |
|-----------|----------------|
| This story must be done before another | `blocks` |
| Another story must be done before this | `is blocked by` |
| Stories share domain or are related | `relates to` |
| This is a child of an epic/story | `subtask of` |
| This is a parent grouping subtasks | `parent for` |
| This depends on another ticket's output | `depends on` |

If the user mentions an issue in the story description or implementation notes (e.g. "see NCS-42", "after NCWF-12 is done"), auto-detect and suggest linking it — confirm before creating the link.

## Step 8 — Report

Display the created issue ID and URL.
List any links created (relation type + linked issue ID).
Ask if a linked sub-task or implementation ticket is needed.
