Comprehensive Git/GitHub operations for code discovery, PR review, and branch management with configurable domain support.
GitHub CLI: cli.github.com
API Reference: See skills/github-discovery/github-api-docs-links.md
Prerequisites
bash
1# Required tools
2gh # GitHub CLI
3git # Git version control
4jq # JSON processor
5
6# Authentication
7gh auth login
Configuration
Domain is exposed and configurable in config/git-config.sh:
bash
1# Default GitHub (can be changed to GitHub Enterprise)
2export GIT_DOMAIN="github.com"
3export GIT_API_URL="https://api.github.com"
4
5# Set default repository (optional)
6export DEFAULT_OWNER="your-org"
7export DEFAULT_REPO="your-repo"
8export DEFAULT_BRANCH="main"
Use Cases
1. Find Existing Implementations
Search GitHub before coding to avoid reinventing solutions
Extract PR context, analyze changes, suggest fixes, post comments
3. Branch Comparison
Compare branches and review diffs locally
Quick Start Workflows
Workflow 1: Find Implementation Before Coding
bash
1# Search for existing implementations
2bash scripts/find_existing_impl.sh "JWT authentication"
3
4# Search specific code patterns
5bash scripts/gh_search_code.sh "OAuth2 implementation" 15
6
7# Search related repositories
8bash scripts/gh_search_repos.sh "language:python oauth stars:>100"
Workflow 2: PR Review with Analysis
bash
1# Step 1: Extract complete PR context for Claude
2bash scripts/gh_pr_review_suggest.sh 123 owner repo > pr_context.txt
3
4# Step 2: Claude analyzes the context automatically:
5# - Reviews diff for security, logic, performance issues
6# - Checks if comments have been addressed
7# - Suggests specific fixes with code examples
8# - Generates reply suggestions
9
10# Step 3: Post review comment
11bash scripts/gh_pr_reply.sh 123 "Suggested fix for validation..." owner repo
Workflow 3: Branch Comparison
bash
1# Compare two branches (local git)
2bash scripts/git_diff_branch.sh main feature-branch
3
4# Get PR diff (via GitHub)
5bash scripts/gh_pr_diff.sh 123 owner repo
Scripts Reference
Search & Discovery
find_existing_impl.sh
Purpose: Search both code and repositories for existing implementations
Usage:
bash
1bash scripts/find_existing_impl.sh <keyword> [code_limit] [repo_limit]
Example:
bash
1bash scripts/find_existing_impl.sh "JWT authentication" 15 10
gh_search_code.sh
Purpose: Search code across GitHub repositories
Usage:
bash
1bash scripts/gh_search_code.sh <query> [limit]
Examples:
bash
1bash scripts/gh_search_code.sh "OAuth implementation"
2bash scripts/gh_search_code.sh "language:python async def" 30
gh_search_repos.sh
Purpose: Search repositories by name, description, topics
Usage:
bash
1bash scripts/gh_search_repos.sh <query> [limit]
Examples:
bash
1bash scripts/gh_search_repos.sh "spring boot"
2bash scripts/gh_search_repos.sh "language:python stars:>1000" 20
PR Operations
gh_pr_review_suggest.sh
Purpose: Extract complete PR context for Claude to analyze and suggest fixes
Usage:
bash
1bash scripts/gh_pr_review_suggest.sh <pr_number> [owner] [repo]
Output includes:
- PR information (title, author, state)
- All changed files
- Complete diff
- Existing comments
- Review comments on code
- Analysis tasks for Claude
Purpose: Get all comments and reviews from a PR
Usage:
bash
1bash scripts/gh_pr_comments.sh <pr_number> [owner] [repo]
gh_pr_diff.sh
Purpose: Get PR diff
Usage:
bash
1bash scripts/gh_pr_diff.sh <pr_number> [owner] [repo]
gh_pr_files.sh
Purpose: List changed files with additions/deletions
Usage:
bash
1bash scripts/gh_pr_files.sh <pr_number> [owner] [repo]
gh_pr_reply.sh
Purpose: Post a comment to a PR
Usage:
bash
1bash scripts/gh_pr_reply.sh <pr_number> <message> [owner] [repo]
Example:
bash
1bash scripts/gh_pr_reply.sh 123 "Please add unit tests" owner repo
Branch Operations
git_diff_branch.sh
Purpose: Compare two branches (native git, no API)
Usage:
bash
1bash scripts/git_diff_branch.sh <base_branch> <target_branch>
Example:
bash
1bash scripts/git_diff_branch.sh main feature-auth
Integration with Other Skills
Investigation Skill (Subagent Pattern)
Use as a subagent to find existing implementations:
bash
1# Before implementing, search for examples
2bash scripts/find_existing_impl.sh "feature keyword"
3
4# Examine found implementations
5bash scripts/gh_search_code.sh "specific pattern"
Review Skill (PR Review Workflow)
Use for comprehensive PR review:
bash
1# 1. Extract PR context
2bash scripts/gh_pr_review_suggest.sh 123 owner repo > context.txt
3
4# 2. Analyze with Claude (automatic):
5# - Get list of comments
6# - Cross-reference with code changes
7# - Identify issues and suggest fixes
8# - Generate reply suggestions
9
10# 3. Post review
11bash scripts/gh_pr_reply.sh 123 "Reply message" owner repo
API Usage Tip
When updating or adding scripts, always reference GitHub API documentation at skills/github-discovery/github-api-docs-links.md to ensure optimal implementation and use of available endpoints.
Configuration Examples
Set Default Repository
bash
1export DEFAULT_OWNER="myorg"
2export DEFAULT_REPO="myproject"
3
4# Now scripts can be called without owner/repo
5bash scripts/gh_pr_diff.sh 123
Use GitHub Enterprise
bash
1export GIT_DOMAIN="github.company.com"
2export GIT_API_URL="https://github.company.com/api/v3"
3
4# Scripts will now use enterprise domain
5bash scripts/gh_search_code.sh "pattern"
Best Practices
✅ Search before coding: Use find_existing_impl.sh to avoid reinventing
✅ Extract full context: Use gh_pr_review_suggest.sh for comprehensive review
✅ Analyze systematically: Security → Logic → Performance → Style
✅ Be specific in reviews: Reference lines, suggest exact fixes
✅ Configure defaults: Set DEFAULT_OWNER/REPO for faster operations
✅ Domain flexibility: Configure GIT_DOMAIN for enterprise instances
Quick Reference
| Task | Script |
|---|
| Find implementations | find_existing_impl.sh <keyword> |
| Search code | gh_search_code.sh <query> |
| Search repos | gh_search_repos.sh <query> |
| Extract PR context | gh_pr_review_suggest.sh <pr> |
| Get PR comments | gh_pr_comments.sh <pr> |
| Get PR diff | gh_pr_diff.sh <pr> |
| Reply to PR | gh_pr_reply.sh <pr> <message> |
| Compare branches | git_diff_branch.sh <base> <target> |
Configuration: config/git-config.sh
Scripts: scripts/
API Reference: skills/github-discovery/github-api-docs-links.md
Tip: Always set DEFAULT_OWNER and DEFAULT_REPO in config for shorter commands.