pr-review-fix: post-delegation re-anchoring insufficient to complete Steps 3-4
Summary
/mach10:pr-review-fix still fails to mark Steps 3 and 4 as completed and doesn't suggest /mach10:push as the next step after the feature-dev delegation returns. The re-anchoring prose added in PR #118 (Fixes #117) is not reliably preventing the issue.
Current Behavior
After the feature-dev delegation in Step 3 completes (all 7 phases finish successfully), the command exits without:
- Marking Step 3 as
completed - Executing Step 4 (mark in progress, suggest next steps, mark completed)
The task list shows:
◼ Step 3: Fix review findings via feature-dev
◻ Step 4: Recommend next steps
✔ Step 0-2 and Phase 1-7 all completed
Proposed Behavior
After feature-dev finishes, the command should reliably mark Step 3 complete, execute Step 4 (recommend /mach10:push), and mark Step 4 complete.
Acceptance Criteria
- Step 3 is reliably marked
completedafter the feature-dev Skill invocation returns - Step 4 is reliably marked
in_progress, the next-step suggestion is output, and Step 4 is markedcompleted - All 5 steps (0-4) show
completedwhen the command finishes normally - The
/mach10:pushnext-step suggestion is consistently output
Context
- Issue #117 identified this problem and added re-anchoring prose (PR #118)
- Issue #111 was closed as a duplicate of #117
- The problem persists after #118 was merged, indicating re-anchoring prose alone is insufficient for this delegation pattern
- The feature-dev 7-phase delegation is the longest-running Skill call in any mach10 command, likely consuming enough context to overwhelm the re-anchoring signal
Technical Notes
- The current re-anchoring in
pr-review-fix.mdfollows the pattern frompr-review.mdStep 2, butpr-review.md's delegation (/pr-review-toolkit:review-pr) is likely shorter than the 7-phase feature-dev workflow, which may explain why re-anchoring works there but not here - The CLAUDE.md "Post-delegation re-anchoring" guideline (added in #118) may need strengthening or supplementing with a different technique for long-running delegations
- Consider whether a structural change (e.g., explicit post-delegation section header, repeated task ID references, or instruction duplication) would be more resilient than prose alone
- Check whether
issue-implement.mdandpr-ci-fix.md(which also delegate to feature-dev) will face the same issue when task tracking is added (part of #81)
Independent Assessment
Summary
The re-anchoring prose added in PR #118 is insufficient to reliably return control after the feature-dev Skill delegation. The feature-dev call is the longest Skill call in any mach10 command, consuming enough outer context to overwhelm a single bridging sentence.
Current State
pr-review-fix.md Step 3 ends with:
Let the feature-dev workflow complete fully. When it finishes, all code changes
for the selected findings should be in place.
Mark Step 3 complete.
The bridge sentence is narrative ("let it complete fully") rather than a concrete conditional. The model can skim past it after a long multi-phase delegation.
Gaps
The current bridge sentence doesn't tie the completion marker to anything verifiable. "Let the feature-dev workflow complete fully" is vague -- the model has no checkpoint to confirm before proceeding.
Recommendation
Try a simple fix first: replace the narrative bridge with an explicit conditional that gives the model a verifiable checkpoint:
"Once all phases of the feature-dev workflow are complete, mark Step 3 complete."
This is a meaningful improvement over the current prose because it reads as an actionable directive with a concrete precondition, not a narrative description. If this proves insufficient (i.e., the model still doesn't attend to the instructions after heavy context consumption), escalate to a structural approach: a prominent ### header block after the Skill invocation that concentrates all post-delegation instructions in a single, high-salience section.
Scope
Minimal change: rewrite 2-3 lines in pr-review-fix.md Step 3 post-delegation prose. Potentially update the CLAUDE.md re-anchoring spec if the wording guidance changes.
Implementation Plan
Stage 1: Strengthen re-anchoring prose in pr-review-fix.md
Goal: Replace the weak narrative bridge with an explicit conditional directive that reliably returns control after the feature-dev Skill delegation.
Files modified:
commands/pr-review-fix.md(line 127)
What changes:
- Replace the narrative sentence at line 127 ("Let the feature-dev workflow complete fully. When it finishes, all code changes for the selected findings should be in place.") with an explicit conditional directive: "When the Skill tool returns, you are back in pr-review-fix Step 3. The feature-dev workflow is complete and all code changes for the selected findings are in place. Using the Step 3 task ID stored in Step 0, mark Step 3 complete, then immediately proceed to Step 4."
- Keep "Mark Step 3 complete." as the standalone sentinel line (line 129) -- consistent with all other steps
- Keep Step 4 (lines 131-139) unchanged -- the existing re-anchor sentence at line 133 serves as harmless reinforcement
Testing: No testable runtime code (plugin command definition). Verification is manual: re-run /mach10:pr-review-fix on a real PR and confirm Steps 3-4 complete.
Stage 2: Update CLAUDE.md re-anchoring spec and version bump
Goal: Strengthen the normative spec so future commands (and future task-tracking additions to issue-implement.md and pr-ci-fix.md per issue 81) follow the stronger pattern.
Files modified:
CLAUDE.md(line 109 -- "Post-delegation re-anchoring" bullet).claude-plugin/plugin.json(version bump)
What changes:
- Replace "Add a bridging sentence that re-establishes the command's position in the workflow before the 'Mark Step N complete.' line." with a three-requirement specification: (1) open with a conditional guard on Skill return ("When the Skill tool returns, you are back in <command> Step N"), (2) state in past tense that the delegated work is complete, and (3) explicitly direct the next two actions by name -- mark the Step N task complete using the stored task ID, then proceed to Step N+1
- Keep the "This applies to Skill delegations only" sentence and the example pointer to
pr-review-fix.mdStep 3 (now pointing to the corrected code) - Bump plugin version
Depends on: Stage 1 (so the example reference points to corrected code)
Testing: No testable runtime code.
Decision Log
Architecture Choice
Selected the Minimal Changes approach over two alternatives:
- Directive-rich: Would have removed the standalone "Mark Step N complete." sentinel and provided a CLAUDE.md template. Rejected because it restructures Step 4 and breaks consistency with other steps.
- Redundant cascade: Would have added a redundant catch point in Step 4 and merged the directive into the paragraph. Rejected because it has the largest change surface and was not needed as a first attempt.
The minimal approach was chosen because it has the smallest change surface, preserves existing patterns, and can be escalated to the redundant cascade approach if it proves insufficient.
This plan will guide staged implementation via /mach10:issue-implement.
Implementation Plan
Stage 1: Replace re-anchoring with early-completion pattern in pr-review-fix.md
Goal: Eliminate the re-anchoring problem structurally by marking the delegating step complete before the Skill invocation, and using hierarchical task naming for delegated phases. The task list state replaces prose as the re-anchoring signal.
Files modified:
commands/pr-review-fix.md(Steps 3 and 4)
What changes:
Step 3 restructure:
- Move "Mark Step 3 complete." to before the Skill tool invocation. Step 3's responsibility becomes "prepare and launch the delegation" -- completion indicates the handoff happened, not that the fixes are done.
- In the Skill invocation blockquote, change the phase naming convention from
"Phase N: <action>"to"Step 3.N: <action>". This creates a visible parent-child relationship in the flat task list. Require at least 1 sub-step to be created when delegating. - Remove the post-delegation re-anchoring prose at line 127 ("Let the feature-dev workflow complete fully...") -- no longer needed.
- Remove the standalone sentinel "Mark Step 3 complete." at line 129 -- already handled before the Skill invocation.
Step 4:
- Remove the bridging sentence at line 133 ("The feature-dev delegation from Step 3 is now complete. This is the final step of the pr-review-fix command.") -- redundant since the task list already shows Step 3 as complete.
- The rest of Step 4 (mark in progress, suggest
/mach10:push, mark complete) is unchanged.
Result: When the Skill returns, the model sees Step 3 already complete and Step 4 pending in the task list. No post-delegation prose is needed.
Task list during execution (flat, but visually grouped by naming):
✔ Step 0: Parse input and create task list
✔ Step 1: Gather PR and review context
✔ Step 2: Identify issues to fix
✔ Step 3: Fix review findings via feature-dev
✔ Step 3.1: Understand the codebase
✔ Step 3.2: Design the solution
◼ Step 3.5: Implement changes
◻ Step 3.6: Test
◻ Step 3.7: Final review
◻ Step 4: Recommend next steps
Testing: Manual. Re-run /mach10:pr-review-fix on a real PR with at least one finding. Verify all steps (0-4) show completed and the /mach10:push suggestion is output.
Stage 2: Update CLAUDE.md conventions and version bump
Goal: Replace the re-anchoring spec with the early-completion convention, update phase naming, and note pending commands.
Files modified:
CLAUDE.md(lines 109-110 -- "Post-delegation re-anchoring" and "Delegation phase tracking" bullets).claude-plugin/plugin.json(version bump)
What changes:
Replace "Post-delegation re-anchoring" bullet (line 109) with a new "Delegation step completion" convention:
- When a tracked step delegates to a Skill (via the Skill tool), mark the step complete before the Skill invocation. The step's responsibility is preparing and launching the delegation, not awaiting its result.
- The delegated Skill creates sub-tasks using hierarchical naming:
"Step N.M: <action>"where N is the parent step number and M is the phase sequence. At least one sub-task must be created. - When the Skill returns, the task list shows the parent step complete and the next step pending -- the task list state is the re-anchoring signal, no prose needed.
- Note:
issue-implement.mdandpr-ci-fix.mddo not yet have task tracking; when tracking is added (issue 81), they must follow this convention for their feature-dev delegations.
Update "Delegation phase tracking" bullet (line 110):
- Change naming convention from
"Phase N: <action>"to"Step N.M: <action>". - Update rationale: hierarchical naming serves dual purpose -- it distinguishes delegated phases from command steps AND creates a visible parent-child relationship in the flat task list.
Update sync notes:
- Task-tracking instruction sync: update to reflect
"Step N.M:"convention. - Remove the "See
pr-review-fix.mdStep 3 for an example" pointer from the old re-anchoring bullet.
Bump plugin version.
Depends on: Stage 1 (so the convention describes what's already implemented).
Testing: Manual. Same as Stage 1.
Relationship to Other Commands
pr-review.mdStep 2 (delegates to/pr-review-toolkit:review-pr): Currently uses re-anchoring prose that works. Can optionally adopt the new pattern but is not in scope for this issue.issue-implement.mdandpr-ci-fix.md: No task tracking yet. When tracking is added (issue 81), these commands should use the early-completion pattern from the start.
Decision Log
Architecture Choice
Selected the early-completion with hierarchical naming approach over three prose-based alternatives:
- Strengthened re-anchoring: Rewrite the bridge sentence as an explicit conditional directive. Rejected because it still relies on the model attending to post-delegation prose -- the root cause of the failure.
- Directive-rich: Remove the sentinel and provide a CLAUDE.md template. Same fundamental limitation.
- Redundant cascade: Multiple catch points. Largest change surface and still prose-dependent.
The early-completion approach eliminates the problem structurally: the task list state replaces prose as the re-anchoring signal. The model doesn't need to attend to any post-delegation instructions -- it reads the task list and sees what's next.
Implementation Plan
Stage 1: Replace re-anchoring with early-completion pattern in pr-review-fix.md
Goal: Eliminate the re-anchoring problem structurally by marking the delegating step complete before the Skill invocation, and using hierarchical task naming for delegated phases. The task list state replaces prose as the re-anchoring signal.
Files modified:
commands/pr-review-fix.md(Steps 0, 3, and 4)
What changes:
Step 0 update:
- Rename Step 3 task creation: subject becomes
"Step 3: Delegate review fixes to feature-dev", activeForm becomes"Delegating review fixes to feature-dev". The delegation verb makes it self-evident that the step completes when the handoff happens, not when the fixes are done.
Step 3 restructure:
- Rename heading from
## Step 3: Fix review findings via feature-devto## Step 3: Delegate review fixes to feature-dev. - Move "Mark Step 3 complete." to before the Skill tool invocation. Step 3's responsibility becomes "prepare and launch the delegation" -- completion indicates the handoff happened, not that the fixes are done. Add a brief note clarifying this semantic: "Step 3 is now complete. The task list state (Step 3 complete, Step 4 pending) is the re-anchoring signal for when the Skill returns."
- In the Skill invocation blockquote, change the phase naming convention from
"Phase N: <action>"to"Step 3.N: <action>". This creates a visible parent-child relationship in the flat task list. Require at least 1 sub-step to be created when delegating. - Remove the post-delegation re-anchoring prose at line 127 ("Let the feature-dev workflow complete fully...") -- no longer needed.
- Remove the standalone sentinel "Mark Step 3 complete." at line 129 -- already handled before the Skill invocation.
Step 4:
- Remove the bridging sentence at line 133 ("The feature-dev delegation from Step 3 is now complete. This is the final step of the pr-review-fix command.") -- redundant since the task list already shows Step 3 as complete.
- The rest of Step 4 (mark in progress, suggest
/mach10:push, mark complete) is unchanged.
Result: When the Skill returns, the model sees Step 3 already complete and Step 4 pending in the task list. No post-delegation prose is needed.
Skill failure behavior: If the Skill invocation fails after Step 3 is marked complete, the task list will show Step 3 as completed with incomplete or failed sub-tasks underneath and Step 4 still pending. This is an accepted trade-off: Step 3 completion indicates the handoff succeeded, not that fixes are done. Sub-task status shows implementation progress. This mirrors how CI pipelines report "job dispatched" vs. "job succeeded" as separate states.
Task list during execution (flat, but visually grouped by naming):
completed Step 0: Parse input and create task list
completed Step 1: Gather PR and review context
completed Step 2: Identify issues to fix
completed Step 3: Delegate review fixes to feature-dev
completed Step 3.1: Understand the codebase
completed Step 3.2: Design the solution
in_progress Step 3.5: Implement changes
pending Step 3.6: Test
pending Step 3.7: Final review
pending Step 4: Recommend next steps
Testing: Manual. Re-run /mach10:pr-review-fix on a real PR with at least one finding. Verify all steps (0-4) show completed and the /mach10:push suggestion is output.
Stage 2: Update CLAUDE.md conventions and version bump
Goal: Replace the re-anchoring spec with the early-completion convention, update phase naming, reconcile the state transitions policy, and note pending commands.
Files modified:
CLAUDE.md(lines 107, 109, 110, and sync note at line 69).claude-plugin/plugin.json(version bump)
What changes:
Update "State transitions" bullet (line 107): Add an exception for Skill delegations: "Exception: when a step's sole purpose is to prepare and launch a Skill delegation, mark it complete before the Skill invocation. The delegated Skill creates sub-tasks that track implementation progress; the step completion indicates the handoff succeeded. Name the step to reflect the handoff (e.g., 'Delegate ...' rather than 'Fix ...') so that completion before the delegated work starts is self-evident from the task name."
Replace "Post-delegation re-anchoring" bullet (line 109) with a new "Delegation step completion" convention:
- When a tracked step delegates to a Skill (via the Skill tool), mark the step complete before the Skill invocation. The step's responsibility is preparing and launching the delegation, not awaiting its result.
- The delegated Skill creates sub-tasks using hierarchical naming:
"Step N.M: <action>"where N is the parent step number and M is the phase sequence. At least one sub-task must be created. - When the Skill returns, the task list shows the parent step complete and the next step pending -- the task list state is the re-anchoring signal, no prose needed.
- This applies to Skill delegations only -- Task subagent calls do not consume the outer model's context and do not need this pattern.
- Note:
issue-implement.mdandpr-ci-fix.mddo not yet have task tracking; when tracking is added (issue 81), they must follow this convention for their feature-dev delegations.
Update "Delegation phase tracking" bullet (line 110):
- Change naming convention from
"Phase N: <action>"to"Step N.M: <action>". - Update rationale: hierarchical naming serves dual purpose -- it distinguishes delegated phases from command steps AND creates a visible parent-child relationship in the flat task list.
Update "Task-tracking instruction sync" note (line 69):
- Replace the parenthetical "(with
"Phase N:"convention)" with "(with"Step N.M:"convention)". - Update the description to reflect the new naming.
Update sync notes:
- Remove the "See
pr-review-fix.mdStep 3 for an example" pointer from the old re-anchoring bullet (replaced by the new convention description).
Bump plugin version.
Depends on: Stage 1 (so the convention describes what's already implemented).
Testing: Manual. Same as Stage 1.
Relationship to Other Commands
pr-review.mdStep 2 (delegates to/pr-review-toolkit:review-pr): Currently uses the same prose-between-delegation-and-completion pattern (lines 70-72). Not in scope for this issue but should be evaluated for adoption of the early-completion pattern in a follow-up. The new CLAUDE.md convention will apply to it.issue-implement.mdandpr-ci-fix.md: No task tracking yet. When tracking is added (issue 81), these commands should use the early-completion pattern from the start.
Decision Log
Architecture Choice
Selected the early-completion with hierarchical naming approach over three prose-based alternatives:
- Strengthened re-anchoring: Rewrite the bridge sentence as an explicit conditional directive. Rejected because it still relies on the model attending to post-delegation prose -- the root cause of the failure.
- Directive-rich: Remove the sentinel and provide a CLAUDE.md template. Same fundamental limitation.
- Redundant cascade: Multiple catch points. Largest change surface and still prose-dependent.
The early-completion approach eliminates the problem structurally: the task list state replaces prose as the re-anchoring signal. The model doesn't need to attend to any post-delegation instructions -- it reads the task list and sees what's next.
Accepted Trade-offs
- Skill failure diagnostic shift: Step 3 will show
completedeven if the Skill fails. Diagnostic information moves to sub-task status rather than parent step status. This is accepted because the alternative (unreliable post-delegation completion) is worse. - "At least one sub-task" is unenforceable: This is a model instruction, not a runtime check. If the Skill fails before creating any sub-tasks, the task list shows Step 3 complete with zero sub-tasks. Accepted as an edge case unlikely to cause confusion in practice.
Naming Convention
Step 3 renamed from "Fix review findings via feature-dev" to "Delegate review fixes to feature-dev". The delegation verb makes the early-completion semantic self-evident from the task name alone -- completion means the handoff happened, not that the work is done. This was added based on plan review feedback.
Stage 1 Complete
Replaced the post-delegation re-anchoring prose in pr-review-fix.md with the early-completion pattern.
Changes (commit 31df41c):
- Step 0: Renamed Step 3 task to "Delegate review fixes to feature-dev" so the delegation verb makes early-completion semantics self-evident from the task name
- Step 3: Moved completion marker before the Skill invocation with a semantic note; changed phase naming from
"Phase N:"to"Step 3.N:"for hierarchical parent-child visibility; removed post-delegation re-anchoring prose and standalone sentinel - Step 4: Removed the bridging sentence (redundant -- task list state now serves as the re-anchoring signal)
Known intermediate state: CLAUDE.md line 69 still references the old "Phase N:" convention for pr-review-fix -- this will be updated in Stage 2.
Next: Stage 2 (update CLAUDE.md conventions and version bump).
Stage 2 Complete
Updated CLAUDE.md task-tracking conventions to document the early-completion delegation pattern and bumped the plugin version.
Changes (commit e524f52):
- State transitions (line 107): Added exception for Skill delegation steps that complete before invocation
- Skill and subagent delegations (line 108): Updated to reflect that Skill phases are tracked via hierarchical sub-tasks, while Task subagent phases are not
- Delegation step completion (line 109): Replaced "Post-delegation re-anchoring" with the early-completion convention -- mark step complete before Skill invocation, task list state is the re-anchoring signal
- Delegation phase tracking (line 110): Changed naming from
"Phase N:"to"Step N.M:"with updated rationale - Task-tracking instruction sync (line 69): Updated
"Phase N:"reference to"Step N.M:" - Version bump: 1.24.0 -> 1.24.1
Additional fix: Line 108 was updated beyond the original plan scope -- code review identified that "Don't track the delegated skill's internal phases from the command level" now contradicted the new Skill delegation convention.
Next: PR creation and review.
Review session decisions (PR #122)
Ran /mach10:pr-review on PR #122. The review found 5 findings (F1-F5) and 4 suggestions (S1-S4). Independent assessment classified 2 as genuine (F1, F2), 2 as false positives (F3, F5), 1 as nitpick (F4), and 1 as deferred (S4).
Decisions
F1 (Genuine): CLAUDE.md overgeneralizes early-completion to all Skill delegations
- The "Delegation phase tracking" bullet had a fan-out/fan-in opt-out that contradicted the "Delegation step completion" rule requiring at least one sub-task for all delegations.
- Decision: Remove the opt-out. All Skill delegations must create sub-tasks. Skills with explicit phases create a task per phase; skills without pre-defined phases use best judgment on granularity but must still create at least one sub-task.
- Also updating
pr-review.mdStep 2 to follow the early-completion pattern (rename to "Delegate PR review to pr-review-toolkit", mark complete before Skill invocation, add sub-task creation instruction).
F2 (Genuine): CLAUDE.md states "no prose needed" but pr-review-fix.md adds explanatory prose
- Decision: Remove the explanatory prose from
pr-review-fix.mdline 107, leaving just "Mark Step 3 complete." The convention document owns the rationale.
S4 (Deferred): Move forward-looking note about issue-implement.md/pr-ci-fix.md
- Decision: Skipped. Documentation placement judgment call, not worth a separate change.
F3, F4, F5, S1-S3: False positives/nitpicks, no action taken.