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 ghVerify Installation
gh --versionYou should see output like:
gh version 2.x.x (xxxx-xx-xx)
Step 2: Authenticate GitHub CLI
Option A: Web Browser (Recommended)
gh auth login- Select GitHub.com
- Select HTTPS for Git operations
- Select Login with a web browser
- Copy the one-time code shown
- Press Enter to open your browser
- Paste the code and authorize
Option B: Token Authentication
If you prefer using a personal access token:
gh auth login --with-token < token.txtWhere token.txt contains your GitHub personal access token with repo scope.
Verify Authentication
gh auth statusYou 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 ghIssue: Authentication fails
Solution:
- Check your internet connection
- Try logging out and back in:
gh auth logoutthengh auth login - Verify your GitHub account has access to the
brainforge-aiorganization
Issue: Can’t create PRs
Solution:
- Verify authentication:
gh auth status - Check you have write access to the repository
- Ensure you’re on the correct branch and have pushed your changes
Additional Tools (Optional but Recommended)
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-gitCursor 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 --versionworks -
gh auth statusshows you’re logged in -
gh pr listshows 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:
- Check this guide’s “Common Issues” section
- Review GitHub CLI documentation
- Ask in engineering or ops Slack channels
Last Updated: January 2026
Related: Linear MCP Setup