GitHub Issue Workflow
Implement a GitHub issue following TDD principles with integrated code review and QA validation.
Arguments
$ARGUMENTS - GitHub issue URL (e.g., https://github.com/owner/repo/issues/123) or issue number (e.g., 123)
Workflow Overview
┌─────────────────────────────────────────────────────────────────┐
│ 1. Setup → Checkout main, create feature branch │
│ 2. Research → Fetch issue details, research best practices │
│ 3. Plan → Create implementation plan, get user approval │
│ 4. TDD Cycle → Write failing test → Implement → Pass │
│ 5. Code Review → Run go-code-reviewer, incorporate feedback │
│ 6. QA Validate → Run qa-requirements-validator, fix gaps │
│ 7. PR Creation → Commit, push, create pull request │
└─────────────────────────────────────────────────────────────────┘
Process
Phase 1: Environment Setup
Validate working directory is clean:
git status --porcelain
If there are uncommitted changes, warn the user and ask how to proceed.
Checkout and update main branch:
git checkout main && git pull origin main
Parse issue identifier from $ARGUMENTS:
- If URL: Extract owner, repo, and issue number
- If number only: Use current repo context
Fetch issue details:
gh issue view $ISSUE_NUMBER --json title,body,labels,assignees
Create feature branch:
# Branch naming: fix/issue-{number}-{short-description} or feat/issue-{number}-{short-description}
git checkout -b {branch-name}
Phase 2: Research & Understanding
Parse issue requirements:
- Extract acceptance criteria from issue body
- Identify affected components/files
- Note any linked issues or PRs
Research best practices:
- Use WebSearch to find relevant patterns for the problem domain
- Check existing codebase patterns using Glob and Grep
- Review similar implementations in the project
Explore affected code:
- Use the Explore agent to understand the codebase area:
Task(
prompt="Explore how {affected_area} works in this codebase. Find relevant files, understand the architecture, and identify where changes need to be made for: {issue_summary}",
subagent_type="Explore"
)
Document findings:
- Create a mental model of what needs to change
- Identify potential risks or edge cases
Phase 3: Implementation Plan
Create structured plan:
Present to user for approval:
## Implementation Plan for Issue #{number}: {title}
### Requirements (from issue)
- [ ] Requirement 1
- [ ] Requirement 2
...
### Approach
{High-level description of the solution}
### Files to Modify/Create
| File | Action | Purpose |
|------|--------|---------|
| path/to/file.go | Modify | Add X functionality |
| path/to/file_test.go | Create | Test cases for X |
### Test Strategy (TDD)
1. Test case 1: {description}
2. Test case 2: {description}
...
### Risks & Mitigations
- Risk: {potential issue}
Mitigation: {how to handle}
Get user approval:
- Present the plan
- Ask: "Does this plan look good? Should I proceed with implementation?"
- Wait for explicit approval before continuing
Phase 4: TDD Implementation Cycle
For each feature/requirement, follow RED-GREEN-REFACTOR:
4.1 RED: Write Failing Test First
Create/update test file:
- Write test that captures the expected behavior
- Include edge cases identified in planning
Run test to confirm it fails:
go test ./... -run TestNamePattern -v
Verify failure is for the right reason:
- Test should fail because functionality doesn't exist yet
- NOT because of syntax errors or wrong test setup
4.2 GREEN: Implement Minimum Code to Pass
Write implementation:
- Only enough code to make the test pass
- Follow existing code patterns in the project
- Refer to CLAUDE.md for project conventions
Run tests:
go test ./... -v
Iterate until all tests pass
4.3 REFACTOR: Improve Code Quality
Clean up implementation:
- Remove duplication
- Improve naming
- Simplify logic where possible
Ensure tests still pass:
go test ./... -v
Phase 5: Code Review
Run go-code-reviewer agent:
Task(
prompt="Review the code changes I made for GitHub issue #{number}. Focus on:
- KISS (Keep It Simple, Stupid) violations
- DRY (Don't Repeat Yourself) violations
- Go best practices and idioms
- Error handling
- Test coverage quality
The changes are in these files: {list of modified files}
Provide specific, actionable feedback.",
subagent_type="go-code-reviewer"
)
Address feedback:
- For each issue identified:
- If Critical/Important: Fix immediately
- If Suggestion: Evaluate and fix if reasonable
- Run tests after each fix
Re-run reviewer if significant changes made:
- Ensure new issues weren't introduced
Phase 6: QA Validation
Run qa-requirements-validator agent:
Task(
prompt="Validate my implementation against the requirements from GitHub issue #{number}.
Requirements from issue:
{parsed requirements from Phase 2}
Implementation files:
{list of modified files}
Verify each requirement is:
- Fully implemented
- Properly tested
- Handles edge cases
Provide a detailed validation report.",
subagent_type="qa-requirements-validator"
)
Address gaps:
- For any requirement NOT FULFILLED or PARTIALLY FULFILLED:
- Go back to Phase 4 (TDD cycle) for that requirement
- Write test for missing case
- Implement fix
- Re-run QA validation
Continue until all requirements are FULFILLED
Phase 7: Commit & Create PR
Final test run:
go test ./... -v
Stage changes:
git add {specific files}
Create commit:
git commit -m "$(cat <<'EOF'
fix: {short description} (#{issue_number})
{Longer description of what was done}
- {Change 1}
- {Change 2}
Closes #{issue_number}
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
EOF
)"
Push branch:
git push -u origin {branch-name}
Create pull request:
gh pr create --title "{title}" --body "$(cat <<'EOF'
## Summary
Fixes #{issue_number}
{Brief description of changes}
## Changes Made
- {Change 1}
- {Change 2}
## Test Plan
- [ ] All existing tests pass
- [ ] New tests added for {feature}
- [ ] Manually verified {scenario}
## Checklist
- [x] Code follows project style guidelines
- [x] Tests written and passing
- [x] Code reviewed by go-code-reviewer
- [x] Requirements validated by qa-requirements-validator
---
Generated with Claude Code
EOF
)"
Report PR URL to user
Error Handling
Git Conflicts
If merge conflicts occur:
- Report to user with affected files
- Ask for guidance on resolution
- Do NOT auto-resolve conflicts
Test Failures
If tests fail unexpectedly:
- Analyze failure reason
- If test bug: Fix test
- If implementation bug: Fix implementation
- If unclear: Ask user for guidance
API/CLI Errors
If gh commands fail:
- Check if user is authenticated:
gh auth status
- Report specific error to user
- Provide remediation steps
Quality Gates
Before proceeding to each phase, verify:
Output
After completion, provide summary:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
GITHUB ISSUE COMPLETE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Issue: #{number} - {title}
Branch: {branch-name}
PR: {pr-url}
Changes:
- {file1}: {description}
- {file2}: {description}
Tests Added: {count}
Code Review: Passed
QA Validation: All requirements fulfilled
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1---2name: github-issue3description: Work on a GitHub issue end-to-end: checkout main, create branch, research best practices, plan implementation, write tests first (TDD), implement, run code review, QA validation, then create PR. Use when given a GitHub issue URL or number to implement.4---56# GitHub Issue Workflow78Implement a GitHub issue following TDD principles with integrated code review and QA validation.910## Arguments1112- `$ARGUMENTS` - GitHub issue URL (e.g., `https://github.com/owner/repo/issues/123`) or issue number (e.g., `123`)1314## Workflow Overview1516```17┌─────────────────────────────────────────────────────────────────┐18│ 1. Setup → Checkout main, create feature branch │19│ 2. Research → Fetch issue details, research best practices │20│ 3. Plan → Create implementation plan, get user approval │21│ 4. TDD Cycle → Write failing test → Implement → Pass │22│ 5. Code Review → Run go-code-reviewer, incorporate feedback │23│ 6. QA Validate → Run qa-requirements-validator, fix gaps │24│ 7. PR Creation → Commit, push, create pull request │25└─────────────────────────────────────────────────────────────────┘26```2728## Process2930### Phase 1: Environment Setup31321. **Validate working directory is clean:**33 ```bash34 git status --porcelain35 ```36 If there are uncommitted changes, warn the user and ask how to proceed.37382. **Checkout and update main branch:**39 ```bash40 git checkout main && git pull origin main41 ```42433. **Parse issue identifier from $ARGUMENTS:**44 - If URL: Extract owner, repo, and issue number45 - If number only: Use current repo context46474. **Fetch issue details:**48 ```bash49 gh issue view $ISSUE_NUMBER --json title,body,labels,assignees50 ```51525. **Create feature branch:**53 ```bash54 # Branch naming: fix/issue-{number}-{short-description} or feat/issue-{number}-{short-description}55 git checkout -b {branch-name}56 ```5758### Phase 2: Research & Understanding59601. **Parse issue requirements:**61 - Extract acceptance criteria from issue body62 - Identify affected components/files63 - Note any linked issues or PRs64652. **Research best practices:**66 - Use WebSearch to find relevant patterns for the problem domain67 - Check existing codebase patterns using Glob and Grep68 - Review similar implementations in the project69703. **Explore affected code:**71 - Use the Explore agent to understand the codebase area:72 ```73 Task(74 prompt="Explore how {affected_area} works in this codebase. Find relevant files, understand the architecture, and identify where changes need to be made for: {issue_summary}",75 subagent_type="Explore"76 )77 ```78794. **Document findings:**80 - Create a mental model of what needs to change81 - Identify potential risks or edge cases8283### Phase 3: Implementation Plan84851. **Create structured plan:**8687 Present to user for approval:88 ```markdown89 ## Implementation Plan for Issue #{number}: {title}9091 ### Requirements (from issue)92 - [ ] Requirement 193 - [ ] Requirement 294 ...9596 ### Approach97 {High-level description of the solution}9899 ### Files to Modify/Create100 | File | Action | Purpose |101 |------|--------|---------|102 | path/to/file.go | Modify | Add X functionality |103 | path/to/file_test.go | Create | Test cases for X |104105 ### Test Strategy (TDD)106 1. Test case 1: {description}107 2. Test case 2: {description}108 ...109110 ### Risks & Mitigations111 - Risk: {potential issue}112 Mitigation: {how to handle}113 ```1141152. **Get user approval:**116 - Present the plan117 - Ask: "Does this plan look good? Should I proceed with implementation?"118 - Wait for explicit approval before continuing119120### Phase 4: TDD Implementation Cycle121122For each feature/requirement, follow RED-GREEN-REFACTOR:123124#### 4.1 RED: Write Failing Test First1251261. **Create/update test file:**127 - Write test that captures the expected behavior128 - Include edge cases identified in planning1291302. **Run test to confirm it fails:**131 ```bash132 go test ./... -run TestNamePattern -v133 ```1341353. **Verify failure is for the right reason:**136 - Test should fail because functionality doesn't exist yet137 - NOT because of syntax errors or wrong test setup138139#### 4.2 GREEN: Implement Minimum Code to Pass1401411. **Write implementation:**142 - Only enough code to make the test pass143 - Follow existing code patterns in the project144 - Refer to CLAUDE.md for project conventions1451462. **Run tests:**147 ```bash148 go test ./... -v149 ```1501513. **Iterate until all tests pass**152153#### 4.3 REFACTOR: Improve Code Quality1541551. **Clean up implementation:**156 - Remove duplication157 - Improve naming158 - Simplify logic where possible1591602. **Ensure tests still pass:**161 ```bash162 go test ./... -v163 ```164165### Phase 5: Code Review1661671. **Run go-code-reviewer agent:**168 ```169 Task(170 prompt="Review the code changes I made for GitHub issue #{number}. Focus on:171 - KISS (Keep It Simple, Stupid) violations172 - DRY (Don't Repeat Yourself) violations173 - Go best practices and idioms174 - Error handling175 - Test coverage quality176177 The changes are in these files: {list of modified files}178179 Provide specific, actionable feedback.",180 subagent_type="go-code-reviewer"181 )182 ```1831842. **Address feedback:**185 - For each issue identified:186 - If Critical/Important: Fix immediately187 - If Suggestion: Evaluate and fix if reasonable188 - Run tests after each fix1891903. **Re-run reviewer if significant changes made:**191 - Ensure new issues weren't introduced192193### Phase 6: QA Validation1941951. **Run qa-requirements-validator agent:**196 ```197 Task(198 prompt="Validate my implementation against the requirements from GitHub issue #{number}.199200 Requirements from issue:201 {parsed requirements from Phase 2}202203 Implementation files:204 {list of modified files}205206 Verify each requirement is:207 - Fully implemented208 - Properly tested209 - Handles edge cases210211 Provide a detailed validation report.",212 subagent_type="qa-requirements-validator"213 )214 ```2152162. **Address gaps:**217 - For any requirement NOT FULFILLED or PARTIALLY FULFILLED:218 - Go back to Phase 4 (TDD cycle) for that requirement219 - Write test for missing case220 - Implement fix221 - Re-run QA validation2222233. **Continue until all requirements are FULFILLED**224225### Phase 7: Commit & Create PR2262271. **Final test run:**228 ```bash229 go test ./... -v230 ```2312322. **Stage changes:**233 ```bash234 git add {specific files}235 ```2362373. **Create commit:**238 ```bash239 git commit -m "$(cat <<'EOF'240 fix: {short description} (#{issue_number})241242 {Longer description of what was done}243244 - {Change 1}245 - {Change 2}246247 Closes #{issue_number}248249 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>250 EOF251 )"252 ```2532544. **Push branch:**255 ```bash256 git push -u origin {branch-name}257 ```2582595. **Create pull request:**260 ```bash261 gh pr create --title "{title}" --body "$(cat <<'EOF'262 ## Summary263264 Fixes #{issue_number}265266 {Brief description of changes}267268 ## Changes Made269270 - {Change 1}271 - {Change 2}272273 ## Test Plan274275 - [ ] All existing tests pass276 - [ ] New tests added for {feature}277 - [ ] Manually verified {scenario}278279 ## Checklist280281 - [x] Code follows project style guidelines282 - [x] Tests written and passing283 - [x] Code reviewed by go-code-reviewer284 - [x] Requirements validated by qa-requirements-validator285286 ---287 Generated with Claude Code288 EOF289 )"290 ```2912926. **Report PR URL to user**293294## Error Handling295296### Git Conflicts297If merge conflicts occur:2981. Report to user with affected files2992. Ask for guidance on resolution3003. Do NOT auto-resolve conflicts301302### Test Failures303If tests fail unexpectedly:3041. Analyze failure reason3052. If test bug: Fix test3063. If implementation bug: Fix implementation3074. If unclear: Ask user for guidance308309### API/CLI Errors310If `gh` commands fail:3111. Check if user is authenticated: `gh auth status`3122. Report specific error to user3133. Provide remediation steps314315## Quality Gates316317Before proceeding to each phase, verify:318319- [ ] **Phase 1 → 2**: Branch created, issue details fetched320- [ ] **Phase 2 → 3**: Requirements understood, codebase explored321- [ ] **Phase 3 → 4**: User approved the plan322- [ ] **Phase 4 → 5**: All tests pass, implementation complete323- [ ] **Phase 5 → 6**: Code review feedback addressed324- [ ] **Phase 6 → 7**: All requirements validated as FULFILLED325- [ ] **Phase 7 complete**: PR created and URL provided326327## Output328329After completion, provide summary:330331```332━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━333 GITHUB ISSUE COMPLETE334━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━335336Issue: #{number} - {title}337Branch: {branch-name}338PR: {pr-url}339340Changes:341- {file1}: {description}342- {file2}: {description}343344Tests Added: {count}345Code Review: Passed346QA Validation: All requirements fulfilled347348━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━349```