Publish to GitHub (only if GH integration is in scope — see preconditions below)
Step 7 — Preconditions (skip the entire step if any fail):
- The user did NOT pass
--no-github to this skill invocation
git remote get-url origin returns a github.com URL
gh auth status reports authenticated
- Capture
<org>/<repo> from the remote URL
If any precondition fails, the PRD remains local-only — no error, just stop here.
Step 7a — Confirmation gate:
Report: PRD written to <path>. Review the file (and edit if needed), then reply 'publish' to create a GitHub issue with label 'epic', or 'cancel' to keep it local.
Wait for explicit confirmation. The user may edit the file before confirming.
Step 7b — Create the GitHub issue:
First ensure the epic label exists, since gh issue create --label epic fails with HTTP 422 if it doesn't:
gh label create epic \
--color 5319e7 \
--description "Product requirements, user stories, and acceptance criteria for new features" \
2>/dev/null || true
This is idempotent: gh label create errors when the label already exists, and 2>/dev/null || true swallows that so a pre-existing epic label (with whatever color/description the repo already chose) is left untouched. Do NOT add --force — that would overwrite an existing label's color/description. If this command fails for a real reason (auth, network), the gh issue create below surfaces it. Then create the issue:
gh issue create \
--title "PRD: <feature_name>" \
--body-file <plan_file_path> \
--label epic
Capture the new issue number and URL from the output.
Prefix the issue title with PRD: so epics are scannable in the issues list, and so the issue title matches the document's # PRD: <Feature Name> heading. This is a display prefix only: the slug and feature-name derivation in Step 6a stay on the bare feature name, and prd-to-plan strips the PRD: prefix when deriving the plan slug, plan heading, and sub-issue title from this epic. No Conventional-Commits type prefix either — PRDs are top-level epics, not constrained by the commit-type convention.
Step 7c — On success:
- Append
<!-- gh-issue: <issue_number> --> as a footer to the local PRD file
- Update the
> GH Issue: header line at the top of the file with the issue reference: > GH Issue: #<n> — https://github.com/<org>/<repo>/issues/<n>
- Report the issue URL to the user
Step 7d — Failure handling:
- Create fails (network, auth, permission, etc.): the local file is intact. Report the error verbatim and tell the user to re-run
/write-a-prd once the issue is resolved — Step 6b's re-invocation matrix will detect the existing file and offer the "publish existing file as a new GH issue" option, which skips re-authoring and only retries the publish.
Step 7e — Update path (when Step 6b's re-invocation chose "Overwrite local + update GH"):
Instead of gh issue create, run:
gh issue edit <existing_issue_number> --body-file <plan_file_path>
This replaces the issue body wholesale, preserving the issue number, comment history, and any sub-issue relationships (e.g., plans created via prd-to-plan that reference this PRD as their parent stay linked). The <!-- gh-issue: <n> --> footer is already present in the file from the original publish — do NOT re-append. On success, just report the issue URL.