Automatically redirects Claude from WebFetch/curl to the authenticated
gh CLI when accessing GitHub resources. Works with private repos and avoids rate limits.Overview
Claude Code’sWebFetch tool and Bash curl/wget commands don’t use GitHub authentication. This plugin solves that by:
- Intercepting GitHub URL access via PreToolUse hooks
- Suggesting the correct
ghCLI command instead - Providing comprehensive
ghCLI guidance via a skill - Auto-cleaning cloned repositories when sessions end
Problems Solved
Private Repos
Unauthenticated fetches fail with 404 errors.
gh uses your token automatically.Rate Limits
Unauthenticated: 60 req/hr. Authenticated: 5,000 req/hr.
Incomplete Data
Some API responses require authentication to return full data.
What Gets Intercepted
| Tool | Pattern | Suggestion |
|---|---|---|
WebFetch | github.com/{owner}/{repo} | gh repo view owner/repo |
WebFetch | github.com/.../blob/... | gh repo clone + Read |
WebFetch | github.com/.../tree/... | gh repo clone + Read/Glob/Grep |
WebFetch | github.com/.../pulls | gh pr list / gh pr view |
WebFetch | github.com/.../issues | gh issue list / gh issue view |
WebFetch | api.github.com/... | gh api <endpoint> |
WebFetch | raw.githubusercontent.com/... | gh repo clone + Read |
Bash | curl https://api.github.com/... | gh api <endpoint> |
Bash | curl https://raw.githubusercontent.com/... | gh repo clone + Read |
Bash | wget https://github.com/... | gh release download |
What Passes Through
- Non-GitHub URLs (any domain that isn’t
github.com,api.github.com,raw.githubusercontent.com, orgist.github.com) - GitHub Pages sites (
*.github.io) - Commands already using
gh - Git commands (
git clone,git push, etc.) - Search commands that mention GitHub URLs (
grep,rg, etc.)
Installation
If
gh is not installed, the hooks silently pass through (no disruption to your workflow).Browsing Repository Code
Key Principle: To read or browse files from a GitHub repo, clone it locally and use normal file tools (Read, Glob, Grep).Clone Pattern
Why clone instead of fetching files via API?
Why clone instead of fetching files via API?
Cloning is:
- Faster for browsing multiple files
- More natural - use Read, Glob, Grep like any local code
- More efficient - one clone vs many API calls
- Session-scoped - auto-cleaned when session ends
Using the Explore Agent
After cloning, use the Explore agent to investigate the repo:Automatic Cleanup
Cloned repositories are stored in session-scoped temp directories:Common Usage Patterns
View Repository
List and View Pull Requests
List and View Issues
API Access
Download Release Assets
Reference Documentation
The skill includes comprehensive reference files:- pull-requests.md - List, view, create, merge, review PRs
- issues.md - List, view, create, close, comment on issues
- repos-and-files.md - View repos, browse files, clone
- api.md - Raw REST/GraphQL access, pagination, jq filtering
- releases.md - List, create, download releases
- actions.md - View runs, trigger workflows, check logs
Usage Examples
- Browse Code
- Fetch API Data
- Download File
Before (fails for private repos):After (uses gh CLI):
Hook Behavior
PreToolUse Hooks
The plugin includes hooks that run before WebFetch and Bash commands:- Fast-fail for non-GitHub URLs - Exit immediately if URL doesn’t match GitHub patterns
- Parse GitHub URLs - Extract owner/repo/endpoint information
- Suggest
ghcommand - Return the equivalentghCLI command - No execution blocking - Claude receives the suggestion and can choose to use it
SessionEnd Hook
Cleans up cloned repositories when the session ends:Benefits
Private Repository Access
Uses your authenticated token automatically - works with all private repos you have access to.
Higher Rate Limits
5,000 requests/hour (authenticated) vs 60 requests/hour (unauthenticated).
Complete API Data
Authenticated requests return full response data, not limited public information.
No Manual Cleanup
Session-scoped temp directories are automatically removed when session ends.
Related Skills
- Devcontainer Setup - GitHub CLI comes pre-installed in devcontainers
- Second Opinion - Uses
gh prcommands for code review workflows - Git Cleanup - Works alongside
ghfor branch management