GitHub CLI Power Tips - Hidden Gems to Supercharge Your Workflow

03 Jan 2026

The GitHub CLI (gh) is a powerful tool that brings GitHub functionality right to your terminal. While most developers know the basics like gh pr create or gh issue list, there are tons of hidden gems that can supercharge your workflow. Here are some of my favourite tips and tricks.

1. Check Repository Visibility in Seconds

Ever wondered if a repo is private or public without opening your browser?

# Simple boolean check
gh repo view --json isPrivate

# Get the visibility status (PRIVATE, PUBLIC, or INTERNAL)
gh repo view --json visibility --jq '.visibility'

Output:

{"isPrivate":true}

2. Query Any Repository Data with JSON

The --json flag is incredibly powerful. You can query almost any field:

# Get multiple fields at once
gh repo view --json name,description,stargazerCount,forkCount

# Pretty print with jq
gh repo view --json name,isPrivate,visibility --jq '.'

3. Find Your Pull Requests

Quickly find your PRs in the current repo or search across all repos:

# List your PRs in current repository
gh pr list --author @me

# Search all your PRs across all accessible repos
gh search prs "author:@me"

# Search PRs in a specific org
gh search prs "org:my-org author:@me"

# Search PRs by state across all repos
gh search prs "author:@me is:merged" --limit 10

4. Quick PR Checkout

Need to review a PR locally? Skip the manual git commands:

# Checkout PR by number
gh pr checkout 123

# Or by URL
gh pr checkout https://github.com/owner/repo/pull/456

5. View PR Diff Without Leaving Terminal

# View the diff of a PR
gh pr diff 123

# View files changed
gh pr view 123 --json files --jq '.files[].path'

6. Bulk Repository Operations

Get creative with JSON output and jq:

# List all your repos with their URLs
gh repo list --json name,url --jq '.[] | "\(.name): \(.url)"'

# Find all private repos
gh repo list --json name,isPrivate --jq '.[] | select(.isPrivate == true) | .name'

7. Watch GitHub Actions in Real-Time

# List recent workflow runs
gh run list

# Watch a run in progress
gh run watch

# View logs for a specific run
gh run view 123456 --log

8. Create Issues from Templates

# Create issue interactively
gh issue create

# Create with flags
gh issue create --title "Bug: Login failing" --body "Description here" --label bug

9. API Access Made Easy

Access any GitHub API endpoint without authentication headers:

# Get repo details via API
gh api repos/owner/repo

# Get PR comments
gh api repos/owner/repo/pulls/123/comments

# POST requests work too
gh api repos/owner/repo/issues --field title="New Issue" --field body="Content"

10. Search Code Across GitHub

# Search for code in your repos
gh search code "function authenticate" --owner yourusername

# Search repos
gh search repos "machine learning" --language python --sort stars

11. Aliases for Frequent Commands

Create custom shortcuts:

# Set up an alias
gh alias set pv 'pr view --web'

# Now use it
gh pv 123

View your aliases:

gh alias list

12. Format Output for Scripts

Use --json with --jq for perfect script integration:

# Get just the PR number
PR_NUM=$(gh pr view --json number --jq '.number')

# Check if repo is private (returns true/false)
IS_PRIVATE=$(gh repo view --json isPrivate --jq '.isPrivate')

# Get list of open PR numbers
gh pr list --json number --jq '.[].number'

CI/CD Example: Gate deployment on open PRs

This pattern is useful when you want to ensure all changes go through PR review before deploying to production:

#!/bin/bash
# Fail deployment if there are open PRs
OPEN_PRS=$(gh pr list --json number --jq '. | length')
if [ "$OPEN_PRS" -gt 0 ]; then
  echo "Cannot deploy: $OPEN_PRS open PR(s) found"
  exit 1
fi
echo "No open PRs. Proceeding with deployment..."

13. Quick Repository Stats

# Get star count, forks, description
gh repo view --json stargazerCount,forkCount,description

# Get issue count via GraphQL
gh repo view --json issues --jq '.issues.totalCount'

# Watch a repo's stars grow
watch -n 60 'gh repo view --json stargazerCount --jq .stargazerCount'

14. Manage Gists from Terminal

# Create a gist
gh gist create myfile.py --public

# List your gists
gh gist list

# View a gist
gh gist view abc123

15. Check Your Rate Limit

# See API rate limit status
gh api rate_limit

Pro Tips

  1. Combine with jq: The --jq flag is your best friend for extracting specific data
  2. Use --help liberally: Every command has detailed help: gh pr --help
  3. Tab completion: Enable it for your shell - makes commands much faster
  4. JSON everywhere: Almost every gh command supports --json for structured output
  5. Pipe-friendly: Designed to work great with Unix pipes and other command-line tools

Bonus: One-Liners I Use Daily

# Find all my open PRs across all repos
gh search prs "author:@me is:open"

# Find PRs that need my review (across all repos)
gh search prs "review-requested:@me is:open"

# Quick PR review workflow
gh pr checkout 123 && code . && gh pr review

# Clone and open in VS Code
gh repo clone owner/repo && cd repo && code .

# Check CI status
gh pr checks

# Create PR with auto-filled template
gh pr create --fill

The GitHub CLI is constantly evolving with new features. Run gh --version to make sure you’re on the latest version, and check gh help to discover even more commands.

What are your favourite gh CLI tricks? Let me know in the comments!