/amplify:fetch-github-filefrom amplify
Fetches source code from GitHub file and directory URLs using the gh CLI. Supports file contents, line ranges, directory listings, and shallow clones.
Ships in amplify. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Fetch source code from GitHub file and directory URLs using the gh CLI for authenticated access.
Verify that gh is available and authenticated before proceeding:
gh auth status
If gh is not installed or not authenticated, tell the user: "This skill requires the GitHub CLI (gh). Install it from https://cli.github.com and run gh auth login."
For GitHub Enterprise (GHE) hosts (e.g. github.mycompany.com), pass --hostname github.mycompany.com to all gh commands.
Parse the GitHub URL to determine what to fetch:
| URL Pattern | Type | Action |
|---|---|---|
github.com/owner/repo/blob/ref/path | File | Fetch file contents |
github.com/owner/repo/blob/ref/path#L10 | File + single line | Fetch file, show line 10 with context |
github.com/owner/repo/blob/ref/path#L10-L25 | File + range | Fetch file, show lines 10-25 |
github.com/owner/repo/tree/ref/path | Directory | List directory contents |
github.com/owner/repo/tree/ref | Repository root | List root directory |
github.com/owner/repo | Repository | List root directory; offer clone for deeper exploration |
raw.githubusercontent.com/owner/repo/ref/path | Raw file | Fetch via curl or gh api |
Extract components from a GitHub URL before fetching:
https://github.com/anthropics/claude-code/blob/main/src/index.ts#L10-L25
^^^^^^^^^^^ ^^^^^^^^^^^^ ^^^^ ^^^^ ^^^^^^^^^^^^^ ^^^^^^^^
owner repo type ref path line range
type: "blob" = file, "tree" = directory
ref: branch name, tag, or full commit SHA
line range: optional; #L10 = single line, #L10-L25 = range
For raw.githubusercontent.com/owner/repo/ref/path, extract owner, repo, ref, and path directly from the path segments.
For bare github.com/owner/repo URLs with no ref, omit the ?ref= parameter entirely from API calls to use the repository's default branch.
# Fetch file content (returns JSON with base64-encoded content)
# Always quote the URL to prevent shell interpretation of ?
gh api 'repos/{owner}/{repo}/contents/{path}?ref={ref}'
Decode the response using the @base64d jq filter, which is portable across all platforms:
gh api 'repos/{owner}/{repo}/contents/{path}?ref={ref}' --jq '.content | @base64d'
For raw.githubusercontent.com URLs, use curl (no auth required for public repos) or the API path above:
curl -fsSL 'https://raw.githubusercontent.com/{owner}/{repo}/{ref}/{path}'
If the URL includes #L10 (single line) or #L10-L25 (range):
For a single-line anchor (#L10), display lines 10 ± 5 for context and highlight line 10.
Example output format:
# src/utils/parser.ts (lines 10-25)
10: export function parseUrl(url: string): ParsedUrl {
11: const match = url.match(GITHUB_PATTERN);
...
gh api 'repos/{owner}/{repo}/contents/{path}?ref={ref}' \
--jq '.[] | "\(.type)\t\(.name)"'
Display as a tree structure showing files and subdirectories. When offering to fetch a specific file from the listing, construct the full path as {parent-path}/{name} so the next API call can be issued without ambiguity.
Clone only when the user explicitly asks for full repo access, or when they need to explore multiple files across the repository. Do not clone when a single file or directory fetch is sufficient.
TEMP_DIR=$(mktemp -d)
gh repo clone {owner}/{repo} "$TEMP_DIR" -- --depth 1 --branch {ref}
echo "Cloned to: $TEMP_DIR"
Use --depth 1 (shallow clone) by default. After cloning, list the root structure and read files as requested. Keep the temp directory path for the remainder of the session.
If --branch {ref} fails because ref is a commit SHA, fetch that specific commit then checkout:
gh repo clone {owner}/{repo} "$TEMP_DIR" -- --depth 1
git -C "$TEMP_DIR" fetch --depth 1 origin {ref}
git -C "$TEMP_DIR" checkout {ref}
Note: git checkout {ref} after a plain --depth 1 clone will fail for arbitrary commit SHAs that are not the shallow tip. The fetch --depth 1 origin {ref} step is required.
gh auth status to confirm authentication. If authenticated and still 403, the repo may be private and the user's token may lack the required scope.download_url from the response (pre-signed for private repos, no extra auth needed):
curl -fsSL '{download_url}'
gh auth login or set the GITHUB_TOKEN environment variable.--hostname {ghe-hostname} to all gh commands.gh auth status — stop and inform the user if gh is missing or unauthenticated.gh api or curl for raw URLs.User pastes: https://github.com/anthropics/claude-code/blob/main/src/index.ts#L1-L50
gh api 'repos/anthropics/claude-code/contents/src/index.ts?ref=main' --jq '.content | @base64d'User pastes: https://github.com/anthropics/claude-code/tree/main/src
gh api 'repos/anthropics/claude-code/contents/src?ref=main' --jq '.[] | "\(.type)\t\(.name)"'src/{name}.User pastes: https://raw.githubusercontent.com/anthropics/claude-code/main/package.json
curl -fsSL 'https://raw.githubusercontent.com/anthropics/claude-code/main/package.json'User pastes: https://github.com/anthropics/claude-code
gh api 'repos/anthropics/claude-code/contents/' (no ?ref= parameter)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Generated from the plugin's indexed repository (wunki/amplify) — no native marketplace selected
npx claudepluginhub p/wunki-amplify28 skills in this plugin
/ask-questions-if-underspecifiedPauses to ask focused clarifying questions when a request lacks enough information to execute correctly. Use when the task is vague, has multiple plausible interpretations, is missing acceptance criteria, or when wrong assumptions would produce significant wasted work. Don't use when the request is already well-specified, when requirements were clarified earlier in the same conversation, when the task is trivially unambiguous (e.g., fix a specific typo), or when general clarification techniques are being discussed rather than applied to a specific task./browse-siteNavigates and interacts with websites using the agent-browser CLI, including clicking elements, filling forms, taking screenshots, extracting page content, and automating multi-step browser workflows. Use when the user asks to open a URL, click something on a page, fill out a web form, take a page screenshot, scrape or extract data from a website, or automate a browser task. Don't use for Playwright, Puppeteer, or Selenium scripts; don't use for browser extension development; don't use for questions about browser APIs, JavaScript, or frontend code that don't require live browser interaction.
/code-simplifierRefines existing code for clarity, readability, and maintainability without changing behavior, interfaces, or outputs. Use when asked to "simplify", "clean up", "refactor for readability", "reduce complexity", or polish code without adding features. Don't use when the request involves changing behavior, adding functionality, migrating to a new pattern or library, renaming public APIs, or any structural change that alters interfaces or outputs.Other plugins' skills for the same job