GitHub Integration

Complete guide to GitHub CLI integration, automated PR creation, reviewer assignment, and team workflows.

GitHub CLI Setup

Installation

Install GitHub CLI
# macOS
$
brew install gh
# Ubuntu/Debian
$
sudo apt install gh
# Windows
$
winget install GitHub.cli

Authentication

Authenticate with GitHub
$
gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Login with a web browser
✓ Authentication complete.

Verify Setup

Verify GitHub CLI
$
gh auth status
github.com
✓ Logged in to github.com as username (oauth_token)
✓ Git operations for github.com configured to use https protocol.

GitHub Configuration

Basic GitHub Settings

gh.enabled

Enable GitHub CLI integration

boolean
Default: true

gh.interactive_reviewers

Use interactive reviewer selection

boolean
Default: true

gh.draft_by_default

Create draft PRs by default

boolean
Default: false

gh.default_assignee

Default assignee for PRs (self or username)

string
Default: self

PR Automation

gh.labels

Default labels to apply to PRs

array
Default: []

gh.team_reviewers

Default team reviewers (e.g., org/team)

array
Default: []

Pull Request Creation

Basic PR Creation

Create Basic PR
$
lfg --pr
Analyzing changes...
✓ Commit message: 'feat: add user authentication system'
✓ Committed on feature/auth and pushed.
✓ PR created: https://github.com/user/repo/pull/42
🔗 https://github.com/user/repo/pull/42

PR with Reviewers and Labels

PR with Reviewers
$
lfg --pr --review "zephyr-dev,pixel-ninja" --labels "feature,backend" --assign "quantum-ops"
Analyzing changes...
✓ Commit message: 'feat: implement JWT token validation'
✓ Committed on feature/jwt and pushed.
✓ PR created with reviewers: zephyr-dev, pixel-ninja
✓ PR assigned to: quantum-ops
✓ Labels applied: feature, backend
🔗 https://github.com/user/repo/pull/43

Team Reviewers and Draft PR

Team Review Draft PR
$
lfg --pr --team-review "org/backend,org/security" --draft --base develop
Analyzing changes...
✓ Commit message: 'feat: add OAuth2 integration'
✓ Committed on feature/oauth and pushed.
✓ Draft PR created against develop
✓ Team reviewers: org/backend, org/security
🔗 https://github.com/user/repo/pull/44

Interactive Reviewer Selection

When gh.interactive_reviewers is enabled, LFG will prompt you to select reviewers:

Interactive Reviewers
$
lfg --pr
Analyzing changes...
✓ Commit message: 'fix: resolve memory leak in auth service'
✓ Committed on bugfix/memory-leak and pushed.
Select reviewers (use fzf or type names):
zephyr-dev (Senior Developer)
pixel-ninja (Tech Lead)
quantum-ops (DevOps)
Selected: zephyr-dev, pixel-ninja
✓ PR created with selected reviewers

Advanced GitHub Features

PR Size Warnings

LFG automatically detects large PRs and applies warning labels:

Large PR Warning
$
lfg --pr
Analyzing changes...
✓ Commit message: 'feat: major refactor of authentication system'
✓ Committed on feature/auth-refactor and pushed.
⚠️ PR size 1,250 lines exceeds 800
✓ PR created with label: needs-splitting
🔗 https://github.com/user/repo/pull/45

Reviewer Cache Management

LFG caches repository collaborators for faster reviewer selection:

Reviewer Cache
$
lfg --pr --reset-reviewers
Fetching repository collaborators...
✓ Reviewer cache updated
Select reviewers from updated list...

Default Configuration

Set up default reviewers, labels, and assignees in your configuration:

.lfg/config.yml
gh:
  enabled: true
  interactive_reviewers: true
  draft_by_default: false
  default_assignee: "self"  # or specific username
  labels: 
    - "needs-review"
    - "backend"
  team_reviewers:
    - "org/backend-team"
    - "org/security-team"

GitHub Workflow Examples

Feature Development

Standard feature branch with team review

lfg --pr --review 'tech-lead' --team-review 'org/backend' --labels 'feature,needs-testing'

Bug Fix

Quick bug fix with automatic assignment

lfg --pr --assign 'self' --labels 'bugfix,urgent' --base main

Draft for Review

Work-in-progress PR for early feedback

lfg --pr --draft --review 'mentor,senior-dev' --labels 'wip,feedback-needed'

Security Review

Security-sensitive changes requiring special review

lfg --pr --team-review 'org/security' --labels 'security,needs-audit' --draft

Release Preparation

Release branch with comprehensive review

lfg --pr --base main --team-review 'org/leads' --labels 'release,critical' --assign 'release-manager'

Documentation Update

Documentation changes with appropriate reviewers

lfg --pr --review 'tech-writer' --labels 'documentation,low-priority'

GitHub Troubleshooting

Problem: GitHub CLI not authenticated

Solution: Run 'gh auth login' to authenticate. Check 'gh auth status' to verify authentication.

Problem: PR creation failed

Solution: Ensure you have push permissions to the repository and the base branch exists. Check GitHub CLI permissions.

Problem: Reviewer not found

Solution: Verify the username is correct and the user has access to the repository. Use --reset-reviewers to refresh the cache.

Problem: Team reviewer access denied

Solution: Ensure the team exists and you have permission to request reviews from that team. Check team visibility settings.

Problem: Labels not applied

Solution: Verify the labels exist in the repository. Repository admins can create missing labels in GitHub settings.

Problem: Interactive reviewer selection not working

Solution: Install 'fzf' for better interactive selection, or disable with gh.interactive_reviewers: false in config.