Draft repository-compliant GitHub pull requests with the `gh` CLI.
skillsy install jaesung-jung/foldericonmaker@gh-prDraft or create pull requests by treating the current repository as the source of truth.
Use local git state for scope, .github/ files for template and lint requirements, and the gh CLI for live GitHub metadata and label changes.
Prefer gh over connector tools for this skill.
Start by identifying the active repository and branch instead of hardcoding them.
Prefer commands such as:
repo="$(gh repo view --json nameWithOwner -q .nameWithOwner)"
default_branch="$(gh repo view --json defaultBranchRef -q .defaultBranchRef.name)"
branch="$(git branch --show-current)"
git status --short
git diff --stat
git log --oneline --decorate --max-count 10
Use the current branch, changed files, and recent commits to understand what the PR actually covers.
Before drafting or revising a PR, inspect the repository files and live GitHub metadata that define the rules:
.github/, such as .github/pull_request_template.md or .github/PULL_REQUEST_TEMPLATE/*.github/workflows/Prefer discovery commands such as:
rg --files .github | rg 'pull_request_template|PULL_REQUEST_TEMPLATE'
rg --files .github/workflows | rg 'pr|pull'
gh label list --repo "$repo" --limit 200
gh issue list --repo "$repo" --state open --limit 30
gh pr list --repo "$repo" --state closed --limit 20
If a workflow enforces a PR title pattern or required body sections, follow that rule exactly.
If multiple templates exist, choose the one that best matches the request and current diff.
Use the local diff to determine the real change set.
Do not finalize the PR body until you have checked whether a related issue exists.
Recommended workflow:
Prefer commands such as:
gh issue list --repo "$repo" --state open --search "<keywords>" --limit 20
gh issue list --repo "$repo" --state all --search "<keywords>" --limit 20
gh issue view <number> --repo "$repo"
When multiple issues are plausible, keep the top candidates, explain the ambiguity briefly, and avoid linking a weak match just to satisfy a template.
Search prior closed or merged PRs when they can improve:
Prefer commands such as:
gh pr list --repo "$repo" --state closed --search "<keywords>" --limit 20
gh pr view <number> --repo "$repo" --json title,body,labels,closingIssuesReferences
Use precedent only when it materially improves the current draft.
Always query live labels with gh before recommending or applying labels.
Do not rely on stale assumptions, repository memory, or examples from this skill.
Required step:
gh label list --repo "$repo" --limit 200
Label selection rules:
P0 to P3, priority:*, severity:*, critical, high, medium, and low.When editing an existing PR, inspect current labels first and add only the missing ones unless the user asked you to replace labels.
Prefer commands such as:
gh pr view <number> --repo "$repo" --json labels
gh pr edit <number> --repo "$repo" --add-label "<label>"
Follow the repository's actual rules, not this skill's examples.
Refs, Closes, or Fixes, follow the observed convention from templates, lint rules, or recent merged PRs.gh label list.Prefer commands such as:
git push -u origin "$branch"
gh pr create --repo "$repo" --base "$default_branch" --head "$branch" --title "<title>" --body-file <file> --label "<label>"
gh pr edit <number> --repo "$repo" --title "<title>" --body-file <file>
gh pr edit <number> --repo "$repo" --add-label "<label>"
When adding more than one label, pass multiple --label or --add-label flags as needed.
When asked to draft a PR, provide:
Title: <repository-compliant title>
Linked issues:
- #123 <issue title>
Recommended labels:
- <label>
- <label>
Reference PRs:
- #456 <title>
Body:
<full PR body that matches the repository template>
If no related issue exists, say so clearly.
If gh is unavailable, still provide the final title, body, and recommended labels so the user can create the PR without rewriting.