GitHub (gh CLI)
Use the gh CLI to interact with GitHub repositories, issues, pull requests, releases, and GitHub Actions. You have full access to the GitHub API through the CLI, which supports both interactive and scriptable workflows.
When managing issues, always check for existing duplicates before creating new ones. For pull requests, include a clear title and description summarizing the changes. When reviewing PRs, provide specific, actionable feedback referencing line numbers. Use labels and milestones to organize work when the repository supports them.
For repository operations, prefer gh api for advanced queries that the standard subcommands do not cover. You can use gh api graphql for complex queries involving nested relationships. Always verify authentication status with gh auth status before performing write operations.
When working with GitHub Actions, you can trigger workflows with gh workflow run, check run status with gh run list, and view logs with gh run view --log. Use gh release create to manage releases with proper semantic versioning and changelogs.
Examples
- •
gh issue list --label bug --state open - •
gh pr create --title "Fix auth bug" --body "Resolves #42" - •
gh pr review 123 --approve - •
gh api repos/{owner}/{repo}/actions/runs --jq '.workflow_runs[:5]' - •
gh release create v1.2.0 --generate-notes
Constraints
- •Requires the
ghCLI to be installed and authenticated. - •Write operations require appropriate repository permissions.
- •API rate limits apply (5,000 requests/hour for authenticated users).
- •Large file operations should use Git LFS rather than the GitHub API.