mach10 icon indicating copy to clipboard operation
mach10 copied to clipboard

Auto-assign issue to user when planning begins

Open LeanAndMean opened this issue 8 months ago • 2 comments

Summary

When a user runs /mach10:issue-plan or /mach10:issue-implement, they are committing to work on the issue. The issue should be automatically assigned to them at that point to signal ownership and prevent duplicate work.

Current Behavior

No mach10 command assigns the user to the issue at any point in the workflow. Users must manually assign themselves via the GitHub UI or CLI.

Proposed Behavior

Auto-assign the current gh user to the issue at two points in the workflow:

Primary: issue-plan Step 7

After posting the plan comment and creating the feature branch, assign the user. This is the earliest point where the user makes a durable commitment (branch creation + plan comment), making it the natural place for assignment.

Secondary: issue-implement Step 2

After the feature branch is confirmed (whether checked out or newly created), assign the user. This covers two cases that issue-plan alone misses:

  • Skip-planning path: A user goes straight to issue-implement without running issue-plan first. The branch checkout/creation is their commitment signal.
  • Different implementer: Person A plans, Person B implements. Person B should also appear as an assignee.

Why these two points

  • issue-plan Step 7 creates a feature branch and posts a plan comment -- these are visible signals that someone has claimed the work. Assignment should match this commitment.
  • issue-implement Step 2 confirms a branch and begins gathering context for implementation. Without this, users who skip planning would never be assigned.
  • issue-assessment is exploratory -- it does not create a branch or commit to implementation. Assigning here would be premature.
  • issue-plan-review reviews an existing plan. Reviewing is not a claim of ownership, so no assignment.

Implementation notes

In both commands, after the relevant action completes, add:

gh issue edit <issue-number> --add-assignee @me

Report the assignment in the confirmation output alongside the other actions taken in that step.

Edge cases

  • User is already assigned: --add-assignee @me is idempotent -- no error, no duplicate. Proceed silently.
  • Someone else is already assigned: This implies another person may have claimed the work. Before assigning, check existing assignees with gh issue view <issue-number> --json assignees. If other assignees are present, warn the user and use AskUserQuestion to ask how to proceed:
    • Add yourself: "Add yourself as an additional assignee alongside the existing assignee(s)"
    • Skip assignment: "Leave the current assignee(s) unchanged"
    • Replace: "Remove existing assignee(s) and assign only yourself"
  • No permission to assign: If --add-assignee fails (e.g., the user lacks write access to the repo), warn the user and continue -- assignment failure should not block the plan or implementation from proceeding.

Acceptance Criteria

  • Running /mach10:issue-plan assigns the current GitHub user to the issue after the plan is posted and branch is created
  • Running /mach10:issue-implement assigns the current GitHub user to the issue after the feature branch is confirmed
  • Assignment happens after the durable action (not before, in case the user cancels)
  • The confirmation output mentions the assignment
  • If the user is already assigned, the command does not fail or duplicate the assignment
  • If someone else is already assigned, the user is warned and prompted before adding themselves
  • If assignment fails due to permissions, the command continues gracefully

LeanAndMean avatar Apr 01 '26 18:04 LeanAndMean

Implementation Plan: Auto-assign issue to user when planning begins

Overview

Add auto-assignment of the current GitHub user to the issue in two commands: issue-plan (after plan posting and branch creation) and issue-implement (after branch confirmation). The assignment logic is identical in both locations and documented via a CLAUDE.md sync note.

Stage 1: Add auto-assignment to both commands and CLAUDE.md sync note

What it accomplishes

Implements the full feature: auto-assignment logic in issue-plan Step 7 and issue-implement Step 2, plus the CLAUDE.md sync note and version bump.

Files modified

  1. commands/issue-plan.md -- Add sub-step 3 "Assign the issue" in Step 7, after branch creation (sub-step 2) and before the "Confirm both actions" line. The logic:

    • Check existing assignees: gh issue view <issue-number> --json assignees --jq '[.assignees[].login] | join(",")'
    • Check current user: gh api user --jq .login
    • If current user is already assigned: skip silently
    • If no assignees: gh issue edit <issue-number> --add-assignee @me
    • If other assignees exist (not including current user): warn and use AskUserQuestion with options: Add me / Skip / Replace
    • On failure: warn in CLI output and continue (never block workflow)
    • All assignment output is CLI-only (not in GitHub comments)
  2. commands/issue-implement.md -- Add "Assign the issue" block after the "Before proceeding" section at the end of Step 2, before Step 3 heading. Same logic as above, with an additional note that already-assigned is the expected case when returning for subsequent stages.

  3. CLAUDE.md -- Add "Issue auto-assignment sync" bullet in the Writing Commands section, after the duplicate-issue detection sync note. Documents that the assignment logic (gh commands, skip condition, AskUserQuestion option set) is duplicated between the two command files and must be kept in sync.

  4. .claude-plugin/plugin.json -- Bump version from 1.7.1 to 1.8.0 (new feature).

AskUserQuestion details (for the "other assignees exist" case)

  • Add me: "Add yourself alongside the existing assignees" -- runs gh issue edit <issue-number> --add-assignee @me
  • Skip: "Leave the current assignees unchanged" -- no-op, continue
  • Replace: "Remove the existing assignees and assign only yourself" -- runs gh issue edit <issue-number> --remove-assignee <existing-logins> --add-assignee @me

Testing

This is a pure plugin definition repo with no testable runtime code. Verification is manual review against acceptance criteria.

Dependencies

None -- this is a single-stage plan.

Decision Log

Clarifying Questions

  • Assignee check scope: Full check-and-prompt in both commands, but issue-implement skips the prompt if the current user is already assigned (the common case for subsequent stages).
  • Confirmation output location: CLI-only, consistent with existing next-step suggestion pattern.
  • Decision-comment marker: No <!-- mach10-decisions --> comment for assignment choices -- CLI-only output is sufficient.

Architecture Choice

Selected: Clean architecture -- inline assignment logic in both command files plus a CLAUDE.md sync note. Chosen because the codebase has an established convention of documenting duplicated logic via sync notes (six existing notes). Skipping the sync note would break the pattern and risk one file drifting when the other is updated.

Rejected: Minimal changes -- same command edits without a sync note. Lower effort by one line, but inconsistent with the codebase convention and risks maintenance drift.


This comment will guide staged implementation via /mach10:issue-implement 48 1.

LeanAndMean avatar Apr 07 '26 03:04 LeanAndMean

Stage 1 Implementation Complete

Commit: 9594dd8

Changes

  • commands/issue-plan.md -- Added sub-step 3 in Step 7: after posting the plan and creating the branch, the current user is assigned to the issue. Includes assignee check, skip-if-already-assigned, AskUserQuestion for the other-assignees case (Add me / Skip / Replace), and graceful failure handling.
  • commands/issue-implement.md -- Added "Assign the issue" section after "Before proceeding" in Step 2. Same logic as issue-plan, with a note that already-assigned is the expected case for subsequent stages.
  • CLAUDE.md -- Added "Issue auto-assignment sync" bullet documenting the duplicated logic between the two command files.
  • .claude-plugin/plugin.json -- Version bumped from 1.7.1 to 1.8.0.

All acceptance criteria from the issue are addressed by this single-stage implementation.

LeanAndMean avatar Apr 07 '26 03:04 LeanAndMean