Creating Issues and Pull Requests
Announce: "Using creating-issues-and-pull-requests skill to handle GitHub creation."
Invariant Principles
- Template Discovery Before Creation - Always attempt template discovery before falling back to a default body. Never skip it.
- Read Templates Yourself, Pass via
--body-file - Never rely on --template or --fill. Read the template content, populate it, write to a temp file, pass via --body-file.
- User Confirms All Side Effects - Never push, create a PR, or create an issue without explicit user approval.
- Target Repository is Never Assumed - Always confirm the merge base repo with the user (upstream or origin?).
- Branch-Relative Documentation Only - PR descriptions derive from the merge-base delta. No development history, no session narratives.
- Jira Tickets are Real or Absent - If no Jira ticket is evident from the branch name or user input, omit the prefix entirely. Never fabricate ticket numbers.
- Base Repo Templates for Fork PRs - When creating a PR from a fork, templates come from the upstream (base) repo, not the fork.
- Zero Tags By Default (Safety-Critical) - All PR titles, descriptions, and issue bodies MUST be sanitized before submission. GitHub auto-links
#N to issues/PRs (notifying all subscribers) and @username pings users. A single stray #108 in a PR description pings everyone subscribed to issue 108. This is treated as a SAFETY-CRITICAL concern, not a nice-to-have. The sanitization gate in the create-pr and create-issue commands enforces this.
- Draft-First for Staging PRs - When creating a PR on a fork (not upstream), default to
--draft. Staging PRs exist for self-review and CI validation, not for notifying the world. Only use --draft=false when the user explicitly requests a ready PR on their fork.
- Fork-Then-Upstream Workflow - Support a two-stage PR workflow: (a) create draft PR on fork for self-review/CI, then (b) when ready, create the real PR on upstream. The skill must make it impossible to accidentally do step (b) when you meant step (a). When the user says "create a PR" in a fork context, always confirm which stage they're in.
Inputs
| Input |
Required |
Default |
Description |
mode |
No |
auto-detect |
"pr" or "issue" |
branch |
No |
current branch |
Feature branch name |
base |
No |
auto-detect |
Base/target branch for PRs |
target_repo |
No |
auto-detect |
OWNER/REPO for the target |
jira_ticket |
No |
detect from branch |
Jira ticket number (e.g., ODY-1234) |
diff_summary |
No |
compute |
Pre-computed merge-base diff summary |
draft |
No |
false |
Create as draft PR |
labels |
No |
none |
Labels to apply |
reviewers |
No |
none |
Reviewers to request |
Outputs
| Output |
Type |
Description |
url |
string |
Created PR or issue URL |
number |
int |
PR or issue number |
type |
string |
"pr" or "issue" |
target_repo |
string |
OWNER/REPO where it was created |
Integration Contract
Called By
finishing-a-development-branch (Option 2: Push and Create PR) - Delegates PR creation with branch context.
executing-plans - Indirectly, through finishing-a-development-branch at the end of implementation.
- User directly - Via
/creating-issues-and-pull-requests, or the shorthand commands /create-pr and /create-issue.
Context Passed by Callers
When invoked as a delegate from finishing-a-development-branch:
mode: "pr"
branch: <feature-branch>
base: <base-branch>
diff_summary: <pre-computed merge-base diff summary>
The skill handles everything from push confirmation through PR creation and URL reporting.
Direct Invocation
| Invocation |
Behavior |
/creating-issues-and-pull-requests |
Mode detection, asks PR or issue |
/creating-issues-and-pull-requests --pr |
Dispatches directly to /create-pr |
/creating-issues-and-pull-requests --issue |
Dispatches directly to /create-issue |
/create-pr |
Invokes PR command directly (bypasses orchestrator) |
/create-issue |
Invokes issue command directly |
The Process
Phase 0: Mode Detection
| Signal |
Detected Mode |
"create a PR", "open PR", caller passes mode: "pr" |
PR |
"create an issue", "file a bug", "open issue", caller passes mode: "issue" |
Issue |
| No clear signal |
Ask user: "Would you like to create a PR or an issue?" |
Phase 1: Gather Context
Before dispatching, collect the context that commands need:
- Current branch:
git branch --show-current
- Remote configuration:
git remote -v
- Fork detection:
gh repo view --json isFork,parent
- Jira ticket detection: Scan the branch name for patterns like
ODY-XXXX or elijahr/ODY-XXXX
Pass all gathered context to the appropriate command.
Phase 1.5: Safety Pre-Check
Before dispatching, determine the workflow stage and draft mode:
Fork detection: Check if the repo has both a fork remote (origin) and an upstream remote (upstream).
- If only one remote exists, skip to Phase 2 with
workflow_stage: "direct".
If fork detected: Ask the user:
"You have a fork and upstream configured. Are you staging this on your fork first, or submitting directly to upstream?"
Set workflow variables based on response:
| User Response |
workflow_stage |
draft_mode |
Target Remote |
| Staging on fork |
fork_staging |
true (forced) |
Fork (origin) |
| Submitting to upstream |
upstream_submit |
User's preference |
Upstream (upstream) |
| Single remote (no fork) |
direct |
User's preference |
Default remote |
Fork staging behavior:
- Force
--draft by default. The user must explicitly pass --draft=false to override.
- Set the target to the fork remote.
Upstream submit confirmation:
Do not proceed without a clear "yes" from the user.
- Pass forward: Provide
workflow_stage and draft_mode to Phase 2.
Phase 2: Dispatch
For PR creation:
Dispatch subagent with command: /create-pr
Provide context: branch name, base branch, target repo (if known), jira ticket (if detected), diff summary (if pre-computed), draft flag, labels, reviewers, workflow_stage, draft_mode.
- If
workflow_stage is fork_staging, pass --draft unless the user explicitly overrode it.
- If
workflow_stage is upstream_submit, pass the confirmed target repo and the user's draft preference.
- If
workflow_stage is direct, pass context as before (no fork-specific overrides).
For issue creation:
Dispatch subagent with command: /create-issue
Provide context: target repo (if known), labels, workflow_stage.
- If
workflow_stage is fork_staging or upstream_submit, ensure the issue is created on the correct target repo matching the workflow stage.
Phase 3: Report Result
Report the created URL back to the user and to any calling skill.
Template Discovery Overview
Both commands implement a 4-tier template discovery cascade. This section provides the high-level algorithm; commands contain the full implementation details.
PR Template Discovery
| Tier |
Source |
Method |
Applies When |
| 1 |
Local filesystem |
Scan .github/, root, docs/ for pull_request_template.md and PULL_REQUEST_TEMPLATE/ directories |
Same-repo PRs only |
| 2 |
Remote (target repo) |
GraphQL repository.pullRequestTemplates |
Always (primary source for fork PRs) |
| 3 |
Org-level .github repo |
GraphQL against ORG/.github |
Fallback when target repo has no templates |
| 4 |
No template found |
Use sensible default body structure |
Final fallback |
Issue Template Discovery
| Tier |
Source |
Method |
| 1 |
Local filesystem |
Scan .github/ISSUE_TEMPLATE/ for .md and .yml files, parse config.yml |
| 2 |
Remote (target repo) |
GraphQL repository.issueTemplates |
| 3 |
Org-level .github repo |
GraphQL against ORG/.github |
| 4 |
Legacy / No template |
Check root issue_template.md; if nothing found, use blank issue (if allowed) |
Multiple Templates
When multiple templates are discovered at any tier, present a chooser listing filenames and descriptions. Let the user select.
All-or-Nothing Override
If the target repo has ANY template of a given type (PR or issue), ALL org-level templates of that type are blocked. There is no merging or layering between repo-level and org-level templates.
Naming Conventions
| Condition |
PR Title |
Branch Name |
| Jira ticket exists |
[ODY-XXXX] <description> |
elijahr/ODY-XXXX |
| No Jira ticket |
<description> (plain, no prefix) |
elijahr/<descriptive-slug> |
Post-Creation Operations
Since gh pr edit is broken (GitHub Projects Classic deprecation), use the REST API for any post-creation modifications:
# Update PR title or body
gh api repos/OWNER/REPO/pulls/NUMBER --method PATCH \
-f title="New title" -f body="New body"
# Add labels
gh api repos/OWNER/REPO/issues/NUMBER/labels --method POST \
-f 'labels[]=label1'
# Request reviewers
gh api repos/OWNER/REPO/pulls/NUMBER/requested_reviewers --method POST \
-f 'reviewers[]=username'
Self-Check
IF ANY unchecked: STOP and fix.
1---2name: creating-issues-and-pull-requests3description: Use when creating GitHub pull requests or issues with template compliance. Triggers: 'create a PR', 'open a pull request', 'file an issue', 'create issue', or invoked as delegate from finishing-a-development-branch Option 2. Discovers project templates, populates them from branch context, and creates via reliable gh CLI patterns.4---5
6# Creating Issues and Pull Requests
7
8<ROLE>
9GitHub Integration Specialist. Your reputation depends on every PR and issue respecting the project's templates, naming conventions, and workflow constraints. A PR that ignores the project's template is a public failure. A fabricated Jira ticket number is unforgivable.
10</ROLE>
11
12**Announce:** "Using creating-issues-and-pull-requests skill to handle GitHub creation."
13
14## Invariant Principles
15
161. **Template Discovery Before Creation** - Always attempt template discovery before falling back to a default body. Never skip it.
172. **Read Templates Yourself, Pass via `--body-file`** - Never rely on `--template` or `--fill`. Read the template content, populate it, write to a temp file, pass via `--body-file`.
183. **User Confirms All Side Effects** - Never push, create a PR, or create an issue without explicit user approval.
194. **Target Repository is Never Assumed** - Always confirm the merge base repo with the user (upstream or origin?).
205. **Branch-Relative Documentation Only** - PR descriptions derive from the merge-base delta. No development history, no session narratives.
216. **Jira Tickets are Real or Absent** - If no Jira ticket is evident from the branch name or user input, omit the prefix entirely. Never fabricate ticket numbers.
227. **Base Repo Templates for Fork PRs** - When creating a PR from a fork, templates come from the upstream (base) repo, not the fork.
238. **Zero Tags By Default (Safety-Critical)** - All PR titles, descriptions, and issue bodies MUST be sanitized before submission. GitHub auto-links `#N` to issues/PRs (notifying all subscribers) and `@username` pings users. A single stray `#108` in a PR description pings everyone subscribed to issue 108. This is treated as a SAFETY-CRITICAL concern, not a nice-to-have. The sanitization gate in the create-pr and create-issue commands enforces this.
249. **Draft-First for Staging PRs** - When creating a PR on a fork (not upstream), default to `--draft`. Staging PRs exist for self-review and CI validation, not for notifying the world. Only use `--draft=false` when the user explicitly requests a ready PR on their fork.
2510. **Fork-Then-Upstream Workflow** - Support a two-stage PR workflow: (a) create draft PR on fork for self-review/CI, then (b) when ready, create the real PR on upstream. The skill must make it impossible to accidentally do step (b) when you meant step (a). When the user says "create a PR" in a fork context, always confirm which stage they're in.
26
27---
28
29## Inputs
30
31| Input | Required | Default | Description |
32|-------|----------|---------|-------------|
33| `mode` | No | auto-detect | `"pr"` or `"issue"` |
34| `branch` | No | current branch | Feature branch name |
35| `base` | No | auto-detect | Base/target branch for PRs |
36| `target_repo` | No | auto-detect | `OWNER/REPO` for the target |
37| `jira_ticket` | No | detect from branch | Jira ticket number (e.g., `ODY-1234`) |
38| `diff_summary` | No | compute | Pre-computed merge-base diff summary |
39| `draft` | No | false | Create as draft PR |
40| `labels` | No | none | Labels to apply |
41| `reviewers` | No | none | Reviewers to request |
42
43## Outputs
44
45| Output | Type | Description |
46|--------|------|-------------|
47| `url` | string | Created PR or issue URL |
48| `number` | int | PR or issue number |
49| `type` | string | `"pr"` or `"issue"` |
50| `target_repo` | string | `OWNER/REPO` where it was created |
51
52---
53
54## Integration Contract
55
56### Called By
57
58- **`finishing-a-development-branch`** (Option 2: Push and Create PR) - Delegates PR creation with branch context.
59- **`executing-plans`** - Indirectly, through `finishing-a-development-branch` at the end of implementation.
60- **User directly** - Via `/creating-issues-and-pull-requests`, or the shorthand commands `/create-pr` and `/create-issue`.
61
62### Context Passed by Callers
63
64When invoked as a delegate from `finishing-a-development-branch`:
65
66```
67mode: "pr"
68branch: <feature-branch>
69base: <base-branch>
70diff_summary: <pre-computed merge-base diff summary>
71```
72
73The skill handles everything from push confirmation through PR creation and URL reporting.
74
75### Direct Invocation
76
77| Invocation | Behavior |
78|------------|----------|
79| `/creating-issues-and-pull-requests` | Mode detection, asks PR or issue |
80| `/creating-issues-and-pull-requests --pr` | Dispatches directly to `/create-pr` |
81| `/creating-issues-and-pull-requests --issue` | Dispatches directly to `/create-issue` |
82| `/create-pr` | Invokes PR command directly (bypasses orchestrator) |
83| `/create-issue` | Invokes issue command directly |
84
85---
86
87## The Process
88
89### Phase 0: Mode Detection
90
91<analysis>
92Determine what the user wants to create:
93- Examine the invocation arguments and user message
94- Check for caller-provided mode
95- If ambiguous, ask the user
96</analysis>
97
98| Signal | Detected Mode |
99|--------|---------------|
100| "create a PR", "open PR", caller passes `mode: "pr"` | PR |
101| "create an issue", "file a bug", "open issue", caller passes `mode: "issue"` | Issue |
102| No clear signal | Ask user: "Would you like to create a PR or an issue?" |
103
104### Phase 1: Gather Context
105
106Before dispatching, collect the context that commands need:
107
1081. **Current branch:** `git branch --show-current`
1092. **Remote configuration:** `git remote -v`
1103. **Fork detection:** `gh repo view --json isFork,parent`
1114. **Jira ticket detection:** Scan the branch name for patterns like `ODY-XXXX` or `elijahr/ODY-XXXX`
112
113Pass all gathered context to the appropriate command.
114
115### Phase 1.5: Safety Pre-Check
116
117Before dispatching, determine the workflow stage and draft mode:
118
1191. **Fork detection:** Check if the repo has both a fork remote (`origin`) and an upstream remote (`upstream`).
120 - If only one remote exists, skip to Phase 2 with `workflow_stage: "direct"`.
121
1222. **If fork detected:** Ask the user:
123 > "You have a fork and upstream configured. Are you staging this on your fork first, or submitting directly to upstream?"
124
1253. **Set workflow variables based on response:**
126
127| User Response | `workflow_stage` | `draft_mode` | Target Remote |
128|---------------|-----------------|--------------|---------------|
129| Staging on fork | `fork_staging` | `true` (forced) | Fork (`origin`) |
130| Submitting to upstream | `upstream_submit` | User's preference | Upstream (`upstream`) |
131| Single remote (no fork) | `direct` | User's preference | Default remote |
132
1334. **Fork staging behavior:**
134 - Force `--draft` by default. The user must explicitly pass `--draft=false` to override.
135 - Set the target to the fork remote.
136
1375. **Upstream submit confirmation:**
138
139<CRITICAL>
140If `workflow_stage` is `upstream_submit`, require explicit confirmation:
141> "This will create a PR visible to the upstream maintainers. Proceed?"
142
143Do not proceed without a clear "yes" from the user.
144</CRITICAL>
145
1466. **Pass forward:** Provide `workflow_stage` and `draft_mode` to Phase 2.
147
148### Phase 2: Dispatch
149
150**For PR creation:**
151
152Dispatch subagent with command: `/create-pr`
153
154Provide context: branch name, base branch, target repo (if known), jira ticket (if detected), diff summary (if pre-computed), draft flag, labels, reviewers, `workflow_stage`, `draft_mode`.
155
156- If `workflow_stage` is `fork_staging`, pass `--draft` unless the user explicitly overrode it.
157- If `workflow_stage` is `upstream_submit`, pass the confirmed target repo and the user's draft preference.
158- If `workflow_stage` is `direct`, pass context as before (no fork-specific overrides).
159
160**For issue creation:**
161
162Dispatch subagent with command: `/create-issue`
163
164Provide context: target repo (if known), labels, `workflow_stage`.
165
166- If `workflow_stage` is `fork_staging` or `upstream_submit`, ensure the issue is created on the correct target repo matching the workflow stage.
167
168### Phase 3: Report Result
169
170Report the created URL back to the user and to any calling skill.
171
172---
173
174## Template Discovery Overview
175
176Both commands implement a 4-tier template discovery cascade. This section provides the high-level algorithm; commands contain the full implementation details.
177
178### PR Template Discovery
179
180| Tier | Source | Method | Applies When |
181|------|--------|--------|-------------|
182| 1 | Local filesystem | Scan `.github/`, root, `docs/` for `pull_request_template.md` and `PULL_REQUEST_TEMPLATE/` directories | Same-repo PRs only |
183| 2 | Remote (target repo) | GraphQL `repository.pullRequestTemplates` | Always (primary source for fork PRs) |
184| 3 | Org-level `.github` repo | GraphQL against `ORG/.github` | Fallback when target repo has no templates |
185| 4 | No template found | Use sensible default body structure | Final fallback |
186
187<RULE>
188For fork PRs, skip Tier 1 entirely. Templates come from the upstream (base) repo via Tier 2 or 3.
189</RULE>
190
191### Issue Template Discovery
192
193| Tier | Source | Method |
194|------|--------|--------|
195| 1 | Local filesystem | Scan `.github/ISSUE_TEMPLATE/` for `.md` and `.yml` files, parse `config.yml` |
196| 2 | Remote (target repo) | GraphQL `repository.issueTemplates` |
197| 3 | Org-level `.github` repo | GraphQL against `ORG/.github` |
198| 4 | Legacy / No template | Check root `issue_template.md`; if nothing found, use blank issue (if allowed) |
199
200### Multiple Templates
201
202When multiple templates are discovered at any tier, present a chooser listing filenames and descriptions. Let the user select.
203
204### All-or-Nothing Override
205
206If the target repo has ANY template of a given type (PR or issue), ALL org-level templates of that type are blocked. There is no merging or layering between repo-level and org-level templates.
207
208---
209
210## Naming Conventions
211
212| Condition | PR Title | Branch Name |
213|-----------|----------|-------------|
214| Jira ticket exists | `[ODY-XXXX] <description>` | `elijahr/ODY-XXXX` |
215| No Jira ticket | `<description>` (plain, no prefix) | `elijahr/<descriptive-slug>` |
216
217<CRITICAL>
218Never fabricate a Jira ticket number. No `ODY-0000`, no placeholder tickets. If the branch name does not contain an `ODY-XXXX` pattern and the user has not provided a ticket number, omit the prefix entirely.
219</CRITICAL>
220
221---
222
223## Post-Creation Operations
224
225Since `gh pr edit` is broken (GitHub Projects Classic deprecation), use the REST API for any post-creation modifications:
226
227```bash
228# Update PR title or body
229gh api repos/OWNER/REPO/pulls/NUMBER --method PATCH \
230 -f title="New title" -f body="New body"
231
232# Add labels
233gh api repos/OWNER/REPO/issues/NUMBER/labels --method POST \
234 -f 'labels[]=label1'
235
236# Request reviewers
237gh api repos/OWNER/REPO/pulls/NUMBER/requested_reviewers --method POST \
238 -f 'reviewers[]=username'
239```
240
241---
242
243<FORBIDDEN>
244- Using `--fill` flag with `gh pr create` (skips templates entirely)
245- Using `--template` flag with `gh pr create` or `gh issue create` (inconsistent behavior)
246- Using `gh pr edit` for any purpose (broken by GitHub Projects Classic deprecation)
247- Fabricating Jira ticket numbers (`ODY-0000`, placeholder tickets)
248- Creating a PR or issue without user confirmation
249- Pushing to remote without user confirmation
250- Including development history or session narratives in PR descriptions
251- Skipping template discovery (always attempt all tiers)
252- Using unquoted heredocs (`<<EOF` instead of `<<'EOF'`) for body content
253- Passing raw body via `--body` when content may contain shell special characters
254- Silently choosing a target repo without user confirmation
255- Using local templates for fork PRs (templates come from upstream)
256</FORBIDDEN>
257
258---
259
260## Self-Check
261
262<reflection>
263Before completing:
264- [ ] Mode (PR or issue) correctly identified from user intent or caller context
265- [ ] Context gathered (branch, remotes, fork status, Jira ticket)
266- [ ] Appropriate command dispatched with full context
267- [ ] Command completed successfully
268- [ ] Result URL reported to user and calling skill
269
270IF ANY unchecked: STOP and fix.
271</reflection>