github-repo-search
Installation
SKILL.md
GitHub Repo Search (No Clone)
Use this skill to locate code in a specific GitHub repo by URL, summarize matches, and deep-read a chosen file via the GitHub API.
Requirements
ghCLI installed and authenticated (gh auth status).- Network access to GitHub.
Inputs to Collect
- Repo URL (e.g.
https://github.com/OWNER/REPO) - Search query (the string or pattern to search)
If any input is missing, ask the user.
Workflow
-
Parse repo
- Extract
OWNERandREPOfrom the URL.
- Extract
-
Search code in the repo
- Run:
gh search code --repo OWNER/REPO "<query>" - Prefer JSON output for structured parsing:
gh search code --repo OWNER/REPO "<query>" --json path,repository,sha,url,textMatches
- Run:
-
Summarize results
- If zero results, report and ask for a refined query.
- If multiple files match, list them with paths and brief snippets (from
textMatchesif present), then ask which file to Deep Read. - If a single file matches, proceed to Deep Read confirmation.
-
Deep Read chosen file
- Use the GitHub API to fetch content without cloning:
gh api repos/OWNER/REPO/contents/<path> - The
contentfield is base64. Decode it:gh api repos/OWNER/REPO/contents/<path> --jq .content | base64 --decode - Fallback for large files (~1 MB limit on contents API):
- Use the
download_urlfrom the contents response:gh api repos/OWNER/REPO/contents/<path> --jq .download_url | xargs curl -L - Or fetch by blob SHA (from
gh search code --json sha):gh api repos/OWNER/REPO/git/blobs/<sha> --jq .content | base64 --decode - Or request raw content directly:
gh api repos/OWNER/REPO/contents/<path> -H "Accept: application/vnd.github.raw"
- Use the
- Use the GitHub API to fetch content without cloning:
-
Present full file
- Show the full content and provide a short summary of the logic relevant to the query.
Usage Example
User request:
Find where rate limiting is implemented for DWS Processor API in https://github.com/PSPDFKit/PSPDFKit
Run:
gh search code --repo PSPDFKit/PSPDFKit "DWS Processor API rate limit" --json path,repository,sha,url,textMatches
If the user chooses a result like <path-from-results>, deep read it:
gh api repos/PSPDFKit/PSPDFKit/contents/<path-from-results> --jq .content | base64 --decode
Notes
- Do not clone the repository unless the user explicitly asks.
- If the file is large, ask whether to show the full file or specific sections.
- Use the default branch unless the user specifies a branch; for a specific ref:
gh api repos/OWNER/REPO/contents/<path>?ref=<branch-or-sha>