Break a PRD issue into Epic issues and link them back to the PRD.
/plugin marketplace add el-feo/ai-context/plugin install ghpm@jebs-dev-toolsprd=#123Resolution order if omitted:
PRDOptional environment variables:
GHPM_PROJECT - GitHub Project name to associate Epics with (e.g., "OrgName/ProjectName" or "ProjectName")
</arguments>
<usage_examples> With PRD number:
/ghpm:create-epics prd=#42
Auto-resolve most recent PRD:
/ghpm:create-epics
With project association:
export GHPM_PROJECT="MyOrg/Q1 Roadmap"
/ghpm:create-epics prd=#42
</usage_examples>
<operating_rules>
<epic_issue_format>
Use this streamlined template. Omit optional sections if empty.
# Epic: <Name>
**PRD:** #<PRD_NUMBER>
## Objective
<1-3 sentences: what this Epic accomplishes and delivers>
## Scope
<Bulleted list of specific deliverables - merge any "Key Requirements" here>
## Acceptance Criteria
- [ ] Criterion 1
- [ ] Criterion 2
- [ ] ...
## Dependencies
<Only include if external dependencies exist; omit section entirely if none>
Omit these sections (redundant with PRD or rarely populated):
</epic_issue_format>
<input_validation>
Before proceeding, verify:
# 1. Verify gh CLI authentication
gh auth status || { echo "ERROR: Not authenticated. Run 'gh auth login'"; exit 1; }
# 2. Verify in git repository
git rev-parse --git-dir > /dev/null 2>&1 || { echo "ERROR: Not in a git repository"; exit 1; }
# 3. Verify GitHub remote exists and get repo info
REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner) || { echo "ERROR: No GitHub remote found"; exit 1; }
# 4. Get owner and repo for API calls
OWNER=$(gh repo view --json owner -q '.owner.login')
REPO_NAME=$(gh repo view --json name -q '.name')
</input_validation>
<workflow>Run input validation checks from previous section.
# If prd=#N provided, extract N
if [[ "$ARGUMENTS" =~ prd=#([0-9]+) ]]; then
PRD="${BASH_REMATCH[1]}"
else
# Find most recent open PRD
PRD=$(gh issue list -l PRD -s open --limit 1 --json number -q '.[0].number')
if [ -z "$PRD" ]; then
echo "ERROR: No open PRD issues found. Create one with /ghpm:create-prd"
exit 1
fi
fi
echo "Using PRD #$PRD"
# Verify PRD exists and get content
PRD_DATA=$(gh issue view "$PRD" --json title,body,url,number)
if [ -z "$PRD_DATA" ]; then
echo "ERROR: PRD #$PRD not found"
exit 1
fi
PRD_TITLE=$(echo "$PRD_DATA" | jq -r '.title')
PRD_BODY=$(echo "$PRD_DATA" | jq -r '.body')
PRD_URL=$(echo "$PRD_DATA" | jq -r '.url')
echo "PRD: $PRD_TITLE"
echo "URL: $PRD_URL"
Analyze the PRD scope and generate the minimum number of Epics needed. For narrow-scope PRDs (documentation updates, configuration changes, single-file modifications), a single Epic is often sufficient. Each Epic should:
# For each Epic, create an issue
gh issue create \
--repo "$REPO" \
--title "Epic: <Name>" \
--label "Epic" \
--body "$(cat <<'EOF'
<Generated Epic Content>
EOF
)"
# Capture issue number from output
EPIC_NUM=<captured from gh issue create output>
EPIC_URL=<captured from gh issue create output>
# Track created Epics
CREATED_EPICS+=("$EPIC_NUM|Epic: <Name>|$EPIC_URL")
if [ -n "$GHPM_PROJECT" ]; then
gh issue edit "$EPIC_NUM" --add-project "$GHPM_PROJECT" 2>/dev/null || {
echo "WARNING: Failed to add Epic #$EPIC_NUM to project '$GHPM_PROJECT'"
}
fi
# Get the PRD's internal issue ID
PRD_ID=$(gh api "repos/$OWNER/$REPO_NAME/issues/$PRD" --jq .id)
for epic_info in "${CREATED_EPICS[@]}"; do
EPIC_NUM=$(echo "$epic_info" | cut -d'|' -f1)
# Get the Epic's internal issue ID
EPIC_ID=$(gh api "repos/$OWNER/$REPO_NAME/issues/$EPIC_NUM" --jq .id)
# Add Epic as sub-issue of PRD
gh api "repos/$OWNER/$REPO_NAME/issues/$PRD/sub_issues" \
-X POST \
-F sub_issue_id="$EPIC_ID" \
--silent && echo "✓ Linked Epic #$EPIC_NUM as sub-issue of PRD #$PRD" \
|| echo "WARNING: Could not link Epic #$EPIC_NUM as sub-issue"
done
COMMENT_BODY="## Epics Created
The following Epics have been created from this PRD:
$(for epic_info in "${CREATED_EPICS[@]}"; do
EPIC_NUM=$(echo "$epic_info" | cut -d'|' -f1)
EPIC_TITLE=$(echo "$epic_info" | cut -d'|' -f2)
echo "- #$EPIC_NUM $EPIC_TITLE"
done)
View sub-issues in the PRD's \"Sub-issues\" section.
---
*Generated by GHPM*"
gh issue comment "$PRD" --body "$COMMENT_BODY"
</workflow>
<error_handling> If gh CLI not authenticated:
gh auth statusgh auth loginIf not in git repository:
git statusIf no GitHub remote:
git remote -vgit remote add origin <url>If PRD not found:
gh issue view <number>gh issue list -l PRD/ghpm:create-prd <description>If label "Epic" doesn't exist:
gh label create Epic --description "Epic issue" --color 1D76DB--label "Epic" from issue creation and continueIf issue creation fails:
gh api rate_limitgh repo view --json viewerPermission -q .viewerPermissionIf sub-issue linking fails:
If project association fails:
GHPM_PROJECT format is correctgh project list<success_criteria> Command completes successfully when:
GHPM_PROJECT set, Epics are added to project (or warnings issued)Verification:
# View created Epics
gh issue list -l Epic --json number,title,url
# Verify sub-issues are linked to PRD
gh api "repos/$OWNER/$REPO_NAME/issues/$PRD/sub_issues" --jq '.[] | "#\(.number) \(.title)"'
# View PRD comments
gh issue view "$PRD" --comments
</success_criteria>
<output> After completion, report:/ghpm:create-tasks epic=#<number> to break an Epic into Tasks"Example Output (Minimal PRD - single epic):
Epics Created Successfully
PRD: #42 - https://github.com/owner/repo/issues/42
Epics Created:
- #43 Epic: Update README Documentation - https://github.com/owner/repo/issues/43
Sub-Issue Linking: 1/1 successful
Project Association: No project specified
Next Step: Run `/ghpm:create-tasks epic=#43` to break an Epic into Tasks
Example Output (Large PRD - multiple epics):
Epics Created Successfully
PRD: #42 - https://github.com/owner/repo/issues/42
Epics Created:
- #43 Epic: User Authentication - https://github.com/owner/repo/issues/43
- #44 Epic: Database Schema - https://github.com/owner/repo/issues/44
- #45 Epic: API Endpoints - https://github.com/owner/repo/issues/45
- #46 Epic: Frontend Integration - https://github.com/owner/repo/issues/46
- #47 Epic: Testing & QA - https://github.com/owner/repo/issues/47
Sub-Issue Linking: 5/5 successful
Project Association: Added to project 'Q1 Roadmap'
Next Step: Run `/ghpm:create-tasks epic=#43` to break an Epic into Tasks
</output>
<related_commands> GHPM Workflow:
/ghpm:create-prd - Create PRD from user input/ghpm:create-epics - Break PRD into Epics/ghpm:create-tasks epic=#N - Break Epics into Tasks/ghpm:tdd-task [task=#N] - Implement Tasks with TDDRelated:
/ghpm:execute epic=#N - Execute all tasks in an Epic/ghpm:qa-create - Create QA issue for testing
</related_commands>Now proceed:
gh issue create.