From 2d184781105169ab2c7314ac2d11eb066a604522 Mon Sep 17 00:00:00 2001 From: Janis Date: Fri, 5 Jun 2026 10:13:18 +0200 Subject: [PATCH] chore(commands): add auto-linking for blocks/relates-to/subtask relations create-story: Step 7 prompts for issue links and auto-detects IDs in description. fix-defect: Step 3b scans for referenced IDs; Step 7b prompts for post-push links. split-story: Step 6b adds inter-subtask blocking chains; Step 6c links external issues. All commands now use content-based project routing (not parent inheritance). Co-Authored-By: Claude Sonnet 4.6 --- .claude/commands/create-story.md | 31 ++++++++++++++++++++++++++-- .claude/commands/fix-defect.md | 25 ++++++++++++++++++++--- .claude/commands/split-story.md | 35 ++++++++++++++++++++++++++++---- 3 files changed, 82 insertions(+), 9 deletions(-) diff --git a/.claude/commands/create-story.md b/.claude/commands/create-story.md index 81ce508..eba380e 100644 --- a/.claude/commands/create-story.md +++ b/.claude/commands/create-story.md @@ -66,10 +66,17 @@ Incorporate feedback. Repeat until user approves. ## Step 5 — Determine Project +> **Project routing rules (always apply these):** +> - Backend code (game engine, bots, API, services, coordinator) → `NCS` +> - Frontend code (UI, UX, web app) → `NCWF` +> - Infrastructure (Kubernetes, pipelines, CI/CD, DB setup, cloud infra) → `NCI` +> - If ambiguous, ask the user. + - Frontend / UI / UX → project: `NCWF` - Backend / coordinator / systems / bot / engine → project: `NCS` +- Kubernetes, pipelines, CI/CD, DB setup, infrastructure → project: `NCI` -If ambiguous, ask the user. +If still ambiguous, ask the user. ## Step 6 — Create Issue @@ -79,7 +86,27 @@ Call `mcp__youtrack__create_issue` with: - `description`: full formatted story from Step 3 (Markdown) - `type`: `Feature` (or `Task` if purely technical with no user-facing value) -## Step 7 — Report +## Step 7 — Link Issues + +After creation, **automatically** 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 NCS-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. diff --git a/.claude/commands/fix-defect.md b/.claude/commands/fix-defect.md index 918a4ed..9f744f4 100644 --- a/.claude/commands/fix-defect.md +++ b/.claude/commands/fix-defect.md @@ -39,12 +39,16 @@ After root cause confirmed, assess scope: To create subtasks: 1. Break fix into discrete, independently-completable tasks (e.g. "Fix validation in RuleSet", "Add regression test for castling edge case", "Update FenParser to handle X"). 2. For each subtask call `mcp__youtrack__create_issue` with: - - `project`: same project as parent ticket + - `project`: based on subtask content — do **not** inherit from parent. Backend code → `NCS`; frontend/UI → `NCWF`; Kubernetes/pipelines/CI-CD/DB setup/infrastructure → `NCI`. If ambiguous, ask user. - `summary`: concise action-oriented title - `type`: `Task` - `description`: what to do and why 3. Call `mcp__youtrack__link_issues` to link each subtask to `$ARGUMENTS` with relation `subtask of`. -4. List created subtask IDs to user. +4. Check if the ticket description or comments mention other issue IDs. For each mentioned ID, suggest a link and confirm with user: + - Fix depends on another fix finishing first → `is blocked by` + - This fix blocks another ticket → `blocks` + - Logically related but independent → `relates to` +5. List created subtask IDs and any additional links to user. Then proceed to Step 4, implementing subtasks in order. @@ -101,7 +105,22 @@ Files changed: - ``` +## Step 7b — Additional Links + +After commenting, ask the user if `$ARGUMENTS` should be linked to any other issues not already linked: + +| Situation | Relation | +|-----------|---------| +| This fix blocks another open ticket | `blocks` | +| Another ticket must ship first | `is blocked by` | +| Related defect or story | `relates to` | +| Duplicate of another defect | `duplicates` | + +Scan the ticket description and comments for any issue IDs that were mentioned but not yet linked. Suggest those automatically. + +Call `mcp__youtrack__link_issues` for each confirmed link. + ## Step 8 — Cleanup Call `ExitWorktree` to delete the worktree. -Report: branch pushed, ticket commented, worktree deleted, done. +Report: branch pushed, ticket commented, links created, worktree deleted, done. diff --git a/.claude/commands/split-story.md b/.claude/commands/split-story.md index 011a3d3..e2d75e2 100644 --- a/.claude/commands/split-story.md +++ b/.claude/commands/split-story.md @@ -59,11 +59,15 @@ Rules: - Definition of Done: adjust per subtask — not all subtasks need the same criteria (e.g. a research spike has different DoD than an implementation task). - Keep description short — one paragraph max. -## Step 5 — Determine Project +## Step 5 — Determine Project per Subtask -Inherit project from parent story (`$ARGUMENTS`): -- If parent is `NCWF-*` → subtasks go in `NCWF` -- If parent is `NCS-*` → subtasks go in `NCS` +Assign each subtask's project based on its content — do **not** inherit blindly from parent: + +- Backend code (game engine, bots, API, services, coordinator) → `NCS` +- Frontend code (UI, UX, web app) → `NCWF` +- Kubernetes, pipelines, CI/CD, DB setup, infrastructure → `NCI` + +If a subtask's project is ambiguous, ask the user before creating it. ## Step 6 — Create Subtasks @@ -75,8 +79,31 @@ For each subtask call `mcp__youtrack__create_issue` with: Then call `mcp__youtrack__link_issues` to link each created subtask to `$ARGUMENTS` with relation `subtask of`. +## Step 6b — Inter-Subtask Links + +If subtasks must be done in sequence (one depends on output of another), add ordering links: +- For each dependency pair call `mcp__youtrack__link_issues` with relation `is blocked by` (subtask B is blocked by subtask A). + +Ask the user to confirm sequencing before adding these links: + +> Do any subtasks have ordering dependencies? (e.g. "Implement X must come before Add tests for X") + +## Step 6c — External Links + +Scan `$ARGUMENTS` description and implementation notes for any referenced issue IDs not already linked. For each: + +| Situation | Relation | +|-----------|---------| +| Parent story blocks another epic/story | `blocks` | +| Story depends on another epic completing | `is blocked by` | +| Related story in same domain | `relates to` | +| This story duplicates or supersedes | `duplicates` | + +Suggest links to the user and call `mcp__youtrack__link_issues` on confirmation. + ## Step 7 — Report List all created subtask IDs and summaries. +List all links created (subtask-of, blocking chains, external). Display parent story link. Ask if any subtask needs further splitting.