Execute a Task or Epic, routing to TDD or non-TDD workflow based on commit type.
/plugin marketplace add el-feo/ai-context/plugin install ghpm@jebs-dev-tools/ghpm:tdd-task): For feat, fix, refactor commit typestest, docs, chore, style, perf commit typesBoth workflows produce identical outputs: conventional commits, Task Report, and a PR that closes the Task. </objective>
<arguments> **Optional arguments:** - `task=#123` - Specific task issue number - `epic=#123` - Epic issue number (executes all open tasks under the epic)Resolution order if omitted:
ghpm/task-<N>-* or task-<N>-*, use NTask assigned to @me:
gh issue list -l Task -a @me -s open --limit 1 --json number -q '.[0].number'gh issue list -l Task -s open --limit 1 --json number -q '.[0].number'
</arguments>
<usage_examples> Execute a single task (auto-routes based on commit type):
/ghpm:execute task=#42
Execute all tasks under an epic:
/ghpm:execute epic=#10
Auto-resolve from branch or GitHub:
/ghpm:execute
</usage_examples>
<operating_rules>
/ghpm:tdd-task - do not duplicate its workflow.<routing_logic>
Read the Task issue body and extract the Commit Type field:
- Commit Type: `<type>`
Before applying commit-type routing, check if the task matches these Non-TDD patterns:
Auto-route to Non-TDD if:
*.md, *.yml, *.yaml, *.json, *.toml, *.txtcommands/**/*.md or .claude/commands/**/*.mdskills/**/*.md or .claude/skills/**/*.mddocs, commands, skills, configThese patterns indicate work where TDD is not applicable (tests cannot be written for markdown/config files).
If no Non-TDD pattern matched, route based on commit type:
Route to TDD workflow (/ghpm:tdd-task):
feat - New features benefit from test-first development (when targeting code files)fix - Bug fixes need tests to verify the fixrefactor - Refactoring requires tests to ensure behavior is preservedRoute to Non-TDD workflow (execute directly):
test - Adding tests doesn't need TDD (you're already writing tests)docs - Documentation changes don't need testschore - Build/CI/tooling changes typically don't need unit testsstyle - Formatting changes don't need testsperf - Performance changes may have benchmarks, not TDD cyclesIf Commit Type is missing or unclear:
.rb, .js, .ts, .py, .go, etc.).md, .yml, .json, etc.)</routing_logic>
<conventional_commits>
All commits and PR titles must follow the Conventional Commits specification.
<type>[optional scope]: <description> (#<issue>)
| Type | Description | Changelog Section |
|---|---|---|
feat | New feature or capability | Features |
fix | Bug fix | Bug Fixes |
refactor | Code restructuring without behavior change | Code Refactoring |
perf | Performance improvement | Performance |
test | Adding or updating tests | Testing |
docs | Documentation only changes | Documentation |
style | Formatting, whitespace (no code change) | (excluded) |
chore | Build, CI, dependencies, tooling | Maintenance |
</conventional_commits>
<workflow>epic=#N providedEPIC=$N
# Get repository owner and name
OWNER=$(gh repo view --json owner -q '.owner.login')
REPO=$(gh repo view --json name -q '.name')
# Fetch all open sub-issues (Tasks) under this Epic using GraphQL API
# GitHub sub-issues are linked via parent-child relationship, NOT by text mention
# NOTE: Use heredoc to avoid shell escaping issues with '!' characters
cat > /tmp/ghpm-subissues.graphql << 'GRAPHQL'
query($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
issue(number: $number) {
subIssues(first: 50) {
nodes {
number
title
state
labels(first: 10) {
nodes { name }
}
}
}
}
}
}
GRAPHQL
gh api graphql -F owner="$OWNER" -F repo="$REPO" -F number=$EPIC \
-f query="$(cat /tmp/ghpm-subissues.graphql)" \
--jq '.data.repository.issue.subIssues.nodes[] | select(.state == "OPEN") | select(.labels.nodes[].name == "Task") | [.number, .title] | @tsv'
Before processing tasks, analyze all task bodies to detect interdependencies:
| Scenario | Strategy |
|---|---|
| All tasks target different files | Process sequentially, one PR per task |
| Multiple tasks target same file | Batch into single PR with separate commits |
| Tasks have explicit dependencies | Process in dependency order |
For batched tasks:
ghpm/task-$FIRST_TASK-<epic-slug>Process tasks using Steps 1-6, applying batching strategy where applicable.
task=#N providedTASK=$N
# 1. Try branch name
BRANCH=$(git rev-parse --abbrev-ref HEAD)
# Extract task number from ghpm/task-<N>-* or task-<N>-*
# 2. Most recent assigned Task
TASK=$(gh issue list -l Task -a @me -s open --limit 1 --json number -q '.[0].number')
# 3. Most recent open Task
TASK=$(gh issue list -l Task -s open --limit 1 --json number -q '.[0].number')
Before proceeding with any task, check if it's already closed or marked as done:
# Fetch issue state and labels
ISSUE_DATA=$(gh issue view "$TASK" --json state,labels,projectItems -q '.')
STATE=$(echo "$ISSUE_DATA" | jq -r '.state')
# Check if issue is closed
if [ "$STATE" = "CLOSED" ]; then
echo "Task #$TASK is already CLOSED. Skipping."
# If processing an Epic, continue to next task; otherwise exit
exit 0 # or continue to next task in Epic mode
fi
# Check for "Done" label
DONE_LABEL=$(echo "$ISSUE_DATA" | jq -r '.labels[]?.name | select(. == "Done" or . == "done" or . == "DONE")')
if [ -n "$DONE_LABEL" ]; then
echo "Task #$TASK has 'Done' label. Skipping."
exit 0
fi
# Check project status field (if linked to a project)
PROJECT_STATUS=$(echo "$ISSUE_DATA" | jq -r '.projectItems[]?.status?.name // empty')
if [ "$PROJECT_STATUS" = "Done" ] || [ "$PROJECT_STATUS" = "Completed" ]; then
echo "Task #$TASK has project status '$PROJECT_STATUS'. Skipping."
exit 0
fi
Behavior:
# Fetch issue details
gh issue view "$TASK" --json title,body,url,labels,comments -q '.'
Extract from issue:
Commit Type: \<type>``)Scope: \<scope>``)Determine workflow (see <routing_logic> for details):
1. Check Non-TDD Patterns (Override):
If target files are non-code (*.md, *.yml, *.json, etc.):
→ Route to Non-TDD workflow (Step 2B)
If task creates slash commands or skills:
→ Route to Non-TDD workflow (Step 2B)
2. Apply Commit-Type Routing:
If Commit Type in [feat, fix, refactor] AND targeting code files:
→ Route to TDD workflow (Step 2A)
Else if Commit Type in [test, docs, chore, style, perf]:
→ Route to Non-TDD workflow (Step 2B)
Else:
→ Analyze task content and make best judgment
For feat, fix, refactor tasks, delegate to the TDD command:
/ghpm:tdd-task task=#$TASK
The TDD command handles all subsequent steps. Proceed to next task if processing an Epic.
For test, docs, chore, style, perf tasks, execute directly.
Comment on the Task with your implementation plan:
## Implementation Plan
- **Objective:** <from task>
- **Commit Type:** `<type>`
- **Scope:** `<scope>`
- **What will be changed:**
- **Verification approach:** (manual verification, existing tests, linting, etc.)
- **Milestones:**
Execute:
gh issue comment "$TASK" --body "<markdown>"
git checkout -b "ghpm/task-$TASK-<short-slug>"
Comment branch name to the issue.
For each milestone:
Make the changes
Verify the changes work (run existing tests, manual verification, linting)
Commit using conventional commit format:
<type>(<scope>): <description> (#$TASK)
Commit patterns by type:
test: test(<scope>): add tests for <behavior> (#$TASK)docs: docs(<scope>): update documentation for <topic> (#$TASK)chore: chore(<scope>): update <tooling/config> (#$TASK)style: style(<scope>): format <files/code> (#$TASK)perf: perf(<scope>): optimize <operation> (#$TASK)After meaningful progress, comment on the Task with:
Edit the issue body to append:
## Task Report (auto)
### Implementation summary
### Files changed
### How to validate
### Verification performed
### Decision log
### Follow-ups (if any)
Execute:
gh issue edit "$TASK" --body "<updated markdown>"
Push branch and create PR:
git push -u origin HEAD
gh pr create --title "<type>(<scope>): <description> (#$TASK)" --body "$(cat <<'EOF'
Closes #$TASK
## Summary
- ...
## Verification
- <what was verified and how>
## Commits
<list of conventional commits made>
EOF
)"
Comment the PR URL back onto the Task:
gh issue comment "$TASK" --body "PR created: <PR_URL>"
If processing an Epic, move to the next task and repeat from Step 1.
After all tasks are complete, comment on the Epic:
gh issue comment "$EPIC" --body "$(cat <<'EOF'
## Execution Complete
All tasks have been executed. PRs created:
- #<TASK_1>: <PR_URL_1>
- #<TASK_2>: <PR_URL_2>
...
EOF
)"
</workflow>
<success_criteria> Command completes when:
For single task:
Closes #$TASK in the bodyFor epic (independent tasks):
For epic (interdependent tasks - same target file):
Closes #T1, Closes #T2, ...)<error_handling> If Commit Type cannot be determined:
If target files cannot be determined:
ghpm, commands, docs → Non-TDD)If task is already in progress (branch exists):
If delegation to /ghpm:tdd-task fails:
If verification fails (tests fail, lint errors):
Proceed now.