cli/cli
Lore
The story of how cli/cli evolved, derived from git history (2019-10-03 to 2026-04-30, 11,228 commits on trunk).
Eras
The bootstrap (Oct 2019 - Feb 2020)
The repo opens with a single commit on 2019-10-03 from the GitHub team. CI lands the next morning, and within weeks gh issue and gh pr start to take shape. This era was conducted under the working name gh and was originally introduced as a successor to the long-running hub project. The early architecture (cmd/gh, pkg/cmd/<command>, an api/ package) is recognizably the same one used today.
Public beta and 1.0 (Feb 2020 - Sep 2020)
gh ships its first public beta in early 2020 and reaches v1.0 by autumn. The boundaries of pkg/cmd/issue/, pkg/cmd/pr/, pkg/cmd/repo/, pkg/cmd/auth/, and pkg/cmd/release/ are settled. The cmdutil.Factory pattern is established as the standard way to wire dependencies into commands. pkg/iostreams/ and pkg/httpmock/ solidify as the cross-cutting infrastructure.
The Codespaces integration (Apr 2021 - 2022)
GitHub Codespaces ships as a public product, and a substantial chunk of its CLI lives directly in cli/cli. The pkg/cmd/codespace/ and internal/codespaces/ trees are added with their own SSH, port-forwarding, and Live Share RPC clients. Today this is still one of the largest single subsystems by line count (internal/codespaces/api/api.go alone is ~37 KB).
Extensions and the platform years (2022 - 2023)
gh extension matures into a real package manager: precompiled binaries (2022), Go-source-tree extensions, and the "official extension stub" mechanism that gently nudges users toward GitHub-owned extensions when they invoke unrecognized commands. A search index (gh extension search), browse (gh extension browse), and a moq-based test mock (pkg/cmd/extension/mocks.go) all land here.
Attestation (early 2024)
A new pkg/cmd/attestation/ tree appears in early 2024 and grows quickly. It vendors a Sigstore + TUF verification stack (pkg/cmd/attestation/verification/, pkg/cmd/attestation/trustedroot/) and embeds an offline copy of the GitHub Sigstore trusted-root under pkg/cmd/attestation/verification/embed/tuf-repo.github.com/. From the same milestone, every gh release is itself signed and verifiable with gh at verify.
The agent and skills era (2025 - 2026)
The two most active areas of recent development:
- AI agent detection (added across 2025):
internal/agents/detect.gorecognizes Codex, Claude Code, Copilot CLI, Gemini CLI, Amp, and OpenCode from environment variables and propagates the result into the API user agent. This pre-datesgh skilland is reused by it. - Skills (
pkg/cmd/skills/,internal/skills/, started ~mid-2025): a full subsystem withinstall,update,publish,preview, andsearchsubcommands, plus an installer, a registry client, a discovery layer, a frontmatter parser, and a lockfile. As of April 2026, skills dominates the 90-day churn list (78 commits ininternal/skills/, 18 inpkg/cmd/skills/install/install.goalone). gh agent-task(added in this same window): a top-level command tree underpkg/cmd/agent-task/for orchestrating long-running AI tasks against a repository.gh accessibilityandgh copilotalso land in this era as first-party commands.
Longest-standing features
| Feature | First seen | Notes |
|---|---|---|
Cobra root + cmd/gh/main.go boot path |
2019-10 | The 4-step main -> ghcmd.Main -> root.NewCmdRoot -> Execute flow has been stable since v1.0. |
pkg/cmd/issue/list/list.go |
2020-08 | Has been the canonical example of "the right way to write a gh command" since 2020. |
pkg/iostreams/iostreams.go |
2019 / early 2020 | The TTY/color/pager abstraction has changed signatures rarely; new fields are added but the interface is stable. |
api/queries_repo.go |
2019 / early 2020 | Now ~46 KB; it has accreted queries continuously and remains the central place to add repository-related GraphQL/REST calls. |
pkg/httpmock/ |
2019 | The mock has been the testing primitive for HTTP since the project started. |
Deprecated and replaced surfaces
context/: marked DEPRECATED indocs/project-layout.md. New code only uses it for the legacyRemotestype.test/andutils/: also marked DEPRECATED.utils/survives as the home of "print a table" helpers that have not yet been migrated tointernal/tableprinter.gh secretv1 schema: replaced by the unified secrets handler inpkg/cmd/secret/sharedonce Actions, Codespaces, and Dependabot secrets converged.- Old prompter: the project migrated from raw
survey/v2calls scattered through commands to the centralizedinternal/prompterinterface (with mocked tests viamoq).survey/v2is still a transitive dependency for legacy UI elements. - Hub-style CLI: although
hub(the unofficial predecessor) is not in this repo,docs/gh-vs-hub.mdpreserves the rationale for splitting from it.
Major rewrites and migrations
- Config v1 to v2 (
internal/config/migration/): introduced when the CLI added multi-account support. The migration code still lives alongside the loader so older config files continue to upgrade in place. Seedocs/multiple-accounts.md. - ProjectsV1 to ProjectsV2: each
gh projectcommand was rewritten against the GraphQL ProjectsV2 API. Look for// TODO ProjectsV1Cleanupmarkers underpkg/cmd/project/for the cleanup tail. go-ghextraction: the lower-level HTTP and auth code lives incli/go-gh.api/client.gois now a thin wrapper that adds GitHub-specific headers, telemetry, and SSO redirect handling on top ofgo-gh'sapi.NewGraphQLClientandapi.NewRESTClient.- Telemetry over Twirp (2024 - 2025): the
internal/barista/observability/telemetry.twirp.goclient (40 KB, generated) replaced ad-hoc HTTP posts. Theinternal/telemetry/service now batches events and supports alogmode that flushes a human-readable summary to stderr. - Skills introduction (2025): not a rewrite but an entirely new top-level subsystem. It accounts for ~78 of 404
pkg/cmdchange events in the last 90 days.
Growth trajectory
- 2019-2020: single-digit committers, foundational packages.
- 2021-2022: the GitHub CLI team grows; Codespaces, Actions (
gh run,gh workflow), andgh extensionarrive. - 2023-2024: dependency hygiene (
golangci-lintratchets up), license-compliance tooling (internal/licenses), attestation, multi-account support. - 2025-2026: AI tooling becomes a first-class concern: agent detection,
gh skill,gh agent-task,gh accessibility,gh copilot, and a corresponding telemetry service.
The longest-tenured contributors (by commit count on trunk, excluding bots) are Mislav Marohnić, Kynan Ware, William Martin, vilmibm, Nate Smith, Babak K. Shandiz, Andy Feller, Corey Johnson, Meredith Lancaster (the dominant author of pkg/cmd/attestation/), and Sam Coe. Subsystem-specific ownership (e.g. Codespaces, attestation, skills) is enforced via .github/CODEOWNERS and surfaced in maintainers.md.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.