Notes for AI coding agents (and people) working on refetch. Read CONTRIBUTING.md for the full workflow.
refetch is a Go 1.27 module, github.com/samgozman/refetch: one binary that
is the fetch_page MCP server, the Claude Code hook handler, the manual
fetcher and the stats report. The repo root is also the Claude Code plugin.
make build:build/refetch(VERSION=x.y.zsets the version string)make test: race-enabled unit tests, no network neededmake cover-check: tests with coverage; fails below 85% (CI runs this)make lint:go mod tidy -diffand golangci-lint with the maxcomments plugin (build/custom-gcl, built from.custom-gcl.ymlbymake lint-build; needs golangci-lint v2.15.0 on PATH)make notices: regenerateTHIRD_PARTY_NOTICESafter any dependency changeclaude plugin validate . --strict: check the plugin manifestsREFETCH_DATA=/tmp/r REFETCH_CONFIG=/dev/null build/refetch get <url>: try a fetch without touching your real data
fetch/: public package; the clients, the public-only dialer, challenge and JavaScript-only detection, HTML to Markdown (Markdown, whatfetch_pagereturns) and to plain text (Text, which the detection measures), PDF and office files to Markdown (Document), Google export addresses (Rewrite)render/: the headless Chrome step: Chrome discovery, the local proxy on the public-only dialer, the DevTools protocol over--remote-debugging-pipeunderrender_timeoutsite/: a site's own public API in place of its page: Stack Exchange questions, Discourse topics (/raw), long GitHub issues, Bluesky and Mastodon posts, YouTube video data, Medium posts from RSS feeds, Bloomberg story datacmd/refetch/archive.go: the Wayback Machine step after a failed read (archivesetting); it sends the URL to archive.orgstore/: SQLite event log (tool_calls,attempts,dailyroll-up)stats/: the funnel and its text reportconfig/: defaults,config.toml,REFETCH_*env varscmd/refetch/: subcommands (mcp,hook,get,stats,doctor, and the hiddenread-pdfchild thatfetch.IsolatePDFruns).claude-plugin/,hooks/hooks.json,skills/: the pluginbin/refetch: the plugin's shell shim, not a build output. Builds go tobuild/.e2e/: the compatibility run against a local test site (-tags e2e)scripts/: notices and the release job's plugin-version script
- Every connection goes through the public-only dialer
(
fetch.DialContext); never add a client that bypasses it. Headless Chrome reaches the network only throughrender's proxy on that dialer. An upstream proxy (use_proxy,fetch.UseProxy) is a CONNECT tunnel inside that dialer; never setProxyon a transport. - Hooks and the MCP server must never break a session: report failures as tool errors, or exit 0 with empty output. Hooks finish in well under 50 ms.
- refetch never denies or rewrites a tool call, and never writes to Claude Code's settings.
- Write modern Go:
errors.AsType,encoding/json/v2,t.Context(),slices/maps. - Tests use fake getters or loopback servers, never the live network.
- Comments explain why, not what; maxcomments caps comment lines per function and per file.
- Conventional commits (
feat:,fix:,docs:,test:,ci:,chore:). release-please builds the release notes and the version from them. - Don't put a
CLAUDE.mdat the repo root: the root is the plugin, and the plugin validator flags it. Claude Code reads this file through.claude/CLAUDE.md. - On
main,versionin.claude-plugin/plugin.jsonstays0.0.0and the sha256 table inbin/refetchstays empty (a test checks it). The release job writes both on thereleasebranch, which the marketplace installs from. - Text that comes from a site or another tool and reaches Claude outside the
page fence goes through
oneLine.