cli/cli
GitHub CLI
gh is GitHub on the command line. The repository at cli/cli ships a single Go binary that brings pull requests, issues, releases, GitHub Actions, Codespaces, repository management, and many other GitHub features to the terminal next to where you already work with git.
What this codebase is
- A Go (1.26+) project with module path
github.com/cli/cli/v2. - A Cobra-based CLI rooted at
cmd/gh/main.goand assembled inpkg/cmd/root/root.go. - Hundreds of subcommands, each living in its own
pkg/cmd/<command>/<subcommand>/package. - A GitHub API client (
api/), a git client wrapper (git/), a feature-detection layer (internal/featuredetection/), terminal I/O abstractions (pkg/iostreams/), and an HTTP mocking framework (pkg/httpmock/). - An extension system (
pkg/cmd/extension/) that lets users install third-partygh-<name>extensions. - An attestation subsystem (
pkg/cmd/attestation/) that verifies SLSA provenance via Sigstore. - A skills subsystem (
pkg/cmd/skills/,internal/skills/) for installing and running natural-language workflows.
Who uses it
- Developers running
ghfrom a terminal on macOS, Linux, or Windows againstgithub.com, GitHub Enterprise Cloud, or GitHub Enterprise Server 2.20+. - AI coding agents (Codex, Claude Code, Copilot CLI, Gemini CLI, Amp, OpenCode) that detect themselves via environment variables and identify in API headers. See
internal/agents/detect.go. - CI pipelines via the pre-installed
ghon GitHub-hosted runners.
Quick links
- Architecture: how the binary is structured and how a single
ghinvocation flows. - Getting started: how to build, test, and lint locally.
- Glossary: vocabulary specific to this codebase.
- How to contribute: branching, PRs, and the definition of done.
- Commands: every
ghtop-level command, grouped by domain. - Systems: internal subsystems shared across commands.
- Reference: configuration, dependencies, and other reference material.
Where to look first
- New
ghcommand:pkg/cmd/<command>/<subcommand>/. The canonical example ispkg/cmd/issue/list/list.go. - Root command wiring:
pkg/cmd/root/root.go. - Factory and shared dependencies:
pkg/cmd/factory/default.go. - API client:
api/client.go.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.