--- name: gh-cli description: Interact with GitHub repositories, issues, PRs, workflows, and more using the gh CLI. Use for GitHub operations like creating issues/PRs, managing repos, checking workflow runs, and browsing GitHub resources. --- # GitHub CLI (gh) ## Purpose Execute GitHub operations directly from the command line using the `gh` CLI tool. ## When to Use - Creating, viewing, or managing issues and pull requests - Repository operations (clone, create, view, fork) - Checking GitHub Actions workflow runs and caches - Managing releases, gists, and secrets - Searching GitHub for repos, issues, or PRs - Opening GitHub resources in the browser - Making authenticated GitHub API calls ## Core Commands ### Repository Management ```bash gh repo create # Create a new repository gh repo clone # Clone a repository gh repo view [repo] # View repository details gh repo fork [repo] # Fork a repository ``` ### Issues ```bash gh issue create # Create a new issue gh issue list # List issues gh issue view # View issue details gh issue close # Close an issue ``` ### Pull Requests ```bash gh pr create # Create a new PR gh pr list # List PRs gh pr view # View PR details gh pr checkout # Checkout a PR locally gh pr merge # Merge a PR gh pr status # Show status of PRs ``` ### GitHub Actions ```bash gh run list # List workflow runs gh run view # View run details gh run watch # Watch a run in real-time gh workflow list # List workflows gh workflow view # View workflow details ``` ### Releases ```bash gh release create # Create a release gh release list # List releases gh release view # View release details ``` ### Search ```bash gh search repos # Search repositories gh search issues # Search issues gh search prs # Search pull requests ``` ### Browse ```bash gh browse # Open repo in browser gh browse # Open issue/PR in browser ``` ### API Access ```bash gh api # Make authenticated API request gh api repos/:owner/:repo/issues # Example: list issues via API ``` ## Common Flags - `--repo ` - Specify repository - `--json` - Output as JSON - `--jq ` - Filter JSON output with jq - `--web` - Open in web browser - `--help` - Show help for any command ## Authentication Check authentication status: ```bash gh auth status ``` Login (if needed): ```bash gh auth login ``` ## Examples ```bash # Create an issue in current repo gh issue create --title "Bug: Login fails" --body "Description here" # List open PRs with JSON output gh pr list --state open --json number,title,author # View workflow run details gh run view 12345 # Clone a repository gh repo clone owner/repo # Search for Rust repositories gh search repos --language rust --sort stars # Make a custom API call gh api graphql -f query='query { viewer { login } }' ``` ## Notes - Most commands work in the context of the current git repository - Use `--repo owner/name` to operate on a different repository - Authentication is required for most operations - Use `gh --help` for detailed command documentation