Gh CLI

Master GitHub CLI commands to automate repository management and development workflows

GitHub command-line interface enables repository management, issue tracking, and workflow automation without browser interaction. This skill provides comprehensive GitHub CLI guidance covering repository operations, issue management, pull request handling, workflow execution, and advanced automation enabling efficient GitHub interaction from terminal.

What Is This?

Overview

GitHub CLI offers command-line access to GitHub features. It guides authentication and configuration, demonstrates repository cloning and operations, shows issue creation and management, illustrates pull request workflows, covers GitHub Actions triggering, enables gist management, and provides automation patterns for common tasks.

The skill covers both interactive and scriptable CLI usage enabling manual operations and automated workflows. It emphasizes efficiency patterns and best practices for terminal-based GitHub interaction, making it suitable for both occasional use and deeply integrated development pipelines.

Who Should Use This

Developers preferring terminal workflows. DevOps engineers automating processes. CI/CD pipeline authors. Power users maximizing efficiency. Teams scripting GitHub operations. Open source maintainers managing repositories.

Why Use It?

Problems It Solves

Browser-based GitHub interaction interrupts terminal workflow. CLI keeps developers in familiar environment improving productivity and reducing context switching between applications.

Repetitive GitHub operations waste time. CLI enables automation through scripts and aliases, allowing teams to standardize common tasks and reduce human error in routine processes.

CI/CD workflows need GitHub integration. CLI provides scriptable interface for automated pipelines, supporting token-based authentication suitable for headless environments.

Multi-repository operations are tedious manually. CLI allows batch processing with shell loops, enabling engineers to apply consistent changes across dozens of repositories in a single script execution.

Core Highlights

Repository operations. Issue management. Pull request workflows. GitHub Actions integration. Gist handling. Release management. Authentication. Scripting and automation. Alias configuration.

How to Use It?

Basic Usage

Install and authenticate GitHub CLI before running any commands. Use commands for common operations with proper flags and options to control output format and behavior.

gh auth login
gh repo clone owner/repo
gh issue list
gh pr create

Specific Scenarios

For issue management, create and track issues efficiently using structured flags.

gh issue create --title "Bug fix" --body "Description"
gh issue view 123
gh issue close 123

For pull requests, manage the full lifecycle from creation through merge.

gh pr create --title "Feature" --body "Details"
gh pr list --author @me
gh pr merge 456

For automation, script workflows using JSON output combined with filtering tools.

gh pr list --json number,title | jq '.[] | select(.title | contains("bug"))'

Real World Examples

A developer works on a feature branch needing pull request creation. Instead of opening a browser, they use gh pr create with title and description flags, automatically linking the current branch, adding reviewers with flags, applying labels, and opening the PR for review. The entire workflow stays in the terminal, maintaining focus and reducing interruption.

A DevOps engineer automates the release process. A script uses gh release create with a version tag, generates release notes with automatic changelog, attaches build artifacts, marks as prerelease if needed, and notifies the team through integrated messaging. Releases become consistent, auditable, and significantly faster to execute.

A maintainer manages multiple repositories requiring bulk operations. A script loops through repos using gh api for advanced queries, creates issues for dependency updates, triggers workflows with gh workflow run, collects statistics, and generates a consolidated report. Multi-repo management becomes tractable even at scale.

Advanced Tips

Configure authentication tokens carefully for both interactive and automated contexts. Use JSON output for scripting to ensure reliable parsing. Create aliases for frequently used command combinations to reduce typing. Combine output with jq for flexible data processing. Leverage environment variables such as GH_TOKEN for CI environments. Use gh api for operations not yet covered by dedicated subcommands. Script repetitive workflows and store them in version control. Configure default repository and organization settings to simplify commands.

When to Use It?

Use Cases

Daily development workflows. CI/CD automation. Repository management. Issue tracking. Pull request management. Release automation. Multi-repo operations. GitHub Actions triggering.

Related Topics

Git command-line operations. GitHub API usage. Shell scripting. JSON processing with jq. CI/CD pipelines. Terminal productivity. Command-line automation.

Important Notes

Requirements

GitHub CLI installation. GitHub account with proper permissions. Understanding of Git basics. Terminal familiarity. Authentication tokens for automation.

Usage Recommendations

Authenticate securely with tokens. Use version control for scripts. Configure defaults appropriately. Combine with Git commands. Leverage aliases for efficiency. Test scripts in non-production environments first. Document automation workflows thoroughly. Keep CLI updated to access the latest features and security patches.

Limitations

Requires internet connectivity. Some features lack CLI equivalence. Complex operations may need direct API access. Authentication needs secure handling, particularly in shared environments. Learning curve for advanced usage increases with scripting complexity.