explaingit

agents365-ai/cloakfetch

24PythonAudience · developerComplexity · 3/5ActiveLicenseSetup · moderate

TLDR

A Claude Code hook plus skill that retries blocked WebFetch requests through CloakBrowser, then returns clean Markdown via trafilatura when Cloudflare returns 403.

Mindmap

mindmap
  root((cloakFetch))
    Inputs
      WebFetch URL
      403 response
      Claude Code hook events
    Outputs
      Clean Markdown
      Fallback context
      Hook logs
    Use Cases
      Read Cloudflare protected pages
      Auto retry failed fetches
      Skill based fallback
      Codex and OpenCode integration
    Tech Stack
      Python
      CloakBrowser
      trafilatura
      Bash

Things people build with this

USE CASE 1

Make Claude Code WebFetch succeed on Cloudflare protected docs and blogs

USE CASE 2

Wire the SKILL.md flow into Codex or OpenCode for the same fallback

USE CASE 3

Add a custom domain allowlist before invoking CloakBrowser to control egress

USE CASE 4

Log every 403 retry as a hook event for later debugging

Tech stack

PythonCloakBrowsertrafilaturaBash

Getting it running

Difficulty · moderate Time to first run · 30min

You must install CloakBrowser, point an env var at the right Python interpreter, and paste a JSON snippet into Claude Code settings before the hook fires.

MIT license, so you can use, modify, and ship it commercially as long as you keep the copyright notice.

In plain English

cloakFetch is a small helper that fixes a specific annoyance for people using Claude Code, the command-line coding assistant from Anthropic. When Claude Code is asked to read a web page, it uses a built-in tool called WebFetch. Many websites sit behind Cloudflare or similar bot protection, and when a normal request hits one of those pages, the response that comes back is just an HTTP 403 Forbidden error. Claude then has nothing to read. The project routes those blocked requests through a different program called CloakBrowser, which is a real Chromium browser with patches at the C++ level that let it pass Cloudflare's JavaScript challenge. Once the page actually loads, the rendered HTML is handed to a Python library called trafilatura, which strips away the menus and ads and returns a clean Markdown version of the article. The Claude agent receives that Markdown and never has to know that the original fetch failed. cloakFetch offers two ways to switch this behavior on. The first is a PostToolUse hook for Claude Code. Claude Code's hook system lets you run a script after every tool call, so the bundled shell script watches WebFetch results, spots the 403 pattern, pulls the URL out of the payload, runs CloakBrowser on it, and feeds the rendered text back as additional context. This path is invisible to the agent and triggers automatically. The second path is a SKILL.md skill that works with agents like Codex, OpenCode, OpenClaw, and SkillsMP. In that mode the agent itself decides to invoke the skill after seeing a failed fetch. The same Python script does the actual browser work in both modes. The repository is organized into a hooks folder for the Claude Code path, a skills folder for the SKILL.md path, and a settings snippet that you paste into your Claude Code configuration. Installation involves copying or symlinking two files into a hooks directory, pointing an environment variable at a Python interpreter that has CloakBrowser installed, and adding a small block of JSON to settings.json. The README notes that successful fallbacks take around 25 to 40 seconds, while misses cost only milliseconds because the regex check skips the browser entirely.

Copy-paste prompts

Prompt 1
Walk me through the PostToolUse hook script in cloakFetch and how it detects a 403 in WebFetch payloads
Prompt 2
Show the exact settings.json block I need to paste into Claude Code to enable cloakFetch hooks
Prompt 3
Modify the cloakFetch fallback to also catch HTTP 429 responses, not just 403
Prompt 4
Explain how trafilatura is used inside cloakFetch to clean up the rendered HTML before passing it back
Prompt 5
Write a SKILL.md variant of cloakFetch that an OpenCode agent can invoke on demand
Open on GitHub → Explain another repo

Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.