Manage GitHub issues, PRs, releases, and actions from the command line.
What Is GitHub CLI?
GitHub CLI (gh) lets you interact with GitHub directly from your terminal. No more switching between your editor and browser for common tasks.
Issues
Create, view, and close issues
Pull Requests
Create, review, and merge PRs
Releases
Create tags and releases
Actions
View and manage workflows
gh extensively for GitHub operations. Understanding these commands helps you review what agents propose.Authentication
First, authenticate with your GitHub account:
# Interactive login (recommended)$ gh auth login# Check your auth status$ gh auth status# View current user$ gh api user --jq '.login'
Working with Issues
# Create an issue interactively$ gh issue create# Create with labels and assignee$ gh issue create \--title "Fix login bug" \--body "Users can't login with email" \--label bug \--assignee @me
Pull Requests
Create and manage pull requests without leaving your terminal:
# Create a PR with title and body$ gh pr create \--title "Add user authentication" \--body "## SummaryImplements OAuth2 login flow.## Test plan- [x] Unit tests pass- [ ] Manual testing on staging"# Create a draft PR$ gh pr create --draft# Request review$ gh pr edit 456 --add-reviewer username# View PR checks status$ gh pr checks 456
--body "$(cat <<'EOF' ... EOF)"Releases & Tags
# Create a release with assets$ gh release create v2.0.0 \--title "Version 2.0.0" \--notes "Major update with new features" \./dist/*.zip# Create a pre-release$ gh release create v2.1.0-beta --prerelease# Delete a release (be careful!)$ gh release delete v1.0.0-test --yes
GitHub Actions
Monitor and interact with your CI/CD workflows:
# View failed runs$ gh run list --status failure# Trigger a workflow manually$ gh workflow run build.yml# Trigger with inputs$ gh workflow run deploy.yml -f environment=staging# View job logs for a specific job$ gh run view 123456 --job 789 --log
Repository Operations
Direct API Access
For advanced use cases, access the GitHub API directly:
# Get repo info as JSON$ gh api repos/owner/repo# List PR comments$ gh api repos/owner/repo/pulls/123/comments# Use jq to extract specific fields$ gh api user --jq '.login, .email'# POST to create something$ gh api repos/owner/repo/issues \-f title="API created issue" \-f body="Created via gh api"
gh api for operations not covered by the standard commands. Review these carefully as they have full API access.Best Practices
Always review PR details before merging
Use gh pr view and gh pr diff to understand changes.
Use --dry-run where available
Some commands support --dry-run to preview actions.
Check workflow status before deploying
Run gh run list to ensure CI passed before releasing.
Use labels and milestones
Organize issues with --label and --milestone flags.
Review agent-created PRs carefully
Agents may create PRs automatically. Always review before merging.
Try It Now
1# Check if gh is installed and authenticated2$ gh auth status34# View the current repository5$ gh repo view67# List recent issues8$ gh issue list --limit 5910# List recent PRs11$ gh pr list --limit 51213# Check recent workflow runs14$ gh run list --limit 5