Guide for searching and exploring external GitHub repositories using the gh CLI. Use this when you need reference implementations, patterns, or code examples from open-source projects to help complete your task.
Guide for searching and exploring external GitHub repositories using the gh CLI. Use this when you need reference implementations, patterns, or code examples from open-source projects to help complete your task.
GitHub Repository Search and Exploration
This skill enables agents to discover, clone, and explore external GitHub repositories when implementing features that may benefit from reference implementations in open-source projects.
When to Use This Skill
Use this skill when you need to:
Find reference implementations for features you're building
Explore how other projects implement similar patterns
Search for code examples across GitHub
Clone external repos for local exploration and learning
Find libraries or tools that could inform your implementation
Do NOT use this skill when:
The task is straightforward and doesn't need external references
The codebase already has established patterns to follow
You're working on proprietary code that shouldn't reference external sources
Resource Directory
All external GitHub repositories MUST be stored in:
.agent_cache/resources/
This is the centralized location for all cloned external repositories. Always check here first before searching GitHub.
Repositories are organized by {owner}/{repo} structure to prevent naming conflicts.
Workflow Overview
┌─────────────────────────────────────────────────────────────────┐
│ 1. Check Local Cache (.agent_cache/resources/) │
│ └─ If found → Use local repo for exploration │
└────────────────────────────┬────────────────────────────────────┘
│ Not found
▼
┌─────────────────────────────────────────────────────────────────┐
│ 2. Authenticate with GitHub (if needed) │
│ └─ gh auth login │
└────────────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ 3. Search GitHub for Repositories │
│ └─ gh search repos <query> │
│ └─ gh search code <query> │
└────────────────────────────┬────────────────────────────────────┘
│ Found match
▼
┌───────────────────────────────────────────────────────────────────┐
│ 4. Clone to Cache Directory │
│ └─ gh repo clone owner/repo .agent_cache/resources/owner/repo │
└────────────────────────────┬──────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ 5. Explore Repository │
│ └─ Use gh commands and file reading tools │
└─────────────────────────────────────────────────────────────────┘
Phase 1: Check Local Cache First
Before searching GitHub, always check if a relevant repository is already cloned locally.
List Cached Repositories
# List all cached repositoriesls -la .agent_cache/resources/
# List repos by ownerls -la .agent_cache/resources/microsoft/
# Search for specific repo by name
find .agent_cache/resources -type d -name "*semantic*" 2>/dev/null
Explore Local Repository
If the repository exists locally, use standard file tools:
# View repository structure
tree -L 2 .agent_cache/resources/microsoft/semantic-kernel/
# Search for patterns in local repo
grep -r "planning" .agent_cache/resources/microsoft/semantic-kernel/python/ --include="*.py" | head -20
# Find specific files
find .agent_cache/resources/microsoft/semantic-kernel -name "*.md" -path "*skills*"
Phase 2: GitHub Authentication
If you need to search or clone from GitHub, ensure authentication is set up.
Check Authentication Status
gh auth status
Interactive Login (if needed)
# Interactive login - user will authenticate via browser
gh auth login
This opens a browser for the user to authenticate with their GitHub account.
Verify Login
# Verify authentication worked
gh auth status
Phase 3: Search GitHub
Use gh search commands to find relevant repositories or code.
Search for Repositories
# Search repos by keywords
gh search repos "agent planning skills" --limit 10
# Search with language filter
gh search repos "agent planning" --language python --limit 10
# Search by owner
gh search repos --owner microsoft "semantic kernel" --limit 10
# Search with JSON output for parsing
gh search repos "agent planning" --json fullName,description,stargazersCount --limit 5
# Sort by stars (most popular)
gh search repos "agent planning" --sort stars --limit 10
# Filter by number of stars
gh search repos "agent framework" --stars ">1000" --limit 10
Search for Code
# Search code across GitHub
gh search code "TaskLedger" --limit 10
# Search code in specific language
gh search code "def plan" --language python --limit 10
# Search code in specific repo
gh search code "planning" --repo microsoft/semantic-kernel --limit 20
# Search code by filename
gh search code "skills" --filename "*.md" --limit 10
# Search with JSON output
gh search code "agent skills" --json path,repository --limit 10
View Repository Details
# View repo README and description
gh repo view microsoft/semantic-kernel
# View repo with specific fields as JSON
gh repo view microsoft/semantic-kernel --json name,description,stargazerCount,defaultBranchRef
# Open repo in browser
gh repo view microsoft/semantic-kernel --web
Phase 4: Clone Repository to Cache
When you find a useful repository, clone it to the cache directory.
Clone Commands
# Create cache directory structuremkdir -p .agent_cache/resources/{owner}
# Clone repository
gh repo clone microsoft/semantic-kernel .agent_cache/resources/microsoft/semantic-kernel
# Clone with shallow history (faster, uses less disk)
gh repo clone microsoft/semantic-kernel .agent_cache/resources/microsoft/semantic-kernel -- --depth 1
# Clone specific branch
gh repo clone microsoft/semantic-kernel .agent_cache/resources/microsoft/semantic-kernel -- --branch main --depth 1