๐งTool Prompts/search
Web Search Tool
src/tools/WebSearchTool/prompt.ts
Prompt Engineering Insight
The Web Search tool prompt uses a 'CRITICAL REQUIREMENT' label to enforce mandatory source citation โ a structured output technique ensuring every search-backed response includes attribution. The date injection via [CurrentMonthYear] is a context-injection technique that prevents the model from using stale year references in queries. The few-shot example of the Sources section format makes the expected output structure unambiguous.
Techniques Used
structured-outputbehavioral-constraintsfew-shot-examplescontext-injectionguardrails
prompt
- Allows Claude to search the web and use the results to inform responses
- Provides up-to-date information for current events and recent data
- Returns search result information formatted as search result blocks, including links as markdown hyperlinks
- Use this tool for accessing information beyond Claude's knowledge cutoff
- Searches are performed automatically within a single API call
CRITICAL REQUIREMENT - You MUST follow this:
- After answering the user's question, you MUST include a "Sources:" section at the end of your response
- In the Sources section, list all relevant URLs from the search results as markdown hyperlinks: [Title](URL)
- This is MANDATORY - never skip including sources in your response
- Example format:
[Your answer here]
Sources:
- [Source Title 1](https://example.com/1)
- [Source Title 2](https://example.com/2)
Usage notes:
- Domain filtering is supported to include or block specific websites
- Web search is only available in the US
IMPORTANT - Use the correct year in search queries:
- The current month is [CurrentMonthYear]. You MUST use this year when searching for recent information, documentation, or current events.
- Example: If the user asks for "latest React docs", search for "React documentation" with the current year, NOT last year
Tags
web-searchcitationssourcesreal-timeknowledge-cutoff
Appears in use cases
This prompt is a step in curated flows that show how pieces of Claude Code connect for real tasks.