GitHub CLI Setup for Cursor

Purpose: Configure GitHub CLI (gh) to create PRs and manage GitHub repositories directly from Cursor

This guide ensures you have GitHub CLI installed and authenticated so you can create PRs, manage issues, and interact with GitHub repositories directly from the terminal in Cursor.


Prerequisites

  • Cursor installed and running
  • macOS (this guide assumes macOS; adjust for other platforms)
  • Homebrew installed (for package management)

Step 1: Install GitHub CLI (gh)

GitHub CLI allows you to create PRs, manage issues, and interact with GitHub repositories directly from the terminal.

Installation

brew install gh

Verify Installation

gh --version

You should see output like:

gh version 2.x.x (xxxx-xx-xx)

Step 2: Authenticate GitHub CLI

gh auth login
  1. Select GitHub.com
  2. Select HTTPS for Git operations
  3. Select Login with a web browser
  4. Copy the one-time code shown
  5. Press Enter to open your browser
  6. Paste the code and authorize

Option B: Token Authentication

If you prefer using a personal access token:

gh auth login --with-token < token.txt

Where token.txt contains your GitHub personal access token with repo scope.

Verify Authentication

gh auth status

You should see:

github.com
  ✓ Logged in to github.com as [your-username]
  - Active account: true
  - Git operations protocol: https
  - Token scopes: 'gist', 'read:org', 'repo', 'workflow'

Step 3: Configure Git (if not already done)

git config --global user.name "Your Name"
git config --global user.email "your.email@brainforge.ai"

Step 4: Test PR Creation

Create a test branch and PR to verify everything works:

# Navigate to a repository
cd /path/to/your/repo
 
# Create a test branch
git checkout -b test/setup-verification
 
# Make a small change
echo "# Setup Verification\n\nThis PR verifies gh CLI is working correctly." > test-setup.md
git add test-setup.md
git commit -m "Test: Verify gh CLI setup"
git push -u origin test/setup-verification
 
# Create a draft PR
gh pr create --draft --title "Test: Setup Verification" --body "Verifying gh CLI is configured correctly"

If successful, you’ll see a PR URL. You can close/delete this test PR afterward.


Common Issues & Solutions

Issue: gh: command not found

Solution: Make sure Homebrew is installed and in your PATH:

# Check if Homebrew is installed
which brew
 
# If not installed, install it:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
 
# Then install gh:
brew install gh

Issue: Authentication fails

Solution:

  1. Check your internet connection
  2. Try logging out and back in: gh auth logout then gh auth login
  3. Verify your GitHub account has access to the brainforge-ai organization

Issue: Can’t create PRs

Solution:

  1. Verify authentication: gh auth status
  2. Check you have write access to the repository
  3. Ensure you’re on the correct branch and have pushed your changes

Git Credential Helper

To avoid entering credentials repeatedly:

# macOS Keychain
git config --global credential.helper osxkeychain
 
# Or use gh for Git operations
gh auth setup-git

Cursor Extensions

Consider installing these Cursor extensions for better GitHub workflow:

  • GitLens - Enhanced Git capabilities
  • GitHub Pull Requests - PR management in Cursor
  • Markdown All in One - Better markdown editing

Verification Checklist

Before you start working, verify:

  • gh --version works
  • gh auth status shows you’re logged in
  • gh pr list shows PRs (or empty list if none)
  • You can create a test PR successfully
  • Git is configured with your name and email

Common Workflows

Creating a PR from Cursor

# 1. Make your changes
git checkout -b feature/my-feature
# ... make changes ...
git add .
git commit -m "Add feature X"
 
# 2. Push branch
git push -u origin feature/my-feature
 
# 3. Create PR
gh pr create --title "Add feature X" --body "Description of changes"

Creating a Draft PR

gh pr create --draft --title "WIP: Feature X" --body "Work in progress"

Updating PR Description

gh pr edit [PR_NUMBER] --body "Updated description"

Getting Help

If you run into issues:

  1. Check this guide’s “Common Issues” section
  2. Review GitHub CLI documentation
  3. Ask in engineering or ops Slack channels

Last Updated: January 2026
Related: Linear MCP Setup