Can Claude Code search the web?
Yes — there's a built-in WebSearch tool, and it fetches live results with sources. The catch is permission. Run a headless prompt with default settings and it declines, telling you to approve the tool rather than guessing from memory. Pass --allowedTools WebSearch and the same prompt returns an answer with citations in about 20 seconds. In an interactive session you approve it once when asked.
-p mode until approved ✓ Says so honestly — asks for approval instead of answering from memory ✗ Flag order matters — --allowedTools before -p, or it eats your prompt It refused first — and that refusal is the more interesting result.
Run one, default permissions, headless: we asked for the current version number of a fast-moving open-source framework — a fact that is wrong the moment it's memorised. Claude Code declined to answer and asked us to approve a tool first, adding that it couldn't answer reliably from memory since a version number would be outdated by its knowledge cutoff. That is the behaviour you want from a tool with a search capability it can't currently reach: refuse, don't improvise. It took 39 seconds to get there.
Run two, same prompt with --allowedTools WebSearch: it searched, answered, and printed a Sources block with a live URL to the vendor's own release announcement. Elapsed 20.6 seconds.
One CLI gotcha worth writing down, because the error message doesn't explain it. --allowedTools takes a variadic list, so claude -p --allowedTools WebSearch "my prompt" treats the prompt as another tool name and fails with "Input must be provided either through stdin or as a prompt argument". Put the flag first: claude --allowedTools WebSearch -p "my prompt".
Why the gate is there.
Claude Code treats reaching the open web the way it treats running a command or editing a file: an action with consequences, approved rather than assumed. Interactively you're prompted once and can allow it for the session. Headless, there's nobody to ask — so it stops and says what it needs.
The failure mode this avoids is the one that makes AI answers untrustworthy: a confident version number, price or date recalled from training data and presented as current. Refusing is the better behaviour, and it's what we observed.
For automation, name the tool explicitly: claude --allowedTools WebSearch -p "…". Keep the grant narrow — allowing one tool is a different decision from bypassing permission checks wholesale, and the CLI offers both. There is a --dangerously-skip-permissions flag; the name is the documentation.
Watch the argument order, per the gotcha above. The list is variadic and will happily swallow whatever follows it, including your prompt.
Searching and fetching a known URL are separate capabilities, and there's a wrinkle worth knowing if you route the tool through a gateway: per Anthropic's network docs, the fetch tool still calls api.anthropic.com for a domain safety check unless skipWebFetchPreflight is set. Even on Bedrock or your own gateway, that one call goes home.
And none of it works without a connection at all — see can Claude Code work offline, where we measured what happens when the network isn't there.
Other capabilities we measured.
Same approach throughout: run it, record the timing, publish what didn't work as readily as what did.
Frequently asked.
Quick follow-ups people search after this question.
Q · 01 Why did Claude Code refuse to search for me? +
-p run with default permissions there's nobody to ask, so it stops and names what it needs. Pass --allowedTools WebSearch, or approve it once when prompted in an interactive session.Q · 02 How do I allow web search in a script? +
claude --allowedTools WebSearch -p "your prompt". Keep the flag before -p: the list is variadic, so trailing it will swallow your prompt and produce the misleading error Input must be provided either through stdin or as a prompt argument.Q · 03 Does it cite what it found? +
Sources: block containing a live URL to the vendor's own announcement. That's the difference between a searched answer and a remembered one, and it's worth checking the links rather than trusting the summary.Q · 04 Can it browse a specific URL rather than search? +
api.anthropic.com for a domain safety check unless you set skipWebFetchPreflight.