--- name: github description: | This skill should be used when the user mentions GitHub PRs, issues, workflows, releases, or repository management. Triggers on keywords like "github", "gh", "pr", "pull request", "issue", "workflow", "actions", "release", "merge", "review", "ci", "check", or PR/issue number patterns like "#123". version: 1.0.0 --- # GitHub CLI Skill This skill enables natural language interaction with GitHub via the `gh` CLI tool (https://cli.github.com/). ## Quick Reference | Intent | Command | | --------------- | -------------------------------------- | | View PR | `gh pr view NUMBER` | | List PRs | `gh pr list` | | My PRs | `gh pr list --author @me` | | Create PR | `gh pr create -t "Title" -b "Body"` | | PR status | `gh pr status` | | Merge PR | `gh pr merge NUMBER` | | View issue | `gh issue view NUMBER` | | List issues | `gh issue list` | | Create issue | `gh issue create -t "Title" -b "Body"` | | Workflow runs | `gh run list` | | View run | `gh run view RUN-ID` | | Repo info | `gh repo view` | | Open in browser | `gh browse` | ## Pull Requests ### Viewing PRs ```bash # View PR in terminal gh pr view NUMBER # View PR in browser gh pr view NUMBER --web # View PR with comments gh pr view NUMBER --comments # View PR diff gh pr diff NUMBER # View PR checks/CI status gh pr checks NUMBER # View PR files changed gh pr diff NUMBER --name-only # View current branch's PR gh pr view # Get PR as JSON (for scripting) gh pr view NUMBER --json number,title,state,mergeable,reviewDecision ``` ### Listing PRs ```bash # List open PRs gh pr list # List my PRs gh pr list --author @me # List PRs assigned to me for review gh pr list --search "review-requested:@me" # List PRs by state gh pr list --state open gh pr list --state closed gh pr list --state merged gh pr list --state all # List PRs by label gh pr list --label bug gh pr list --label "needs review" # List PRs by base branch gh pr list --base main gh pr list --base develop # List PRs by head branch gh pr list --head feature/my-branch # List draft PRs gh pr list --draft # Search PRs gh pr list --search "fix login" gh pr list --search "author:username" gh pr list --search "is:open is:draft" # Limit results gh pr list --limit 10 # JSON output for scripting gh pr list --json number,title,author,createdAt # Web view of PR list gh pr list --web ``` ### Creating PRs ```bash # Interactive PR creation gh pr create # Non-interactive with title and body gh pr create --title "Add feature X" --body "Description here" # Create with specific base branch gh pr create --base develop # Create draft PR gh pr create --draft --title "WIP: Feature" # Create and request reviewers gh pr create --title "Feature" --reviewer user1,user2 # Create with assignees gh pr create --title "Feature" --assignee @me,user2 # Create with labels gh pr create --title "Fix" --label bug,urgent # Create with milestone gh pr create --title "Feature" --milestone "v1.0" # Create with project gh pr create --title "Feature" --project "Project Name" # Create from issue (links PR to issue) gh pr create --title "Fix #123" --body "Closes #123" # Fill title/body from commit messages gh pr create --fill # Fill from specific commit gh pr create --fill-first # Use template gh pr create --template bug_report.md # Create and open in browser gh pr create --title "Feature" --web # Read body from file gh pr create --title "Feature" --body-file DESCRIPTION.md ``` ### PR Status and Checks ```bash # Show status of PRs relevant to you gh pr status # Check CI status for a PR gh pr checks NUMBER # Watch CI status (updates live) gh pr checks NUMBER --watch # Wait for checks to complete gh pr checks NUMBER --watch --fail-fast # Check specific PR's review status gh pr view NUMBER --json reviewDecision,reviews # List required checks gh pr checks NUMBER --required ``` ### Reviewing PRs ```bash # Start a review gh pr review NUMBER # Approve PR gh pr review NUMBER --approve # Request changes gh pr review NUMBER --request-changes --body "Please fix X" # Comment without approval/rejection gh pr review NUMBER --comment --body "Looks good overall" # View PR diff for review gh pr diff NUMBER # Checkout PR locally for testing gh pr checkout NUMBER # Checkout PR to specific branch gh pr checkout NUMBER --branch test-pr-123 # Add comment to PR gh pr comment NUMBER --body "Comment text" # Edit PR comment gh pr comment NUMBER --edit-last --body "Updated comment" ``` ### Merging PRs ```bash # Merge PR (uses repo default method) gh pr merge NUMBER # Merge with specific method gh pr merge NUMBER --merge # Create merge commit gh pr merge NUMBER --squash # Squash and merge gh pr merge NUMBER --rebase # Rebase and merge # Merge and delete branch gh pr merge NUMBER --delete-branch # Auto-merge when checks pass gh pr merge NUMBER --auto # Disable auto-merge gh pr merge NUMBER --disable-auto # Merge with custom commit message gh pr merge NUMBER --squash --subject "feat: add feature" --body "Details" # Admin merge (bypass protections) gh pr merge NUMBER --admin ``` ### Editing PRs ```bash # Edit PR title gh pr edit NUMBER --title "New title" # Edit PR body gh pr edit NUMBER --body "New description" # Add labels gh pr edit NUMBER --add-label bug,urgent # Remove labels gh pr edit NUMBER --remove-label wip # Add reviewers gh pr edit NUMBER --add-reviewer user1,user2 # Remove reviewers gh pr edit NUMBER --remove-reviewer user1 # Add assignees gh pr edit NUMBER --add-assignee @me # Set milestone gh pr edit NUMBER --milestone "v1.0" # Convert to draft gh pr ready NUMBER --undo # Mark ready for review gh pr ready NUMBER # Set base branch gh pr edit NUMBER --base develop ``` ### Closing/Reopening PRs ```bash # Close PR gh pr close NUMBER # Close with comment gh pr close NUMBER --comment "Closing because..." # Close and delete branch gh pr close NUMBER --delete-branch # Reopen PR gh pr reopen NUMBER ``` ## Issues ### Viewing Issues ```bash # View issue gh issue view NUMBER # View in browser gh issue view NUMBER --web # View with comments gh issue view NUMBER --comments # Get issue as JSON gh issue view NUMBER --json number,title,state,labels,assignees ``` ### Listing Issues ```bash # List open issues gh issue list # List my issues gh issue list --assignee @me # List issues I created gh issue list --author @me # List issues mentioning me gh issue list --mention @me # List by state gh issue list --state open gh issue list --state closed gh issue list --state all # List by label gh issue list --label bug gh issue list --label "help wanted" # List by milestone gh issue list --milestone "v1.0" # Search issues gh issue list --search "login error" gh issue list --search "is:open label:bug" # Limit results gh issue list --limit 20 # JSON output gh issue list --json number,title,labels,createdAt # Web view gh issue list --web ``` ### Creating Issues ```bash # Interactive creation gh issue create # Non-interactive gh issue create --title "Bug: X not working" --body "Description" # Create with labels gh issue create --title "Bug" --label bug,urgent # Create with assignees gh issue create --title "Task" --assignee @me,user2 # Create with milestone gh issue create --title "Feature" --milestone "v1.0" # Create with project gh issue create --title "Feature" --project "Project Name" # Use template gh issue create --template bug_report.md # Read body from file gh issue create --title "Feature" --body-file ISSUE.md # Create and open in browser gh issue create --title "Bug" --web # Create from current branch name gh issue create --recover ``` ### Editing Issues ```bash # Edit title gh issue edit NUMBER --title "New title" # Edit body gh issue edit NUMBER --body "New description" # Add labels gh issue edit NUMBER --add-label bug,urgent # Remove labels gh issue edit NUMBER --remove-label wip # Add assignees gh issue edit NUMBER --add-assignee user1 # Remove assignees gh issue edit NUMBER --remove-assignee user1 # Set milestone gh issue edit NUMBER --milestone "v1.0" # Add to project gh issue edit NUMBER --add-project "Project Name" ``` ### Closing/Reopening Issues ```bash # Close issue gh issue close NUMBER # Close with comment gh issue close NUMBER --comment "Fixed in #PR" # Close as completed gh issue close NUMBER --reason completed # Close as not planned gh issue close NUMBER --reason "not planned" # Reopen issue gh issue reopen NUMBER ``` ### Issue Comments ```bash # Add comment gh issue comment NUMBER --body "Comment text" # Edit last comment gh issue comment NUMBER --edit-last --body "Updated" # Open comment editor gh issue comment NUMBER --editor ``` ### Linking Issues and PRs ```bash # Create PR that closes issue gh pr create --title "Fix #123" --body "Closes #123" # Link issue in PR body gh pr create --body "Fixes #123, Related to #456" # Develop on issue (create branch) gh issue develop NUMBER # Develop with custom branch name gh issue develop NUMBER --name feature/fix-issue # Develop and checkout gh issue develop NUMBER --checkout ``` ## Workflows and Actions ### Listing Runs ```bash # List recent workflow runs gh run list # List runs for specific workflow gh run list --workflow build.yml # List runs by status gh run list --status success gh run list --status failure gh run list --status in_progress # List runs for branch gh run list --branch main # List runs for user gh run list --user @me # Limit results gh run list --limit 10 # JSON output gh run list --json databaseId,status,conclusion,name # Web view gh run list --web ``` ### Viewing Runs ```bash # View run details gh run view RUN-ID # View run in browser gh run view RUN-ID --web # View specific job gh run view RUN-ID --job JOB-ID # View run log gh run view RUN-ID --log # View failed job logs only gh run view RUN-ID --log-failed # Exit with run's exit code gh run view RUN-ID --exit-status # Watch run progress gh run watch RUN-ID # Get run as JSON gh run view RUN-ID --json status,conclusion,jobs ``` ### Managing Runs ```bash # Rerun failed jobs gh run rerun RUN-ID --failed # Rerun all jobs gh run rerun RUN-ID # Rerun specific job gh run rerun RUN-ID --job JOB-ID # Rerun with debug logging gh run rerun RUN-ID --debug # Cancel a run gh run cancel RUN-ID # Delete a run gh run delete RUN-ID # Download run artifacts gh run download RUN-ID # Download specific artifact gh run download RUN-ID --name artifact-name # Download to specific directory gh run download RUN-ID --dir ./artifacts ``` ### Triggering Workflows ```bash # Trigger workflow (workflow_dispatch) gh workflow run workflow.yml # Trigger with inputs gh workflow run workflow.yml -f param1=value1 -f param2=value2 # Trigger on specific branch gh workflow run workflow.yml --ref feature-branch # Trigger from JSON file gh workflow run workflow.yml --json