| name | file-searching |
| description | Regex file search via gh-grep extension. TRIGGERS - search code files, grep repository, file content search. |
File Search with Regex
Capability: Regex-based file content search across GitHub repositories using gh-grep
When to use: Searching repository files (code, docs, configs) - NOT issues
Installation Required: gh extension install k1LoW/gh-grep
Key Distinction
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā SEARCH DECISION ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
ā ā
ā gh search issues ā Search ISSUES/PRs ā
ā (searching-issues skill) ā
ā ā
ā gh grep ā Search FILES (code, docs) ā
ā (THIS skill) ā
ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Quick Commands
Basic File Search
gh grep "authentication" --owner myorg --repo myrepo
gh grep "Bug.*critical" --owner myorg --repo myrepo
gh grep "API_KEY" --owner myorg --repo myrepo --include "*.env*"
gh grep -i "password" --owner myorg --repo myrepo
Common Patterns
gh grep "function.*login" --owner myorg --repo myrepo
gh grep "TODO:" --owner myorg --repo myrepo --include "*.js,*.ts"
gh grep "process\.env\." --owner myorg --repo myrepo
gh grep "^import.*axios" --owner myorg --repo myrepo
Flags & Options
Output Control
gh grep "error" --owner myorg --repo myrepo --line-number
gh grep "config" --owner myorg --repo myrepo --files-with-matches
gh grep "api" --owner myorg --repo myrepo --max-count 10
File Filtering
gh grep "test" --owner myorg --repo myrepo --include "*.test.js"
gh grep "console" --owner myorg --repo myrepo --exclude "node_modules/*"
gh grep "interface" --owner myorg --repo myrepo --include "*.ts,*.tsx"
Search Scope
gh grep "feature" --owner myorg --repo myrepo --branch develop
for repo in repo1 repo2 repo3; do
gh grep "authentication" --owner myorg --repo $repo
done
Regex Patterns
Common Regex
gh grep "\bpassword\b" --owner myorg --repo myrepo
gh grep "^export" --owner myorg --repo myrepo
gh grep ";$" --owner myorg --repo myrepo --include "*.js"
gh grep "colou?r" --owner myorg --repo myrepo
gh grep "[0-9]{3}-[0-9]{4}" --owner myorg --repo myrepo
Advanced Patterns
gh grep "function \w+\(.*\)" --owner myorg --repo myrepo
gh grep "error.*handler" --owner myorg --repo myrepo
gh grep "import" --owner myorg --repo myrepo | grep -v "node_modules"
Common Workflows
1. Security Audit
gh grep "api_key.*=.*['\"]" --owner myorg --repo myrepo --include "*.js,*.ts,*.py"
gh grep -i "password\s*=\s*['\"][^'\"]+['\"]" --owner myorg --repo myrepo
gh grep "AWS_SECRET" --owner myorg --repo myrepo
2. Code Quality Check
gh grep -i "TODO|FIXME" --owner myorg --repo myrepo
gh grep "console\.log" --owner myorg --repo myrepo --include "*.js,*.ts"
gh grep "deprecated" --owner myorg --repo myrepo --include "*.md"
3. Dependency Analysis
gh grep "import.*lodash" --owner myorg --repo myrepo
gh grep "axios\.|fetch\(" --owner myorg --repo myrepo
gh grep "SELECT.*FROM" --owner myorg --repo myrepo
4. Documentation Search
gh grep "\[.*\]\(.*\)" --owner myorg --repo myrepo --include "*.md"
gh grep "^```" --owner myorg --repo myrepo --include "*.md"
gh grep "^#{1,3} " --owner myorg --repo myrepo --include "*.md"
Multi-Repository Search
#!/bin/bash
PATTERN="authentication"
OWNER="myorg"
REPOS=("repo1" "repo2" "repo3")
for repo in "${REPOS[@]}"; do
echo "=== Searching $repo ==="
gh grep "$PATTERN" --owner "$OWNER" --repo "$repo" --line-number
echo ""
done
Performance Considerations
Speed:
- gh-grep searches via GitHub API (network latency)
- Faster than cloning repos for quick searches
- Slower than local grep for large codebases
Rate Limits:
- GitHub API rate limits apply
- Authenticated requests: 5,000/hour
- Consider caching results for repeated searches
Best Practices:
- Specific patterns - Narrower regex = fewer results = faster
- File filters - Use
--include to reduce search scope
- Limit results - Use
--max-count for quick verification
- Batch searches - Search multiple patterns in one pass
Comparison: gh grep vs gh search issues
| Feature | gh grep | gh search issues |
|---|
| Searches | Repository files | Issues/PRs |
| Regex | ā
Full regex support | ā No regex |
| Wildcards | ā
Yes | ā No |
| Context | ā
Line-based | ā No context |
| File types | ā
Filter by extension | N/A |
| Installation | Extension required | Native |
| Use case | Code/docs search | Issue/PR search |
Limitations
- No local search - Always queries GitHub API
- Branch-specific - Searches one branch at a time
- No multiline - Pattern must match within single line
- Rate limits - API quota applies
- No content display - Shows matches, not full file content
Tool Selection
- Search repository FILES ā Use
gh grep (this skill)
- Search Issues/PRs ā Use
gh search issues (searching-issues skill)
- AI-powered operations ā Use
gh models (ai-assisted-operations skill)
Installation: gh extension install k1LoW/gh-grep
Maintenance Status: Actively maintained (211 stars, updated daily)
Full Extension Guide: GITHUB_CLI_EXTENSIONS.md