Guides using Claude API web search and web fetch tools for live web access, including version selection, domain filtering, citations, error handling, and cost management.
Ships in messages-api-features. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Web search finds pages and returns cited results; web fetch reads the full text of a URL or PDF that already appeared in the conversation. Both are server tools: Anthropic runs them during the request and you never return a tool result for them.
| Need | Tool |
|---|---|
| Current events, prices, recently changed facts | Web search |
| Answers that must cite sources | Web search (citations always on) or web fetch with citations enabled |
| Summarize or extract from a specific URL or PDF | Web fetch |
| "Read the README of project X" without a URL | Both: search locates it, fetch reads it |
Both tools have dated versions. As documented at the time of writing:
| Tool | Versions | Difference |
|---|---|---|
| Web search | web_search_20250305, web_search_20260209, web_search_20260318 | Basic; adds dynamic filtering; adds response_inclusion |
| Web fetch | web_fetch_20250910, web_fetch_20260209, web_fetch_20260309, web_fetch_20260318 | Basic; dynamic filtering; cache bypass (use_cache); response_inclusion |
Dynamic filtering lets Claude write code that filters results before they enter context. It runs on code execution that the API provisions automatically, so do not add the code execution tool yourself. Not every model or cloud platform supports the newer versions (some platforms offer only the basic ones); check the tool pages, or read capabilities.server_tools.web_search.supported from the Models API.
An organization admin can disable either tool in the Claude Console; requests then fail with a 400.
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
const MODEL = process.env.ANTHROPIC_MODEL!; // a current model ID
const response = await client.messages.create({
model: MODEL,
max_tokens: 16000,
tools: [
{ type: "web_search_20250305", name: "web_search", max_uses: 3 },
{ type: "web_fetch_20250910", name: "web_fetch", max_uses: 5, citations: { enabled: true }, max_content_tokens: 50000 },
],
messages: [{ role: "user", content: "Find the current release notes for project X and summarize breaking changes." }],
});
Parameters worth setting:
| Parameter | Tool | Purpose |
|---|---|---|
max_uses | Both | Hard cap per request; exceeding it returns a max_uses_exceeded error result |
allowed_domains or blocked_domains | Both | Domain filtering; never both in one tool (400) |
user_location | Search | Localize results (type: "approximate" plus city/region/country/timezone) |
citations | Fetch | Off by default for fetch; always on for search |
max_content_tokens | Fetch | Truncates large text content to control cost |
Search results arrive as web_search_tool_result blocks whose content is a list of web_search_result items; fetch results arrive as web_fetch_tool_result with a web_fetch_result document. Errors do not raise: the API returns 200 and the result block's content is a single error object.
for (const block of response.content) {
if (block.type === "web_search_tool_result") {
if (Array.isArray(block.content)) {
for (const r of block.content) console.log(r.title, r.url);
} else {
console.warn("search error:", block.content.error_code); // e.g. max_uses_exceeded, too_many_requests
}
}
}
Web fetch error codes include url_not_in_prior_context, url_not_allowed, url_not_accessible, unsupported_content_type, and content_too_large. A search that succeeds with no matches returns an empty list, not an error.
encrypted_content (and citations carry encrypted_index) that the API needs on later turns; modified or missing values cause a 400stop_reason: "pause_turn". Send the paused assistant message back unchanged to continuetool_use; return your client results and the server tool runs on the next requestWeb fetch can only fetch URLs that already appeared in user messages, client tool results, or earlier search/fetch results, never URLs that appear only in Claude's own output or only in the system prompt. It also refuses URLs that look like they contain credentials. Residual risk remains when untrusted content and sensitive data share a conversation, so:
allowed_domains for fetch wherever the set of sites is knownmax_usesurl_sources to stop specific client tool results from counting as URL sourcesThe docs require citations to the original source when you show API output directly to end users, and advise consulting legal counsel if you rework the output. Render cited_text, title, and url next to the claims they support.
Web search is billed per search plus tokens for the results that enter context (results count as input tokens on later turns too). Web fetch has no per-call charge beyond the tokens for fetched content, which can be large for long pages and PDFs. Check current rates on the tool and pricing pages, set max_uses, and set max_content_tokens on fetch.
encrypted_content or rebuilding assistant messages from text onlymax_uses on user-facing routespause_turnusage.server_tool_use to track search and fetch countsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
web-search, web-fetch, claude-api, citations, domain-filtering
Other plugins' skills for the same job
/messages-api-features:web-search-and-fetchfrom messages-api-features
npx claudepluginhub latestaiagents/agent-skills --plugin messages-api-features7 skills in this plugin
/code-executionUse the Claude API code execution tool so the model runs Bash and Python in an Anthropic-hosted sandbox during a response — for calculation, data analysis, file generation, and checking its own work. Covers tool versions, file upload, retrieving generated files, container reuse, limits, and data-retention constraints.
Use this skill when building features where Claude must actually run code (not just write it), when choosing a code execution tool version, or when debugging missing output files or expired containers.
Activate when: Claude code execution, code_execution tool, Python sandbox, run code tool, data analysis agent, code interpreter, container_upload, container reuse, OUTPUT_DIR.
/computer-useBuild desktop and browser automation agents with the Claude API computer use toolset — screenshots, clicks, typing, scrolling — run by your own harness inside an isolated VM or container. Covers choosing the toolset version, the agent loop, batch actions, sandboxing, prompt-injection risk, and when an API integration is the better choice.
Use this skill when building agents that operate GUIs (legacy apps, browsers without APIs), migrating from an older computer use tool version, or reviewing the safety of a computer use deployment.
Activate when: Claude computer use, computer_toolset, computer_20251124, computer_20250124, desktop agent, screen control, click and type agent, GUI automation.
/long-contextWork with large Claude context windows deliberately — check the window for your model, count tokens before sending, structure long inputs for recall, cache the stable part, and manage growing conversations with compaction, context editing, or memory instead of stuffing everything in.
Use this skill when feeding large codebases, document sets, or long agent histories to Claude, when weighing long context against retrieval, or when a conversation is approaching the context limit.
Activate when: long context, context window, 1M context, context limit, prompt is too long, context rot, compaction, context editing, long context vs RAG, token counting.
/memory-toolGive Claude agents persistent memory across conversations with the Claude API memory tool — a client-side file store under /memories that Claude reads and writes through commands your application executes. Covers setup, the six commands, SDK helpers, path-traversal protection, and pairing memory with compaction or context editing.
Use this skill when an agent must remember preferences, project state, or decisions between sessions, when implementing a memory handler, or when reviewing a memory implementation for security.
Activate when: Claude memory tool, memory_20250818, agent memory, persistent memory, /memories directory, cross-session state, long-term memory agent, BetaLocalFilesystemMemoryTool.
/prompt-cachingUse Claude API prompt caching to reuse processed prompt prefixes across requests — automatic vs explicit breakpoints, 5-minute and 1-hour TTLs, minimum cacheable lengths, what invalidates the cache, and how to measure hit rate from usage fields.
Use this skill when building apps with large repeated context (system prompts, tool definitions, documents, long conversations), reducing API spend, or debugging cache reads that stay at zero.
Activate when: prompt caching, cache_control, cache hit rate, cache_read_input_tokens, 1 hour cache, ttl 1h, ephemeral cache, cache breakpoint, cache invalidation.
/thinking-and-effortConfigure Claude's thinking and the effort parameter correctly — adaptive vs legacy budget-based thinking, the display setting, effort levels, thinking with tool use, cost control with max_tokens, and how thinking settings interact with prompt caching. Model behavior differs, so the skill shows how to check per-model rules instead of assuming them.
Use this skill when enabling or tuning reasoning, migrating code that uses budget_tokens, debugging 400 errors on thinking parameters, empty thinking blocks, or truncated answers, or trading quality against latency and cost.
Activate when: extended thinking, adaptive thinking, budget_tokens, effort parameter, output_config effort, thinking blocks, thinking display, interleaved thinking, reasoning tokens, thinking_tokens.
2 plugins in one repository ship this exact skill · first indexed Nov 5, 2026