mach10 icon indicating copy to clipboard operation
mach10 copied to clipboard

pr-create skill should auto-close sub-issues listed in parent issue

Open LeanAndMean opened this issue 7 months ago • 3 comments

Summary

When a PR is created for a parent issue that lists sub-issues (e.g., #298, #289, etc.), the pr-create skill only adds a Fixes #<parent> keyword. The sub-issues are referenced as plain text ("sub-issue 298") without GitHub closing keywords, so they remain open after the PR merges.

Current Behavior

pr-create reads the parent issue and generates a PR body with Fixes #<parent-issue>. Sub-issues are mentioned in the summary text but without Fixes/Closes keywords. After merge, only the parent issue is auto-closed by GitHub; sub-issues must be closed manually.

Proposed Behavior

When the linked issue contains a "Sub-issues" section (or similar list of child issue references), pr-create should append closing keywords for each sub-issue in the PR body alongside the parent. For example:

Fixes #415, fixes #298, fixes #289, fixes #179, fixes #320, fixes #293

Acceptance Criteria

  • pr-create detects sub-issue references (e.g., - #298 — ...) in the parent issue body
  • Closing keywords are generated for all sub-issues in addition to the parent
  • Sub-issues are auto-closed by GitHub when the PR merges

LeanAndMean avatar Apr 06 '26 20:04 LeanAndMean

Assessment

Scope: Small — change is confined to commands/pr-create.md. No new files, no sync constraints affected. Downstream consumers (pr-review.md, feature-completeness-checker.md) already handle multiple Fixes #N references.

Implementation approach: Add a sub-step after reading the linked issue (Step 2) to parse its body for sub-issue references, then include closing keywords for each in the PR body template (Step 3).

Open questions to resolve during planning:

  1. Sub-issue format patterns — The issue gives one example (- #298 — ...), but sub-issues can appear as task lists (- [ ] #N), plain list items (- #N), GitHub's native "Sub-issues" section, or inline references. The implementation should define which patterns to detect and in what priority.

  2. Staged work — If a PR implements only some sub-issues (e.g., one stage of a multi-stage plan), auto-closing all sub-issues would be incorrect. The existing user review step in Step 3 (draft approval with "Modify" option) naturally mitigates this — users can remove unwanted closing keywords — but the command instructions should call this out explicitly.

  3. Mention vs. sub-issue — Pattern matching should distinguish sub-issues (listed in a structured section) from casual mentions ("see also ...") to avoid over-closing unrelated issues.

LeanAndMean avatar Apr 06 '26 21:04 LeanAndMean

Implementation Plan: Sub-issue auto-closing in pr-create

Overview

Modify commands/pr-create.md to detect sub-issues from a linked parent issue and include closing keywords for each in the PR body, so GitHub auto-closes them on merge.

Architecture Decision

Approach: Pragmatic blend — named sub-block for detection logic (clear separation of concerns), Fixes #N for all issues (simpler, consistent), concise instructions.

Detection strategy: API-first with body-parse fallback:

  1. Try GitHub sub-issues API (gh api repos/:owner/:repo/issues/<number>/sub_issues)
  2. Fall back to scanning the issue body for #N references on structured list lines

Escape valve: The existing "Modify" option in Step 3 lets users remove unwanted closing keywords.

Stage 1: Add sub-issue detection and closing keywords to pr-create

Scope: Single file, single stage.

File modified: commands/pr-create.md

Changes

Change 1 — Step 2, new "Sub-issue detection" sub-block (after "Issue resolution" block, before Step 3):

  • Gate on whether an issue was identified (skip if no issue)
  • Strategy A: Query gh api repos/:owner/:repo/issues/<issue-number>/sub_issues --jq '[.[] | .number]'; if succeeds with results, use as confirmed sub-issue list
  • Strategy B (fallback): If API fails or returns empty, scan the issue body for #N references on structured list lines (lines beginning with -, *, +, - [ ], - [x]); record matches as candidate sub-issues
  • If neither strategy yields results, sub-issue list is empty

Change 2 — Step 3, body template and inclusion rule:

  • Replace single Fixes #<issue-number> line with multi-line pattern: parent Fixes followed by one Fixes #N per sub-issue
  • Replace single-sentence inclusion rule with three-case rule:
    • No issue identified: omit all closing keywords
    • Issue without sub-issues: include only Fixes #<issue-number>
    • Issue with sub-issues: include Fixes #<issue-number> for the parent followed by one Fixes #N line for each sub-issue; note that user can remove unwanted lines via "Modify"

Testing

No testable runtime code (this is a command definition file). Verification is manual: invoke /mach10:pr-create on a PR linked to a parent issue with sub-issues and confirm the draft body includes closing keywords for all sub-issues.

Dependencies

None. No downstream files need changes — pr-review.md, feature-completeness-checker.md, and pr-merge.md all handle multiple closing keywords naturally.


This plan will guide staged implementation via /mach10:issue-implement.

LeanAndMean avatar Apr 06 '26 21:04 LeanAndMean

Progress: Stage 1 complete

Commit 4a1820c implements the sub-issue auto-closing feature in commands/pr-create.md.

Changes:

  • Added "Sub-issue detection" sub-block in Step 2 with two strategies: GitHub sub-issues API (primary) and checkbox body-parse fallback
  • Updated Step 3 body template and closing keywords inclusion rule to support three cases: no issue, issue without sub-issues, issue with sub-issues
  • Each sub-issue gets its own Fixes line in the PR body

Review refinements applied:

  • Narrowed body-parse fallback to checkbox lines only (- [ ] / - [x]) to avoid false positives from informational references
  • Clarified API path resolution order with explicit shell variable substitution
  • Added user disclosure when sub-issues are sourced from the less-reliable fallback strategy

LeanAndMean avatar Apr 06 '26 21:04 LeanAndMean