Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News GitHub CLI 2.0 Brings Support for Extensions

GitHub CLI 2.0 Brings Support for Extensions

This item in japanese

With its new major version, GitHub CLI enables extending its basic feature set by installing and running extensions. A GitHub CLI extension is just a repository prefixed with gh- and providing an executable file with the same name as the repository.

GitHub provided a number of example extensions to both show what is possible to do with them and to allow developers to get started more quickly. In particular, the gh contribute extension will find an issue to work on and start contributing to an open source project. The gh branch extension is able to sort all branches by date with any associated open pull request.

As mentioned, a GitHub CLI extension is just a repository. You can create one easily by running the following command, which will create the repo for you and display further instructions:

gh extension create <extension-name>

You can also install and use a local extension before pushing it to GitHub by running the following command from your extension directory:

gh extension install .

Optionally, if you want other developers to know about your extensions, you can add the gh-extension topic to their repos, which will make them listed here.

You can list all installed extensions by running gh extension list and you can upgrade any extension by running gh extension upgrade <extension-name> or all of them with gh extension upgrade --all.

You can write a GitHub CLI extension using the language you prefer, says GitHub, with the only requirement that the file implementing the extension behaviour has execution privilege. This implies that any user of your extension will need to have the interpreter for that language installed on their machine. For this reason, GitHub recommends implementing extensions as bash scripts, which are widely supported.

It is important to notice that GitHub CLI will run extensions using the same privileges as those granted to your current user and without any specific provisions against malicious code such as sandboxing or static analysis. Therefore, you are strongly advised to carefully review the code of any third-party extension you install before using it.

GitHub CLI was introduced as a beta in the first months of 2020 with the aim of making it possible for developers to work with issues and pull requests without leaving the command line. The tool was therefore never meant to replace or compete in functionality with Git's command line client, rather it is an attempt to complement it for GitHub-specific developer workflows. Extensions constitute another step in the direction of letting developers customize their GitHub workflow according to their preferences.

Rate this Article