GitHub CLI 2.0 opens the door to custom commands

GitHub CLI has shipped version 2.0 with support for extensions, letting developers build their own commands on top of the tool's core functionality. Extensions are plain repositories prefixed with gh-, so distributing a custom command is as simple as pushing a repo to GitHub.

The release builds on the foundation laid by GitHub CLI 1.0, which aimed to bring end-to-end developer workflows into the terminal. Since then, the tool has gained stronger scripting support and tighter integration with GitHub Actions. But a single fixed feature set can't cover every workflow, and extensions are meant to close that gap—anyone can now tailor GitHub CLI to their own needs, or install extensions others have published.

Creating an extension

Getting started with a new extension is straightforward. Because an extension is only a repository with the gh- prefix, you can define its behavior however you like. To remove the boilerplate, GitHub CLI includes the gh extension create command, which scaffolds a repository with pre-written Bash that you can build on.

More detail on authoring extensions is available in the official documentation, along with the source for the example projects below.

What the team built as examples

To demonstrate the range of what extensions can do, the GitHub CLI team released several examples—from practical issue-management tools to purely decorative ones.

gh user-status sets your GitHub user status right from the terminal, useful for signaling when you're unavailable or in a focus session.

GIF demo of `gh user-status`

gh branch is a fuzzy-finder branch switcher. Branches are ordered by how recently they were used, and the extension surfaces details about any pull requests tied to the branch you're considering.

GIF demo of `gh branch`

gh contribute is aimed at open source contributors hunting for a task. It locates issues in a project that carry help wanted or good first issue labels, were opened in the past year, and don't yet have an associated pull request.

GIF demo of `gh contribute`

gh screensaver shows that extensions don't have to be utilitarian. It runs a full-screen ASCII art screensaver, joining the already-existing gh repo garden on the lighter side of the CLI.

GIF demo of `gh screensaver`

gh triage packages the process the team uses for triaging issues in its open source repository. The intended use is less as a drop-in tool and more as a template—something to study and adapt into a triage workflow that fits your own project.

GIF demo of `gh triage`

Extensions built by the community can be shared in the GitHub CLI repository's discussion board. GitHub CLI itself is available to install from cli.github.com.