Claude-skill-registry google-search
Integration patterns for web search grounding, including query operator usage, API-based search orchestration, and citation metadata mapping. Triggers: google-search, grounding, search-api, citations, search-operators, web-search.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/google-search" ~/.claude/skills/majiayu000-claude-skill-registry-google-search && rm -rf "$T"
manifest:
skills/data/google-search/SKILL.mdsource content
Google Search Grounding
Overview
Google Search grounding allows LLM applications to access real-time information and provide verifiable citations. This skill covers both direct tool integration (like Gemini's
google_search) and custom API implementations.
When to Use
- Fact-Checking: When the LLM needs to confirm recent events (e.g., Euro 2024 results).
- Source Attribution: When user trust requires seeing direct links to the information source.
- Niche Research: Using operators like
to restrict information to specific domains.site:
Decision Tree
- Does the model support built-in grounding (e.g., Gemini)?
- YES: Enable
tool.google_search - NO: Use Custom Search API.
- YES: Enable
- Do you need to restrict search to specific sites?
- YES: Use
operator (no spaces).site:example.com
- YES: Use
- Do you need to exclude terms?
- YES: Use
operator.-term
- YES: Use
Workflows
1. Implementing Search Grounding (Tool-based)
- Enable the
tool in the model configuration.google_search - Send a user prompt to the API and receive the response containing
.groundingMetadata - Extract
for debugging andwebSearchQueries
for source links.groundingChunks - Render the response with citations by mapping
indices to the source URLs.groundingSupports
2. Precise Source Targeting
- Use the
operator to restrict searches to trusted domains (e.g.,site:
).site:nytimes.com - Combine multiple operators (e.g.,
) for specific technical queries.site:github.com "error 404" - Exclude irrelevant results using the
operator (e.g.,-
).jaguar speed -car
3. Custom Search API Integration
- Create a Programmable Search Engine ID in the Google control panel.
- Generate an API key for Custom Search.
- Perform GET requests to the API with the
parameter and parse the resulting JSON search results.q
Non-Obvious Insights
- Strict Operators: Search operators like
must NOT have spaces between the colon and the value (e.g.,site:
works,site:nytimes.com
fails).site: nytimes.com - Citations Metadata: Grounding metadata uses
to map specific text segments to source indices, allowing for precise, multi-source citations in a single sentence.groundingSupports - Synthesis Loop: The Gemini tool doesn't just return links; it analyzes the prompt, generates multiple refined queries, and synthesizes a grounded answer.
Evidence
- "The model analyzes the prompt and determines if a Google Search can improve the answer." - Google AI
- "Do not put spaces between the operator and your search term." - Google Search Help
- "Spain won Euro 2024...1" - Google AI Grounding Example
Scripts
: Implementation of Custom Search API requests.scripts/google-search_tool.py
: Example of parsing grounding metadata for citations.scripts/google-search_tool.js
Dependencies
(for Custom Search API)google-api-python-client
(for Gemini Tool-use)google-generativeai