Port create-defect, create-story, estimate-issues, fix-defect, implement-feature and split-story commands, adapted for the Angular frontend (npm build/test, prettier gates, NCWF routing). implement-feature now walks subtasks, respects blocked-by, and reports cross-project (NCS/NCI) tasks. Ignore .claude/worktrees. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
6.2 KiB
Fix Defect from YouTrack
Automated defect-fix workflow. Ticket ID: $ARGUMENTS
This is the NowChess-Frontend repo (Angular 20 / TypeScript). Gates:
- Build:
npm run build - Test:
npm test -- --watch=false --browsers=ChromeHeadless - Format:
npx prettier --write .(check withnpx prettier --check .)
Step 1 — Fetch Ticket
Call mcp__youtrack__get_issue with ID $ARGUMENTS.
Extract and display: summary, description, steps to reproduce, Priority, Subsystem.
Step 2 — Create Worktree
Derive branch name from ticket:
typefrom YouTrack issue type:bug→fix,feature/task→feat,refactor→refactor, elsechorescopefrom affected area (kebab-case, omit if unclear)descriptionfrom ticket summary: lowercase, kebab-case, max 40 chars, drop articles
Branch format: <type>/<ticket-id>-<description>
Example: fix/NCWF-123-board-flip-resets-selection
Call EnterWorktree with that branch name.
All subsequent file work happens inside this worktree.
Step 3 — Identify Root Cause (read-only)
- Run
npm run build— capture all errors and warnings. - Run
npm test -- --watch=false --browsers=ChromeHeadless— capture all failures. - Spawn
cavecrew-investigatorwith: ticket description + build/test output → locate root cause (files, line numbers, what's wrong). - If anything is ambiguous (reproduction unclear, scope uncertain, conflicting signals), use
AskUserQuestiontool to ask — max 4 questions at once. - Report findings to user. No file writes yet. Wait for acknowledgement before continuing.
Step 3b — Complexity Assessment + Subtasks
After root cause confirmed, assess scope:
Simple (1–2 files, single concern, < 1 hour estimated): proceed directly to Step 4.
Complex (3+ files, multiple concerns, or estimated > 1 hour): create subtasks before coding.
To create subtasks:
- Break fix into discrete, independently-completable tasks (e.g. "Fix selection state in BoardComponent", "Add spec for flip behaviour", "Update GameService move stream").
- For each subtask call
mcp__youtrack__create_issuewith:project: based on subtask content — do not inherit from parent. Frontend/UI →NCWF; backend code →NCS; Kubernetes/pipelines/CI-CD/infrastructure →NCI. If ambiguous, ask user.summary: concise action-oriented titletype:Taskdescription: what to do and why
- Call
mcp__youtrack__link_issuesto link each subtask to$ARGUMENTSwith relationsubtask of. - 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
- Fix depends on another fix finishing first →
- List created subtask IDs and any additional links to user.
Then proceed to Step 4, implementing subtasks in order.
Step 4 — Fix
- Implement fix (use the
general-purposeagent for non-trivial multi-file changes; inline edits for small ones). - Run
npm run build— must be green. - Run
npm test -- --watch=false --browsers=ChromeHeadless— must be green (add new specs for new behaviour; do not modify existing specs unless requirements changed). - Run
npx prettier --write .— blocking, foreground only. Wait for completion before continuing. - Run
npx prettier --check .— blocking, foreground only (neverrun_in_background). Wait for exit code 0. Must be green.- If it fails, fix all issues and re-run until exit code 0.
- Do NOT proceed to Step 5 until the build, tests and format check all pass. If any step fails, iterate until all pass.
Step 5 — Review
Spawn cavecrew-reviewer on the full diff.
Display findings grouped by severity.
Step 5b — Apply Review Findings
If the review produced any findings (any severity):
- Implement all agreed fixes.
- Run
npm run build— must be green. - Run
npm test -- --watch=false --browsers=ChromeHeadless— must be green. - Run
npx prettier --write .thennpx prettier --check .— blocking, foreground only. Wait for exit code 0. - Re-spawn
cavecrew-revieweron the updated diff to confirm all findings are resolved.
Repeat until review is clean or user explicitly accepts remaining findings.
Step 6 — Confirm + Push
Show summary: ticket, branch, files changed, review findings.
Use AskUserQuestion tool to ask for explicit approval before pushing. Include any open questions about commit message scope or body if unclear.
On approval, commit following Conventional Commits:
<type>(<scope>): <short description, imperative, ≤50 chars>
<optional body: what changed and why, wrap at 72 chars>
Closes $ARGUMENTS
https://knockoutwhist.youtrack.cloud/issue/$ARGUMENTS
type: same as branch type (fix,feat,refactor,chore, etc.)scope: affected area (ui,components,services,models,core,routing,pages,styles)- Subject: imperative mood, no period, lowercase
- Footer
Closes $ARGUMENTSand ticket URL always present
Push branch to remote.
Step 7 — Comment on Ticket
After successful push, call mcp__youtrack__add_issue_comment on $ARGUMENTS with:
Branch `<branch-name>` pushed.
<one-sentence summary of what was changed and why>
Files changed:
- <file1>
- <file2>
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 with discard_changes: true to delete the worktree.
(Branch was pushed in step 6 — commits are safe on remote; discard_changes: true bypasses the local-ahead guard.)
Report: branch pushed, ticket commented, links created, worktree deleted, done.