Add task tracking to pr-create
Summary
Add TaskCreate/TaskUpdate progress tracking to the pr-create command. This command has complex multi-strategy context gathering (3 issue detection strategies, 2-strategy sub-issue detection with state queries), conditional closing keywords logic, and a draft/approve user interaction loop. Task tracking will ensure the context gathering phase -- particularly sub-issue detection and closing keywords inclusion -- is not skipped.
Motivation: In PR #90, a pr-create session skipped the sub-issue closing keywords step, causing sub-issues #65, #66, #67 to remain open after merge. An explicit "Gather branch and issue context" task checkpoint would have prevented this.
Part of #81 (Tier 2 -- HIGH priority). See #81 for task tracking conventions and overall context.
File: commands/pr-create.md
What Is Task Tracking?
mach10 commands should use TaskCreate and TaskUpdate to establish visible progress checkpoints. Tasks are created upfront after input parsing, then transitioned to in_progress / completed as work proceeds. This makes long-running commands observable and forces the execution to explicitly pass through each checkpoint. See #81 for the full conventions.
Task Graph
All 3 tasks are created in a single block after Step 1 (input parsing). Each task starts as pending.
| Task | Subject | activeForm | in_progress | completed |
|---|---|---|---|---|
| T1 | Gather branch and issue context | Gathering context | Before Step 2 | After Step 2 (commits analyzed, issue read if identified, sub-issues detected) |
| T2 | Draft PR and get approval | Drafting PR | Before Step 3 | After Step 3 (user approves draft) |
| T3 | Create pull request | Creating pull request | Before Step 4 | After Step 5 (PR created, confirmed) |
Notes:
- T1 covers all context gathering: branch detection, commit analysis, issue identification (3 strategies), issue + comment reading, and sub-issue detection (2-strategy with state queries). This is the critical checkpoint -- the step that was skipped in the PR #90 incident.
- T2 covers the draft composition and the modify/approve interaction loop. The closing keywords inclusion rule is applied during drafting.
- T3 covers the push-if-needed and
gh pr createcall.
Delegation Notes
No skill or subagent delegation. All work is direct.
Acceptance Criteria
- [ ] All 3 tasks are created after input parsing, before any work begins
- [ ] Each task transitions
in_progress->completedat the boundaries described above - [ ] T1 is not marked
completeduntil sub-issue detection has been attempted (when an issue is identified) - [ ] T2 stays
in_progressthrough any modify loops - [ ] If user cancels at draft approval, T2 remains
in_progress, T3 remainspending - [ ]
allowed-toolsin frontmatter includesTask(if not already present)
Note: The task tracking conventions have been revised (see comment on issue 81). The task graph in this issue body follows the old "3-5 compound tasks" convention and is now stale. When implementing this sub-issue, derive the task graph using 1-to-1 step mapping: one task per command step, with a Step 0 that handles input parsing and task list creation. See the updated CLAUDE.md conventions and commands/pr-review.md for the reference implementation.
Implementation Plan
Stage 1: Add task tracking to pr-create command
What it accomplishes: Adds full Step 0 bootstrap and per-step task state transitions to commands/pr-create.md, following the established conventions from the 5 existing tracked commands.
Files modified:
commands/pr-create.md(primary)CLAUDE.md(sync list update)
Changes
1. Frontmatter -- Add TaskCreate, TaskUpdate to allowed-tools:
allowed-tools: Bash, Read, Grep, Glob, AskUserQuestion, TaskCreate, TaskUpdate
2. Restructure steps -- Merge current Step 1 (Parse Input) into a new Step 0 (Parse input and create task list). Renumber current Steps 2-5 to Steps 1-4.
New step structure:
| Step | Subject | activeForm |
|---|---|---|
| Step 0 | Step 0: Parse input and create task list | Parsing input |
| Step 1 | Step 1: Gather context | Gathering context |
| Step 2 | Step 2: Draft PR and get approval | Drafting PR |
| Step 3 | Step 3: Create pull request | Creating pull request |
| Step 4 | Step 4: Confirm | Confirming |
3. Step 0 body -- Merge current Step 1 content (parse input logic) with the canonical task creation bootstrap. After parsing, create a task for Step 0 and immediately mark it in progress. Then create tasks for each of the remaining 4 steps one at a time, in step order, all starting as pending. Mark Step 0 complete after task list is created.
4. Steps 1-4 (renumbered from current Steps 2-5) -- Add "Mark Step N in progress." as the first line and "Mark Step N complete." as the last line of each step body.
5. Early exit / failure handling:
- Step 1 (Gather Context): Detached HEAD, on default branch, or no changes -> leave Step 1 as
in_progress - Step 2 (Draft PR): User cancels -> leave Step 2 as
in_progress - Step 3 (Create PR): Push failure or
gh pr createfailure -> leave Step 3 asin_progress
6. Update CLAUDE.md -- Add commands/pr-create.md to the Step 0 bootstrap sync list (currently lists 5 command files; becomes 6).
Dependencies
None -- single stage.
Testing
This is a plugin definition (no testable runtime). Verification is by review -- confirm the wording matches the canonical pattern from the 5 reference implementations.
Decision Log
Architecture Choice
Only one viable approach exists: mechanical application of the established task tracking conventions from CLAUDE.md. The current Step 1 (Parse Input) is absorbed into Step 0 (consistent with all reference implementations where Step 0 handles input parsing), and Steps 2-5 are renumbered to Steps 1-4. No alternative architectures were considered because the conventions are fully prescriptive.
Clarifying Questions
- Step 2 granularity: Asked whether Step 2 (Gather Context) should be split into sub-steps to separately track sub-issue detection (motivated by the PR 90 incident). Decision: keep as a single step, following strict 1-to-1 mapping with the current step structure.
This comment will guide staged implementation via /mach10:issue-implement 96 1.
Implementation Plan
Stage 1: Add task tracking to pr-create command
What it accomplishes: Adds full Step 0 bootstrap and per-step task state transitions to commands/pr-create.md, following the established conventions from the 5 existing tracked commands.
Files modified:
commands/pr-create.md(primary)CLAUDE.md(sync list updates)
Changes
1. Frontmatter -- Add TaskCreate, TaskUpdate to allowed-tools:
allowed-tools: Bash, Read, Grep, Glob, AskUserQuestion, TaskCreate, TaskUpdate
2. Restructure steps -- Merge current Step 1 (Parse Input) into a new Step 0 (Parse input and create task list). Renumber current Steps 2-5 to Steps 1-4.
New step structure:
| Step | Subject | activeForm |
|---|---|---|
| Step 0 | Step 0: Parse input and create task list | Parsing input |
| Step 1 | Step 1: Gather context | Gathering context |
| Step 2 | Step 2: Draft PR and get approval | Drafting PR |
| Step 3 | Step 3: Create pull request | Creating pull request |
| Step 4 | Step 4: Confirm PR and suggest next steps | Confirming PR |
3. Step 0 body -- Merge current Step 1 content (parse input logic) with the canonical task creation bootstrap. After parsing, create a task for Step 0 and immediately mark it in progress. Then create tasks for each of the remaining 4 steps one at a time, in step order, all starting as pending. Task list display order matches creation order, so each task must be a separate sequential call -- do not batch multiple task creations in a single message. Store each returned task ID for later use -- do not assume IDs are sequential. Mark Step 0 complete after task list is created.
4. Steps 1-4 (renumbered from current Steps 2-5) -- Add "Mark Step N in progress." as the first line and "Mark Step N complete." as the last line of each step body.
5. Early exit / failure handling:
- Step 1 (Gather Context): Detached HEAD, on default branch, or no changes -> leave Step 1 as
in_progress - Step 2 (Draft PR): User cancels -> leave Step 2 as
in_progress - Step 3 (Create PR): Push failure or
gh pr createfailure -> leave Step 3 asin_progress
6. Update CLAUDE.md -- Three sync sections require updates:
- Step 0 bootstrap sync (line 70): Add
commands/pr-create.mdto the list. Change "five command files" to "six command files" and "all six locations" to "all seven locations". - Issue auto-assignment sync (line 66): Update step reference from
(Step 2, "Sub-issue detection" block)to(Step 1, "Sub-issue detection" block). --commentstwo-call sync (line 68): Update step reference fromcommands/pr-create.md (Step 2)tocommands/pr-create.md (Step 1).
Dependencies
None -- single stage.
Testing
This is a plugin definition (no testable runtime). Verification is by review -- confirm the wording matches the canonical pattern from the 5 reference implementations.
Decision Log
Architecture Choice
Only one viable approach exists: mechanical application of the established task tracking conventions from CLAUDE.md. The current Step 1 (Parse Input) is absorbed into Step 0 (consistent with all reference implementations where Step 0 handles input parsing), and Steps 2-5 are renumbered to Steps 1-4. No alternative architectures were considered because the conventions are fully prescriptive.
Clarifying Questions
- Step 2 granularity: Asked whether Step 2 (Gather Context) should be split into sub-steps to separately track sub-issue detection (motivated by the PR 90 incident). Decision: keep as a single step, following strict 1-to-1 mapping with the current step structure.
This comment will guide staged implementation via /mach10:issue-implement 96 1.
Progress: Stage 1 complete
Implemented task tracking for the pr-create command following the established conventions from the 5 existing tracked commands.
Changes (commit 65b48e6):
commands/pr-create.md: Added Step 0 bootstrap with canonical task creation pattern, renumbered Steps 2-5 to Steps 1-4, added per-step state transitions (in_progress/completed), added early exit handling for detached HEAD, default branch, no changes, user cancel, push failure, and PR creation failureCLAUDE.md: Updated 4 sync sections (Step 0 bootstrap sync,--commentstwo-call sync, Issue auto-assignment sync, Task-tracking instruction sync) to reflect the new step numbering and includepr-createin tracked command lists
No deviations from the implementation plan.