7.6 KiB
Implement GitHub Issue - Automated Workflow
You are orchestrating the complete implementation → review → merge pipeline for issue $ARGUMENTS.
Your Mission
Execute this workflow autonomously without stopping between phases unless errors occur:
- Phase 1: Implementation - Launch issue-implementer agent
- Phase 2: Review - Launch review-orchestrator agent (3 parallel checks)
- Phase 3: Merge - Launch issue-merger agent
Do NOT stop between phases to ask the user. Only stop if:
- An agent returns an error
- Review decision is "REQUEST_CHANGES" (report feedback to user)
- Merge fails due to conflicts (report to user)
Execution Instructions
Phase 1: Implementation
Launch the issue-implementer agent with issue number $ARGUMENTS:
Use the Task tool with:
- subagent_type: issue-implementer
- description: "Implement issue $ARGUMENTS"
- prompt: "Implement issue $ARGUMENTS following the 8-step workflow."
If API returns 500 "Overloaded" error:
- Automatically retry up to 2 more times (3 attempts total)
- Wait 5 seconds between retries
- Log: "API overloaded, retrying in 5 seconds... (attempt X/3)"
- Only fail if all 3 attempts return 500 errors
After agent completes, verify actual implementation:
# Check manifest exists
if [ -f ".agent-state/issue-$ARGUMENTS-implementation.yaml" ]; then
STATUS=$(grep "status:" .agent-state/issue-$ARGUMENTS-implementation.yaml | cut -d: -f2 | tr -d ' ')
# Verify implementation artifacts
BRANCH=$(grep "branch:" .agent-state/issue-$ARGUMENTS-implementation.yaml | cut -d: -f2 | tr -d ' "')
# Check branch exists
if ! git rev-parse --verify "$BRANCH" >/dev/null 2>&1; then
echo "⚠️ Warning: Branch $BRANCH not found, but status is $STATUS"
echo "This may indicate implementation succeeded despite error messages"
fi
# For AWS operations, verify resources exist (if applicable)
# This will be handled in implementation verification section below
else
echo "❌ ERROR: Implementation manifest not found"
echo "Agent may have failed before completion"
exit 1
fi
Verify Implementation Success: Check actual state, not just manifest:
- Branch exists:
git rev-parse --verify feature/issue-$ARGUMENTS - Commits pushed:
git log origin/feature/issue-$ARGUMENTS - Issue labeled:
gh issue view $ARGUMENTS --json labels | grep ready_for_review
Using the verification helper script:
# Verify branch exists
~/.claude/scripts/verify-github-operation.sh branch-exists $ARGUMENTS feature/issue-$ARGUMENTS
# Verify label updated
~/.claude/scripts/verify-github-operation.sh label-updated $ARGUMENTS ready_for_review
The verification script provides color-coded output and clear success/failure indicators.
If status is "ready_for_review" and verification passes, print:
✅ Phase 1 Complete: Implementation
📋 Files changed: [list from manifest]
📊 Status: ready_for_review
⏭️ Continuing to review phase...
Then proceed to Phase 2 immediately.
Phase 2: Review
Launch the review-orchestrator agent:
Use the Task tool with:
- subagent_type: review-orchestrator
- description: "Review issue $ARGUMENTS"
- prompt: "Orchestrate code review for issue $ARGUMENTS. Coordinate security, quality, and documentation checks in parallel. Create PR if approved."
Wait for completion, then check:
cat .agent-state/issue-$ARGUMENTS-review.yaml | grep "decision:"
If decision is "APPROVE", verify and report:
Verify Review Completion:
# Verify PR was created
~/.claude/scripts/verify-github-operation.sh pr-created $ARGUMENTS
# Verify label updated to ready_for_merge
~/.claude/scripts/verify-github-operation.sh label-updated $ARGUMENTS ready_for_merge
If verification passes, print:
✅ Phase 2 Complete: Review
🔒 Security: PASS (0 issues)
⚡ Quality: PASS
📚 Documentation: PASS
🎯 Decision: APPROVE
📝 PR created and label updated
⏭️ Continuing to merge phase...
Then proceed to Phase 3 immediately.
If decision is "REQUEST_CHANGES", print:
❌ Phase 2: Changes Requested
📝 Feedback: [show blocking issues from manifest]
🔄 Issue returned to "To Do" status
Workflow stopped. Address the feedback and re-run /implement-issue $ARGUMENTS
Stop here and report to user.
Phase 3: Merge
Launch the issue-merger agent:
Use the Task tool with:
- subagent_type: issue-merger
- description: "Merge PR for issue $ARGUMENTS"
- prompt: "Merge the approved pull request for issue $ARGUMENTS. Handle conflict resolution if needed, update all tracking systems, and cleanup worktrees."
Wait for completion, then verify and report:
Verify Merge Completion:
# Verify PR was merged
~/.claude/scripts/verify-github-operation.sh pr-merged $ARGUMENTS
# Verify issue was closed
~/.claude/scripts/verify-github-operation.sh issue-closed $ARGUMENTS
If verification passes, print:
✅ Phase 3 Complete: Merge
🔗 PR merged and verified
📦 Commit: [SHA from merger output]
🏁 Issue #$ARGUMENTS closed and verified
✨ Workflow complete
Error Handling
Error Recovery Protocol:
-
Check actual state before failing:
- Implementation phase: Verify branch exists, files changed, commits pushed
- Review phase: Verify PR created (if approved), issue labeled correctly
- Merge phase: Verify PR merged, issue closed, branch deleted
-
For API 500 "Overloaded" errors specifically:
- These are temporary overload, not failures
- Automatically retry up to 2 more times (3 attempts total)
- Wait 5 seconds between retries
- Only fail if all 3 attempts return errors
-
For "operation failed" but state shows success:
- Log warning but continue workflow
- Example: "Connection closed" error but AWS resource actually exists
- Report to user: "Operation completed successfully despite error message"
-
For actual failures:
- Stop workflow immediately
- Show clear error with phase name and details
- Provide specific recovery steps
- Preserve work (don't delete worktree/branch)
Common errors:
- "Issue not found" → Check issue number format (should be just number, not URL)
- "No implementation manifest" → Run implementer first
- "Review not approved" → Address review feedback and re-run workflow
- "Merge conflicts" → Resolve manually, then re-run merge phase
- "API Overloaded" → Automatic retry (up to 3 attempts)
- "Label not updated" → Manually update via:
gh issue edit NUMBER --add-label LABEL
Status Reporting
After each phase completion, use this format:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Phase [N]: [Phase Name]
✅ Status: [Complete/Failed]
📊 Details: [Key information]
⏭️ Next: [What happens next]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Final Report
After Phase 3 completes successfully, provide:
🎉 Issue #$ARGUMENTS Implementation Complete
📊 Summary:
• Implementation: [files changed]
• Review: [decision + check results]
• Merge: [PR number + commit SHA]
🔗 Links:
• Issue: https://github.com/Mygentic-AI/mygentic-personal-assistant/issues/$ARGUMENTS
• PR: [PR URL from merger output]
• Commit: [commit URL]
✅ All tracking systems updated
✅ Worktree cleaned up
✅ Branches deleted
Start now with issue $ARGUMENTS. Do not ask for confirmation between phases.