cli/cli
Fun facts
A small collection of things you would only learn from reading the source.
The em dash is banned
AGENTS.md instructs contributors and AI agents to "never use em dashes (-) in code, comments, or documentation; use regular dashes (-) or rewrite the sentence instead." A custom forbidigo rule enforces this in CI. This wiki follows the same rule.
gh verifies its own releases
Every release is signed via Sigstore and accompanied by a SLSA build-provenance attestation produced by .github/workflows/deployment.yml. You can verify a downloaded gh binary with gh attestation verify -R cli/cli <file>, using gh itself as the verifier. The trust root is embedded in the binary at pkg/cmd/attestation/verification/embed/tuf-repo.github.com/ so the verification works fully offline.
Six AI coding agents are recognized by name
internal/agents/detect.go sniffs environment variables to identify the calling agent: Amp, Claude Code, Codex, Copilot CLI, Gemini CLI, and OpenCode. The detection is intentionally ordered (e.g. Amp checks before Claude Code because Amp also sets CLAUDECODE=1). The detected name is propagated into the User-Agent header so server-side logs can attribute traffic without leaking user identity.
The biggest non-test file is a project query
pkg/cmd/project/shared/queries/queries.go weighs in at 52 KB, more than 46 KB). ProjectsV2's GraphQL schema is wide enough that holding all of its types and fragments in one file made for the easiest navigation, even though it dwarfs every other source file in the repo.api/queries_repo.go (
The CLI builds itself, on purpose
script/build.go is a Go program, not a shell script. The Makefile compiles it once with CGO_ENABLED=0 and then uses the resulting script/build binary for the actual bin/gh build. This keeps Windows and Unix on the same code path (go run script/build.go) and avoids any platform-specific build glue.
"Trunk" is the default branch
Most GitHub repos default to main. cli/cli calls its default branch trunk. The release workflow attaches build provenance certificates back to refs/heads/trunk, and the SLSA attestation chain breaks if you sign from anywhere else.
The largest test file would be a feature in another project
pkg/cmd/run/view/view_test.go is over 100 KB. It exhaustively asserts the rendered output of gh run view for run-failed, run-passing, in-progress, and reran scenarios across both TTY and non-TTY modes, and it predates the move to internal/tableprinter.
Not everything in the tree is current
docs/project-layout.md flags context/, test/, and utils/ as DEPRECATED. They survive only because removing them would touch a lot of older code paths. New code is expected to ignore them.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.