ketch
A stateless CLI for web search, code search, library docs, and scraping — one binary, no daemon, no API server to run.
Why ketch
Most research tooling for agents means wiring up several provider SDKs, each with its own auth and response shape. ketch collapses that into one binary with three research surfaces:
ketch search— web search, no API key required (Brave, DuckDuckGo, SearXNG, Exa, Firecrawl, Keenable, Tavily, Parallel, SerpBase, Serply, or You.com)ketch code— grep real OSS source across public repos (Grep, Sourcegraph, or GitHub Code Search)ketch docs— curated, version-aware library documentation (Context7)
Plus ketch scrape and ketch crawl to turn HTML pages and text-based PDFs into clean markdown.
It's built for two audiences at once:
- Humans, who want a fast terminal tool for the same job
curl | pandocor a browser tab would otherwise do. - AI agents, who want structured, predictable output (
--jsoneverywhere), documented exit codes for control flow, and a singleketch configcall to discover what backends are active — no environment probing, no per-provider glue code.
An operator configures the backend once (ketch config set backend searxng); every agent invocation afterward just calls ketch search or ketch scrape without knowing or caring which provider is behind it.
Install
# Homebrew
brew install ketch
# go install
go install github.com/1broseidon/ketch@latest
# Or download a prebuilt binary (linux/darwin/windows, amd64/arm64)
# from https://github.com/1broseidon/ketch/releases
Quickstart
$ ketch scrape https://go.dev/doc/effective_go
---
url: https://go.dev/doc/effective_go
title: Effective Go - The Go Programming Language
words: 16582
---
1. [Documentation](https://go.dev/doc/)
2. [Effective Go](https://go.dev/doc/effective_go)
...
## Introduction
Go is an open-source programming language that focuses on simplicity, reliability, and efficiency...
Search real OSS code with zero configuration:
$ ketch code "http.NewRequestWithContext" --lang go --limit 2
---
query: http.NewRequestWithContext
lang: go
backend: grepapp
result_count: 2
---
harness/harness registry/app/remote/clients/registry/client.go (line 207)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, buildPingURL(c.url), nil)
https://github.com/harness/harness/blob/main/registry/app/remote/clients/registry/client.go
...
Web search works with zero configuration too — the default backend (auto)
falls back through the keyless providers, so there is no key to set first:
ketch search "golang error handling"
ketch search "golang error handling" --scrape # fetch + extract full content per result
ketch search "golang error handling" --multi # federate across every usable backend, rank-fused
ketch search "golang error handling" --random # pick one random backend, fallback to rest on failure
auto tries providers in a fixed order and returns the first that answers,
reporting which one served in the backend: field. It prefers whatever you
have actually configured — your own SearXNG or Degoog instance first, then any
provider you have set a key for — and only then the keyless hosted providers.
So setting a key is still how you get a specific provider and higher limits,
and you do not have to also set backend for it to take effect:
ketch config set brave_api_key <key> # auto now prefers Brave
ketch search "golang error handling" -b ddg # or pick a provider explicitly
--multi queries several backends at once and fuses their rankings with
Reciprocal Rank Fusion (a page several engines rank highly floats to the top),
deduplicating by URL and tagging each result with the engines that returned it.
--random shuffles the backend list, tries one, and falls back to the rest —
ideal when you want one provider's results without wasting rate limits on all
of them. Both support bare (all usable backends) or =brave,exa explicit lists, and both
are mutually exclusive with --backend and each other.
See site/reference/commands.md.
Every command takes --json for structured output:
ketch scrape https://example.com --json
# {"url":"https://example.com","title":"Example Domain","markdown":"..."}
Pipe any HTML through ketch's readability + markdown pipeline without a fetch:
curl -L https://chain.sh/ketch | ketch extract
cat page.html | ketch extract --select article --max-chars 4000
PDF extraction
ketch scrape detects PDFs from the response MIME type or %PDF- signature and extracts their text with a built-in pure-Go parser:
ketch scrape https://example.com/report.pdf
Scanned/image-only PDFs need OCR and return a precondition error with an OCR-converter hint in the built-in path. Operators can configure an external PDF-to-Markdown converter that writes Markdown to stdout (capped at 10 MiB); its shlex-parsed command must contain exactly one {input} placeholder:
ketch config set external_pdf_to_md_converter_command 'pdftotext "{input}" -'
ketch config set external_pdf_to_md_converter_timeout_sec 300
When configured, the external converter is authoritative: failures are returned rather than silently falling back to the built-in parser. PDF binary output is never emitted: --raw and --select reject PDFs as validation errors. With --force-browser, PDF markdown still uses text extraction and never opens Chromium's PDF viewer.
Commands
| Command | What it does |
|---|---|
search |
Web search — Brave, DuckDuckGo, SearXNG, Exa, Firecrawl, Keenable, Tavily, Parallel, SerpBase, Serply, or You.com |
code |
Grep real OSS source — Grep (default), Sourcegraph, or GitHub Code Search |
docs |
Library/framework docs — Context7 (curated, version-aware snippets) |
scrape |
Fetch HTML or PDF URL(s) and extract clean markdown; concurrent batch, JSON array, file, or stdin input |
extract |
Convert piped HTML to clean markdown (curl ... | ketch extract) — no fetch, no cache, no browser |
crawl |
BFS or sitemap crawl with optional background execution and status tracking |
browser |
Manage headless Chrome for JS-rendered pages (install, status) |
config |
Show effective config as JSON, or init / set / path |
cache |
Show page-cache stats, or clear |
doctor |
Live health check of every backend, the browser, and the cache — exit 0 healthy, 5 when a configured surface is broken |
mcp |
Run ketch as an MCP server over stdio (mcp serve) — the five research surfaces as tools |
version |
Print version, commit, build date |
Every command supports -h/--help for its full flag list; --json is the only flag global to every command. Full flag reference lives at 1broseidon.github.io/ketch.
Backends
| Surface | Default | Also available | Setup |
|---|---|---|---|
search |
auto |
brave, ddg, searxng, exa, firecrawl, keenable, tavily, parallel, serpbase, degoog, serply, youcom |
Nothing — auto falls back through the keyless providers (parallel → exa → keenable → youcom → firecrawl → ddg) and needs no key. Brave, Tavily, SerpBase, and Serply need a free key (ketch config set brave_api_key / tavily_api_key / serpbase_api_key / serply_api_key) and auto prefers them once set; firecrawl_api_key, exa_api_key, keenable_api_key, and youcom_api_key are optional and lift the hosted caps. degoog needs a self-hosted instance (ketch config set degoog_url ), searxng an instance URL (ketch config set searxng_url ); both are preferred over hosted APIs once configured |
code |
grepapp |
sourcegraph, github |
Grep and Sourcegraph need nothing; GitHub uses gh auth login, $GITHUB_TOKEN, or ketch config set github_token |
docs |
context7 |
local (planned, not yet implemented) |
Free key: ketch config set context7_api_key |
Why it works well for agents
- Stateless, single binary. No daemon, no server to keep alive — call, get a result, exit.
- Documented exit codes, not just stderr text, for scripted control flow:
2bad input,3not found,4upstream/network failure,5missing precondition (e.g. no API key),6cancelled (SIGINT/SIGTERM). - Automatic JS-rendering fallback.
ketch scrapeandketch crawldetect JS-shell pages (React/Vue/Svelte SPAs, streaming hydration frameworks) and transparently re-fetch via headless Chrome when need