A Claude Code plugin that prevents WebFetch attempts on GitHub URLs and guides gh api usage toward proper CLI subcommands.
When Claude Code interacts with GitHub:
- WebFetch fails on private repos - GitHub requires authentication, and WebFetch doesn't have access to credentials
gh apibypasses better tools - Usinggh api repos/owner/repo/pulls/123whengh pr view 123exists wastes the rich subcommand features
This plugin intercepts both:
- WebFetch calls to GitHub URLs → blocks with
ghCLI alternatives gh api repos/...calls → suggests properghsubcommands (pr, issue, release, etc.)
- 🚫 Blocks WebFetch on GitHub URLs - Prevents 404 errors on private repos
- 🔄 Guides gh api → subcommands - Redirects
gh api repos/...to propergh pr,gh issue, etc. - ✅ Smart command suggestions - Parses URLs/paths and suggests specific gh CLI commands
- 🔒 Uses authenticated access - Leverages your existing gh CLI authentication
- 🎯 Context-aware help - Different suggestions for PRs, issues, releases, contents, and repos
-
Add the marketplace to Claude Code:
/plugin marketplace add plinde/claude-plugins
-
Install the plugin:
/plugin install github-webfetch-blocker@plinde-plugins
-
The plugin is automatically enabled. Verify with:
/plugin list
For local development or testing:
-
Clone the marketplace repository:
git clone https://github.com/plinde/claude-plugins.git
-
Add as a local marketplace:
cd claude-plugins /plugin marketplace add .
-
Install the plugin:
/plugin install github-webfetch-blocker@plinde-plugins
Once installed and enabled, the plugin automatically intercepts:
- WebFetch calls to GitHub URLs
gh api repos/...calls that have better subcommand alternatives
Before (fails with 404):
⏺ Fetch(https://github.com/mycompany/myrepo/pull/123/)
⎿ Error: Request failed with status code 404
After (blocked with smart suggestions):
⏺ Fetch(https://github.com/mycompany/myrepo/pull/123/)
⎿ ❌ BLOCKED: WebFetch on GitHub URLs
GitHub URLs require authentication and will return 404 errors for private repositories.
✅ Use gh CLI instead with authenticated access:
Suggested commands for this PR:
gh pr view 123 --repo mycompany/myrepo --json title,body,state,author
gh pr diff 123 --repo mycompany/myrepo
gh pr view 123 --repo mycompany/myrepo --comments
Before (works but misses better tooling):
⏺ Bash(gh api repos/mycompany/myrepo/pulls/123)
After (guided to proper subcommand):
⏺ Bash(gh api repos/mycompany/myrepo/pulls/123)
⎿ ⚠️ GUIDANCE: Prefer gh CLI subcommands over gh api
Detected: gh api repos/mycompany/myrepo/pulls/123
✅ Use gh pr subcommand instead:
# View PR details
gh pr view 123 --repo mycompany/myrepo
# Get structured JSON output
gh pr view 123 --repo mycompany/myrepo --json title,body,state,author,comments
# View PR diff
gh pr diff 123 --repo mycompany/myrepo
Why prefer subcommands?
• Better error handling and user-friendly output
• Automatic pagination where applicable
• Structured --json output with --jq filtering
| gh api endpoint | Suggested subcommand |
|---|---|
repos/O/R/pulls/N |
gh pr view N --repo O/R |
repos/O/R/pulls |
gh pr list --repo O/R |
repos/O/R/issues/N |
gh issue view N --repo O/R |
repos/O/R/issues |
gh issue list --repo O/R |
repos/O/R/releases |
gh release list --repo O/R |
repos/O/R/releases/latest |
gh release view --repo O/R |
repos/O/R/contents/... |
Clone repo + Read tool |
repos/O/R/actions/runs |
gh run list --repo O/R |
repos/O/R/actions/workflows |
gh workflow list --repo O/R |
repos/O/R |
gh repo view O/R |
The plugin registers two PreToolUse hooks:
- Intercepts WebFetch tool calls before execution
- Checks if the URL contains
github.com - If yes:
- Parses the URL to identify the type (PR, issue, repo, or generic)
- Extracts owner, repo name, and resource number if applicable
- Generates specific
ghCLI commands tailored to that URL - Blocks with exit code 1 and shows context-aware suggestions
- If no: allows WebFetch to proceed normally
- Intercepts Bash tool calls before execution
- Checks if the command contains
gh api repos/... - If yes:
- Parses the API path to identify the resource type
- Checks if a proper
ghsubcommand exists for that endpoint - If better alternative exists: blocks with suggested subcommand
- If no better alternative: allows
gh apito proceed
- If no: allows Bash command to proceed normally
- Claude Code v0.1.0 or higher
ghCLI installed and authenticated (for the suggested alternatives)jqfor JSON parsing (used by the hook script)
No additional configuration needed. The plugin works out of the box once enabled.
-
Check plugin is installed and enabled:
/plugin list
-
Verify the plugin in settings:
cat ~/.claude/settings.json | jq '.enabledPlugins'
-
Reinstall if needed:
/plugin uninstall github-webfetch-blocker@plinde-plugins /plugin install github-webfetch-blocker@plinde-plugins
Ensure gh CLI is installed and authenticated:
gh auth statusIf not authenticated:
gh auth logingithub-webfetch-blocker/
├── .claude-plugin/
│ └── plugin.json # Plugin metadata
├── README.md # This file
├── LICENSE # MIT License
├── hooks/
│ └── hooks.json # Hook configuration
└── scripts/
├── block-github-webfetch.sh # WebFetch blocker hook
└── suggest-gh-subcommands.sh # gh api → subcommand guidance
Contributions welcome! Please submit issues and pull requests to the repository.
MIT License - see LICENSE file for details
Peter Linde