Skip to content

GitHub CLI

43.1k stars
official open-source Has MCP macOS Linux Windows Actively maintained

GitHub's official command-line tool. Manage pull requests, issues, repositories, and Actions workflows without leaving the terminal.

GitHub CLI has both a CLI and an MCP server. See when to use each

Part of the GitHub CLI tools for AI agents

What your agent can do

Your agent runs `gh issue list --state open --json number,title,labels` and gets structured JSON for every open issue. It reads each title, applies labels with `gh issue edit <number> --add-label bug`, assigns teams with `--add-assignee @frontend-team`, and closes duplicates with `gh issue close`. Twenty issues triaged in seconds. Zero browser tabs.Pull request workflows chain naturally. Your agent creates a branch, writes code, runs `gh pr create --fill` to auto-populate the title and body from commit messages, then requests review with `--reviewer @copilot` for an AI code review before a human even looks at it. When CI passes, `gh pr merge --squash --delete-branch` closes the loop.The hidden power feature is `gh api`. It hits any GitHub API endpoint with automatic authentication. Your agent chains it with `jq` for operations the web UI will never match: `gh api repos/{owner}/{repo}/pulls --jq '.[].title'` for custom dashboards, bulk label updates across hundreds of issues, or cross-repo audit queries. Most developers never discover `gh api`. Your agent uses it constantly.CI debugging happens in real-time. `gh run watch` streams workflow logs as they execute. When a run fails, your agent reads the output, identifies the failure, and either fixes the code or reruns the workflow with `gh run rerun`. No Actions tab refreshing. No clicking through log groups.GitHub shipped Agentic Workflows in February 2026. Drop a Markdown file into `.github/workflows/`, describe what you want in plain English, and `gh aw compile` converts it into executable Actions. Six built-in patterns: continuous triage, automatic documentation, code simplification, test improvement, CI failure investigation, and daily health reports. Your agent can both create and compile these workflows.GitHub's own benchmarks show 25% faster task completion via CLI compared to the web UI. For an agent processing dozens of operations per session, that speed gap compounds fast.

Limitations

Organization settings, billing, and GitHub App configuration are dashboard-only. The CLI is GitHub-specific with no GitLab or Bitbucket support. For visual code review with inline diff annotations, the web UI is still faster than terminal-based review. GitHub Projects board views (drag-and-drop, Kanban) have no CLI equivalent.

Key Commands

gh pr create Create a pull request from the current branch
gh pr merge Merge a pull request and clean up the branch
gh issue create Create a new issue with labels and assignees
gh repo clone Clone a repository to your local machine
gh run watch Watch a GitHub Actions workflow run in real time
gh copilot suggest Get AI-powered command suggestions from GitHub Copilot
gh api Make authenticated requests to the GitHub API

GitHub Stats

repo cli/cli
stars 43.1k
language Go
license MIT
last commit Mar 12, 2026

Alternatives

tool description
GitHub CLI current tool
hub The original GitHub CLI by Chris Wanstrath. Predecessor to gh, now in maintenance mode.

FAQ

Is GitHub CLI free?
Yes. GitHub CLI is free and open-source under the MIT license with 43,000+ stars. It works with GitHub Free, Pro, Team, and Enterprise accounts. Every feature is available on every plan, including `gh api` for direct API access.
How do you authenticate GitHub CLI?
Run `gh auth login` and follow the prompts. Authenticate via browser (OAuth) or paste a personal access token. For CI/CD pipelines and AI agents, set the `GH_TOKEN` environment variable. Authentication persists until you run `gh auth logout`. You can authenticate to multiple GitHub instances simultaneously.
Can GitHub CLI replace the GitHub website?
For your AI agent, `gh` replaces the GitHub website entirely. Your agent creates PRs, manages issues, monitors CI, reviews code, and queries the API through structured commands that return parseable output. The agent never opens a browser. Organization settings, billing, and GitHub App configuration remain dashboard-only for humans.
Does GitHub CLI work with GitHub Enterprise?
Yes. Run `gh auth login --hostname your-enterprise.github.com` to authenticate against your Enterprise instance. All commands work identically. Your agent can be authenticated to both github.com and your Enterprise instance at the same time.
What is the difference between git and gh?
git manages version control: commits, branches, merges. gh manages the GitHub platform: pull requests, issues, Actions, repos, and API access. Your agent uses both together. git for code operations, gh for everything GitHub. The distinction matters because gh adds structured output (JSON via `--json` flags) that agents can parse directly.

Last verified: Mar 14, 2026