Implement GitHub issues end to end using GitHub CLI and git, from cloning a repository (and forking only when needed) to opening a pull request. Use when asked to pick up a specific issue from GitHub and deliver a ready-to-review PR with linked issue context, commits, validation notes, and a pre-PR quality pass via $code-review.
Resources
1Install
npx skillscat add mishankov/agent-skills/gh-issue-to-pr Install via the SkillsCat registry.
GitHub Issue To PR
Execute a reliable issue-implementation workflow for repositories hosted on GitHub using gh and git.
Required Inputs
owner/repo(upstream repository)issue_number- Local parent directory for clones
Workflow
- Verify environment and read issue context.
- Clone the target repository and fork only when owner is not current user.
- Create an issue-specific branch.
- Implement changes and run relevant checks.
- Commit local changes.
- Run
$code-reviewon the branch diff and address material findings. - Push branch to
origin. - Open a PR with issue linkage.
Step 1: Verify and Load Context
Run:
gh auth status
gh issue view <issue_number> --repo <owner/repo> --json number,title,body,labels,assignees,urlParse acceptance criteria, constraints, and edge cases from the issue before coding.
Step 2: Clone and Conditionally Fork
Detect current GitHub login and repository owner:
gh auth status
gh api user -q .loginIf <owner> from <owner/repo> is equal to current login:
cd <parent_dir>
gh repo clone <owner/repo>
cd <repo_name>Use origin as the base remote for fetch/rebase/push.
If <owner> is different from current login, fork first:
cd <parent_dir>
gh repo fork <owner/repo> --clone --remote=true
cd <repo_name>In fork mode, ensure:
origin-> personal forkupstream-> original<owner/repo>
If upstream is missing in fork mode:
git remote add upstream https://github.com/<owner/repo>.gitStep 3: Create Branch
Detect default branch:
gh repo view <owner/repo> --json defaultBranchRef -q .defaultBranchRef.nameIf running in fork mode, branch from latest upstream/<default_branch>:
git fetch upstream
git checkout -B <default_branch> upstream/<default_branch>
git checkout -b issue-<issue_number>-<short-slug>If running in owner mode (no fork), branch from latest origin/<default_branch>:
git fetch origin
git checkout -B <default_branch> origin/<default_branch>
git checkout -b issue-<issue_number>-<short-slug>Step 4: Implement Issue
- Keep scope strictly aligned with issue requirements.
- Avoid unrelated refactors unless required to complete the issue.
- Add or update tests for behavior changes.
- Run project checks (lint/test/build) relevant to changed code.
Capture key verification results for PR description.
Step 5: Commit Locally
Use clear, issue-linked commits:
git add -A
git commit -m "Fix #<issue_number>: <short summary>"If there are multiple logical changes, split into separate commits.
Step 6: Run $code-review Before PR
Invoke $code-review on the diff between <default_branch> and issue-<issue_number>-<short-slug>.
Review expectations:
- Report findings with severity and file/line evidence.
- Treat
P0andP1findings as blockers. - Resolve blocker findings and rerun relevant checks.
- For unresolved
P2/P3, document rationale in the PR body.
Step 7: Push Branch
Push only after local checks and blocker review findings are resolved:
git push -u origin issue-<issue_number>-<short-slug>Step 8: Create Pull Request
If running in fork mode, open PR from <your-github-login>:issue-... to upstream:
gh pr create \
--repo <owner/repo> \
--head <your-github-login>:issue-<issue_number>-<short-slug> \
--base <default_branch> \
--title "Fix #<issue_number>: <short summary>" \
--body "<problem/solution/testing summary>"If running in owner mode, open PR from branch in the same repository:
gh pr create \
--repo <owner/repo> \
--head issue-<issue_number>-<short-slug> \
--base <default_branch> \
--title "Fix #<issue_number>: <short summary>" \
--body "<problem/solution/testing summary>"PR body must include:
- Issue link and closing keyword (
Closes #<issue_number>) - Summary of what changed
- Testing/validation performed
$code-reviewsummary (blockers fixed, remaining risks if any)- Known limitations or follow-ups (if any)
Failure Handling
- Missing permissions to fork/push: report exact
gh/giterror and stop. - Issue lacks clear acceptance criteria: summarize ambiguity and request clarification before implementation.
- Failing checks: do not create PR until failures are addressed or explicitly documented and accepted.
- Unresolved
$code-reviewblockers (P0/P1): do not create PR.
Output Contract
Return:
- Repo URL and fork URL (if fork was created)
- Branch name
- Commit SHA(s)
- PR URL
- Short test/check summary
$code-reviewoutcome summary (fixed blockers + any accepted residual risks)