fetch-firecrawl-fallback
A Claude Code mod that makes the built-in WebFetch tool survive anti-bot walls, invisibly.
When WebFetch hits a 403, a Cloudflare "Just a moment...", a CAPTCHA or any other bot wall, this mod quietly retries the page with the Firecrawl CLI, and if that fails, in a real browser through Claude in Chrome. The agent that called WebFetch gets back an ordinary WebFetch result. It never learns a wall existed, never sees a failed attempt, never spends a turn deciding what to do about it.
Before: WebFetch(url) -> "Request failed with status code 403" -> agent burns turns improvising
After: WebFetch(url) -> "Pro costs £10 a month." -> agent carries on
Why
Agents hit bot walls constantly: documentation behind Cloudflare, pricing pages, news sites, forums. The usual outcome is the agent trying three more search queries, guessing at mirrors, or giving up. Each of those costs tokens and wall-clock time, and the answer is usually one click away in a real browser.
Teaching every agent, skill and prompt "if fetch fails, try Firecrawl, then Chrome" is brittle and expensive. This mod puts the escalation below the agent, where it belongs, so nothing above it needs to know.
What the agent sees
Nothing different. That is the whole design goal.
- Same tool name, same inputs (
url, prompt, offset), same output shape (bytes, code, codeText, result, durationMs, url).
- No extra tool to learn, no extra instructions in the system prompt, no extra tool definitions.
- No intermediate failures, no "I was blocked, trying another way" narration.
- If every fallback fails, the agent gets
WebFetch's original error, unchanged, exactly as it would have without the mod.
Token cost
The fallback adds no tokens to the agent's context. The agent sees one tool call and one result of the same size and kind as a normal WebFetch.
To be precise about where the work happens: WebFetch normally fetches the page and runs your prompt over it with a small model, returning only that short answer. The mod does the same last step. It takes the page text from Firecrawl or Chrome, runs your prompt over it with a small model (haiku by default) in a separate call, and returns only the short answer. That call is billed to your account like WebFetch's own, but it never enters the agent's conversation. The raw page never reaches the main model.
How it works
flowchart TD
A["Agent calls WebFetch(url, prompt)"] --> B["WebFetch runs as normal"]
B --> C{"Is the outcome a bot wall?<br/>403 / 429 / 503 / challenge page"}
C -- "no" --> Z["Result passes through untouched"]
C -- "yes" --> D{"Public URL?"}
D -- "yes" --> E["firecrawl scrape (CLI)"]
D -- "private / local / credentialed" --> G
E --> F{"Real content?"}
F -- "yes" --> M
F -- "no" --> G["Claude in Chrome: throwaway tab,<br/>wait for the challenge to clear"]
G --> H{"Real content?"}
H -- "yes" --> M["Small model applies your prompt<br/>(outside the agent's context)"]
H -- "no" --> Y["Agent gets WebFetch's original answer"]
M --> N["Normal WebFetch result, code 200"]
The mod hooks tool.call for WebFetch, calls next(e) so the real tool always goes first, and only steps in on a wall. A successful fetch costs nothing extra: no extra process, no extra request.
What counts as a wall
- Statuses: 401, 403, 406, 407, 429, 451, 503, 999 (a 404 or a 500 is a real answer, not a wall).
- Errored fetches whose message names one of those statuses or carries challenge text.
- Short "successful" answers that describe a wall: Cloudflare, Akamai, Incapsula, PerimeterX, DataDome and generic CAPTCHA or "checking your browser" interstitials, which often come back as a 200.
- Not a wall:
WebFetch's cross-host REDIRECT DETECTED notice. That is the tool asking the agent a question and is passed through.
The same check runs on what Firecrawl and Chrome return, so a wall that survives one rung is never passed off as an answer.
Requirements
Both are optional. With neither, the mod does nothing and WebFetch behaves exactly as before.
Install
In a Claude Code terminal session:
/plugin install fetch-firecrawl-fallback --marketplace chrisns/claude-mod-fetch-firecrawl-fallback
Answer y to add the marketplace, then choose a scope. The mod is active straight away, with no reload.
To try it from a clone without installing: