Skip to content

Commit 6611c18

Browse files
committed
feat(github): Add prompts for automated issue and PR creation
1 parent f382d6c commit 6611c18

2 files changed

Lines changed: 216 additions & 0 deletions

File tree

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Create Issue From Branch Changes
2+
3+
Create or update a GitHub issue from the changes in the current branch compared to main.
4+
5+
## Requirements
6+
7+
1. Compare changes from origin/main..HEAD and infer the user-facing goal.
8+
2. Do not include implementation details (no file lists, refactor notes, internal mechanics).
9+
3. Ask before editing the issue:
10+
- Which label should be used?
11+
- Which milestone should be used?
12+
4. Defaults:
13+
- If label is not provided, use improvement.
14+
- If milestone is not provided, use the latest open milestone.
15+
5. The issue description must be well-formatted Markdown.
16+
6. Use this Markdown structure exactly (omit empty sections):
17+
- ## Summary
18+
- ## Goal
19+
- ## Success Criteria
20+
- ## References
21+
7. Keep language concise, goal-oriented, and user-facing.
22+
23+
## Operational Steps
24+
25+
1. Ensure branch comparison is up to date:
26+
27+
```bash
28+
git fetch origin main --quiet
29+
git log --oneline --no-merges origin/main..HEAD
30+
git diff --name-status origin/main..HEAD
31+
```
32+
33+
2. Ask:
34+
- Label? (default: improvement)
35+
- Milestone? (default: latest open milestone)
36+
37+
3. Resolve defaults:
38+
39+
```bash
40+
LABEL="${LABEL:-improvement}"
41+
42+
if [ -z "$MILESTONE" ]; then
43+
MILESTONE="$(gh api repos/{owner}/{repo}/milestones --paginate -f state=open --jq 'sort_by(.number) | last | .title')"
44+
fi
45+
```
46+
47+
4. Build a well-formatted Markdown body in a temp file:
48+
49+
```bash
50+
cat > /tmp/issue-body.md <<'EOF'
51+
## Summary
52+
<goal-focused summary>
53+
54+
## Goal
55+
<what outcome we want>
56+
57+
## Success Criteria
58+
- <criterion 1>
59+
- <criterion 2>
60+
61+
## References
62+
- <optional links>
63+
EOF
64+
```
65+
66+
5. Suggest a title in this style:
67+
- [IMPROVEMENT]: <goal-focused title>
68+
- Adapt prefix to selected label where appropriate (for example: [FEATURE]: ...).
69+
70+
6. Create or update issue:
71+
72+
Create:
73+
74+
```bash
75+
gh issue create \
76+
--title "<TITLE>" \
77+
--label "$LABEL" \
78+
--milestone "$MILESTONE" \
79+
--body-file /tmp/issue-body.md
80+
```
81+
82+
Update existing:
83+
84+
```bash
85+
gh issue edit <ISSUE_NUMBER> \
86+
--title "<TITLE>" \
87+
--add-label "$LABEL" \
88+
--milestone "$MILESTONE" \
89+
--body-file /tmp/issue-body.md
90+
```
91+
92+
7. Verify and report final state:
93+
94+
```bash
95+
gh issue view <ISSUE_NUMBER> --json number,title,url,labels,milestone,body
96+
```
97+
98+
Report:
99+
- Issue number and URL
100+
- Final title
101+
- Final label(s)
102+
- Final milestone
103+
- Confirmation that body is well-formatted Markdown and goal-focused
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Create PR From Branch Changes
2+
3+
Create or update a GitHub pull request from the current branch into the fork's main branch with a well-formatted PR description.
4+
5+
## Requirements
6+
7+
1. Compare changes from origin/main..HEAD and infer the user-facing intent.
8+
2. Keep the PR description aligned with the actual branch changes.
9+
3. The PR description must be well-formatted Markdown.
10+
4. The PR must reference the issue it resolves using closing keywords (for example: Resolves #1234).
11+
5. If no issue number is provided, ask for it before creating or updating the PR.
12+
6. Keep language concise, outcome-focused, and reviewer-friendly.
13+
7. Do not include irrelevant implementation noise; summarize what matters for review.
14+
8. Whenever new commits are pushed that change scope, update the PR description so it stays in sync with current branch changes.
15+
16+
## PR Markdown Template
17+
18+
Use this structure (omit empty sections):
19+
- ## Summary
20+
- ## Why
21+
- ## Validation
22+
- ## Issue
23+
24+
Example:
25+
26+
```md
27+
## Summary
28+
- <high-level change 1>
29+
- <high-level change 2>
30+
31+
## Why
32+
- <problem or goal>
33+
34+
## Validation
35+
- <tests run>
36+
- <results>
37+
38+
## Issue
39+
Resolves #<issue-number>
40+
```
41+
42+
## Operational Steps
43+
44+
1. Ensure branch comparison is current:
45+
46+
```bash
47+
git fetch origin main --quiet
48+
git log --oneline --no-merges origin/main..HEAD
49+
git diff --name-status origin/main..HEAD
50+
```
51+
52+
2. Determine branch and existing PR state:
53+
54+
```bash
55+
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
56+
GH_PAGER=cat GH_FORCE_TTY=0 gh pr list --head "$BRANCH" --json number,title,url,state
57+
```
58+
59+
3. Ask for required metadata if missing:
60+
- Target issue number to resolve
61+
- PR title override (optional)
62+
63+
4. Build or refresh PR body in a temp file:
64+
65+
```bash
66+
cat > /tmp/pr-body.md <<'EOF'
67+
## Summary
68+
- <high-level change 1>
69+
- <high-level change 2>
70+
71+
## Why
72+
- <problem or goal>
73+
74+
## Validation
75+
- <tests run>
76+
- <results>
77+
78+
## Issue
79+
Resolves #<issue-number>
80+
EOF
81+
```
82+
83+
5. Create PR if none exists:
84+
85+
```bash
86+
GH_PAGER=cat GH_FORCE_TTY=0 gh pr create \
87+
--base main \
88+
--head "$BRANCH" \
89+
--title "<PR title>" \
90+
--body-file /tmp/pr-body.md
91+
```
92+
93+
6. Update PR if one already exists, or after new commits change scope:
94+
95+
```bash
96+
GH_PAGER=cat GH_FORCE_TTY=0 gh pr edit <PR_NUMBER> \
97+
--title "<PR title>" \
98+
--body-file /tmp/pr-body.md
99+
```
100+
101+
7. Verify final PR state:
102+
103+
```bash
104+
GH_PAGER=cat GH_FORCE_TTY=0 gh pr view <PR_NUMBER> --json number,title,url,body
105+
```
106+
107+
## Completion Checklist
108+
109+
- PR exists and targets main
110+
- Description is well-formatted Markdown
111+
- Description matches current branch changes
112+
- Issue reference uses closing keyword (Resolves/Fixes/Closes #...)
113+
- PR body was refreshed after any scope-changing push

0 commit comments

Comments
 (0)