Github CLI is Cool!

Github CLI is Cool!

Published: 8/20/2025

tags: githubclitoolsgit

How Github CLI + Codespaces + free AI = Awesome


If you’re not using Github CLI you really are missing out. I’ve been diving deep and honestly, it’s been a real game-changer for my workflow. If you like to try and stay inside the terminal with git being at the heart of everything is super helpful. Let me show you how I’m using it to streamline everything from Codespaces to AI powered development.

Getting Started with GitHub CLI

First things first, download the CLI tool with:

Terminal window
# On macOS
brew install gh
# On Windows
winget install GitHub.cli
# On Ubuntu/Debian
sudo apt install gh

After installation, authenticate with:

Terminal window
gh auth login

From here you can sign in when the browser opens.

Managing Pull Requests Like a Pro

Instead of clicking through the GitHub UI, I handle PRs right from my terminal:

Terminal window
# Create a PR and reference an issue
gh pr create --title "feat: add user authentication" --body "Closes #42"
# Check PR status (super helpful during CI runs)
gh pr status
# Review a PR's changes
gh pr diff
# The real MVP - checkout a PR locally
gh pr checkout 123

Codespaces - Your Dev Environment Anywhere

I’ve been loving Codespaces for consistent development environments. The free tier with, like, 120 hours on a 4gb machine is awesome when you don’t have a good machine or server you can use. Here’s how I manage them:

Terminal window
# Start a new Codespace with beefier specs
gh codespace create -r myorg/myrepo
# List all my active Codespaces
gh codespace list
# SSH into an existing Codespace
gh codespace ssh -c mycodespace-name

Adding Extensions Using GitHub Copilot from the CLI

This is where Github CLI really shines. You can add community built extensions like gh-dash and gh-models to improve and extended usability. You can start experimenting with GitHub’s AI features through the CLI and here is how copilot would work:

Terminal window
# Install the Copilot extension
gh extension install github/gh-copilot
# Get AI-powered command suggestions and you can
gh copilot suggest "command to find all python files modified in the last week"
# Get explanations for complex commands
gh copilot explain "git rebase -i HEAD~3"

It’s hard to find a happy medium with Ai but these AI features can significantly boost productivity, especially for complex tasks or when working with unfamiliar commands. I don’t care what people say; they are super helpful. Github offers a lot of models for free right now for building AI applications, which can be done in codespaces for quick setup. Then there is also a playground mode on the website like some others do. Here is how you can use latest models at no cost via the CLI.

Using GitHub Models from the CLI

GitHub CLI also integrates with these models, which makes it really easy to access AI in your terminal for fast answers without using any resources besides internet data. It is helpful to set aliases if you don’t want to enter the menu and choose a model. Here’s how you can leverage them:

Terminal window
# Install the GitHub Models extension
gh extension install github/gh-models
# List available AI models
gh models
# Run a model with a prompt
gh models run gpt-4o "why is the sky blue?"

Repository Management

Working with repos becomes much smoother:

Terminal window
# Clone a repo (way faster than copying URLs)
gh repo clone myorg/myrepo
# Create a new repo and set it up locally
gh repo create my-new-project --public --clone
# View repository insights
gh repo view --web

Quick Issue Management

And for those times when you need to create or track issues or maintainers:

Terminal window
# Create an issue with labels
gh issue create --title "Bug in login flow" --label "bug,urgent" --assignee @me
# List all issues assigned to you
gh issue list --assignee @me
# Close an issue
gh issue close 123 --comment "Fixed in PR #456"

Custom Scripts and Aliases

With Github CLI, you can add aliases or pipe commands together, even using the api into easy to use scripts, you can save a lot of time. Here’s one I use for new projects based on templates that creates a branch and starts a Codespace with one command:

#!/bin/bash
setup_project() {
local repo_name=$1
local template=$2
# Create new repo from template
gh repo create "$repo_name" --private --template "$template"
# Clone and set up Codespace
gh repo clone "$repo_name"
cd "$repo_name"
gh codespace create
# Set up branch protection
gh api "repos/$repo_name/branches/main/protection" \\
--method PUT \\
--field required_status_checks.strict=true \\
--field required_pull_request_reviews.required_approving_review_count=1
}
# Usage: setup_project "new-project" "org/template-repo"

Why Use Github CLI

Moving to Github CLI may not seem like a big change, but it has seriously improved my productivity. No more context switching between browser tabs, no more clicking through menus, and way less time spent on repetitive tasks. Plus, with the AI features integrated right into the terminal; it’s just super convenient. Whether you’re managing pull requests, creating repos, spinning up Codespaces, or leveraging AI with gh models, having everything accessible from the terminal just makes sense. It’s well worth giving it a try over plain git commands!