Query Wikipedia
Google AI EdgeOfficialPublished by Google AI Edge
- Skill
- Tool integration
- Data and AI
- Apache-2.0
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The query-wikipedia skill enables an agent to fetch and summarize information from Wikipedia. By requiring a clean, entity-focused topic and a corresponding language code, it ensures accurate retrieval of broad subject articles. The skill is designed to provide concise, 1-3 sentence summaries, maintaining the language of the original user request and offering related information if the specific query details are not found.
What it does
- Extracts primary entities or events from user queries for Wikipedia searching.
- Supports multi-language queries using standard 2-letter language codes.
- Generates concise summaries of 1-3 sentences.
- Handles time-sensitive queries by defaulting to current iterations if unspecified.
- Provides fallback information if the exact answer is missing from the retrieved content.
When to use it
- When you need a quick, reliable summary of a person, place, or event.
- When verifying general knowledge facts during a conversation.
- When you need information in a specific language supported by Wikipedia.
- When you need to provide context for a broad topic without overwhelming the user.
Advantages
- Reduces context bloat by enforcing a 1-3 sentence summary limit.
- Ensures linguistic consistency by matching the output language to the input.
- Improves search accuracy by stripping conversational filler from the query.
- Maintains helpfulness by offering related facts when direct answers are unavailable.
Usage examples
- “Who is Albert Einstein?”
- The agent extracts 'Albert Einstein' as the topic and returns a concise 1-3 sentence summary of his life and contributions.
- “Dime quién ganó el mundial 2022”
- The agent extracts 'Mundial 2022' as the topic, uses the 'es' language code, and provides a summary in Spanish.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/google-ai-edge/query-wikipedia/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip query-wikipedia.zip -d .agents/skills
Documentation by Google AI Edge
Query Wiki
Instructions
Call the run_js tool using index.html and a JSON string for data with the following fields:
topic: Required. Extract ONLY the primary entity, person, or event (e.g., "2026 Oscars", "Albert Einstein"). You MUST REMOVE all specific question details, action words, or conversational text (e.g., do NOT include words like "winner", "best picture", "who won", "history of"). Search for the broad subject so the tool can return the main article.
lang: Required. The 2-letter language code. This code MUST match the language of the keywords you provided in the
topicfield. Use standard codes, e.g., "en" (English), "es" (Spanish), "zh" (Chinese), "fr" (French), "de" (German), "ja" (Japanese), "ko" (Korean), "it" (Italian), "pt" (Portuguese), "ru" (Russian), "ar" (Arabic), "hi" (Hindi).
Constraints:
Provide a concise summary (1-3 complete sentences) to conserve context. Always ensure your response ends with a finished sentence. your response MUST BE written in the SAME language as the user's original prompt.
For recurring events or time-sensitive facts, query the specific iteration (e.g., "2026 Oscars"). If the user omits the year, default to the current year.
If the exact answer to the user's question is not found in the extract, briefly state this, then proactively offer a related piece of information that was found in the text.
Files
- ATTRIBUTION.mdAdded by AutoGineer901 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md1.5 KiB
- scripts/index.html5.5 KiB
scripts/index.html
<!--
@license
Copyright 2026 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================
-->
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Query Wiki</title>
</head>
<body>
<script>
/**
* Performs a fuzzy search to get the intro, then fetches Section 0 HTML to parse the infobox.
* @param {string} topic - The search keywords.
* @param {string} lang - The two-letter language code.
*/
async function fetchWikiFuzzyAndInfobox(topic, lang) {
const baseUrl = `https://${lang}.wikipedia.org/w/api.php`;
// Step 1: Fuzzy search to get the exact title and the clean introduction
const searchParams = new URLSearchParams({
action: "query",
format: "json",
generator: "search",
gsrsearch: topic,
gsrlimit: "1",
prop: "extracts",
explaintext: "1",
exintro: "1",
origin: "*",
});
const searchRes = await fetch(`${baseUrl}?${searchParams.toString()}`);
if (!searchRes.ok) throw new Error(`HTTP error! status: ${searchRes.status}`);
const searchData = await searchRes.json();
if (!searchData.query || !searchData.query.pages) {
return {
error: `No Wikipedia articles found matching '${topic}' in language '${lang}'.`,
};
}
const pages = searchData.query.pages;
const firstPageKey = Object.keys(pages)[0];
const page = pages[firstPageKey];
const title = page?.title;
let extract = page?.extract || "";
// Step 2: Fetch the HTML of Section 0 (the top of the page) to grab the infobox
let infoboxText = "";
try {
const parseParams = new URLSearchParams({
action: "parse",
page: title,
section: "0",
prop: "text",
format: "json",
origin: "*",
});
const parseRes = await fetch(`${baseUrl}?${parseParams.toString()}`);
const parseData = await parseRes.json();
const html = parseData?.parse?.text["*"];
if (html) {
// Use DOMParser to parse the HTML and find the infobox table
const parser = new DOMParser();
const doc = parser.parseFromString(html, "text/html");
const infobox = doc.querySelector("table.infobox");
if (infobox) {
const rows = infobox.querySelectorAll("tr");
rows.forEach((row) => {
const th = row.querySelector("th");
const td = row.querySelector("td");
if (th && td) {
// Clean up text (remove citation brackets like [1] and swap newlines for separators)
let key = th.textContent.replace(/\[\d+\]/g, "").trim();
let value = td.textContent
.replace(/\[\d+\]/g, "")
.trim()
.replace(/\n+/g, " | ");
infoboxText += `${key}: ${value}\n`;
}
});
}
}
} catch (e) {
console.warn("Failed to parse infobox:", e);
// If parsing fails, we just silently continue and return the extract
}
// Step 3: Combine Infobox and Extract
let finalResult = "";
if (infoboxText) {
finalResult += `--- INFOBOX ---\n${infoboxText}\n\n`;
}
if (extract) {
finalResult += `--- SUMMARY ---\n${extract}`;
}
if (!finalResult.trim()) {
return { error: `Found page '${title}' but no text or infobox was available.` };
}
// Step 4: Apply language-based safety caps
let maxChars;
switch (lang.toLowerCase()) {
case "zh":
maxChars = 1500;
break;
case "fr":
maxChars = 4300;
break;
case "es":
maxChars = 4500;
break;
case "en":
default:
maxChars = 5000;
break;
}
if (finalResult.length > maxChars) {
finalResult = finalResult.substring(0, maxChars) + "\n\n... [TRUNCATED TO SAVE CONTEXT]";
}
return { title: title, result: finalResult };
}
window["ai_edge_gallery_get_result"] = async (data) => {
try {
const jsonData = JSON.parse(data);
if (!jsonData.topic) return JSON.stringify({ error: "No topic provided to search." });
if (!jsonData.lang) return JSON.stringify({ error: "No language code (lang) provided." });
const wikiResponse = await fetchWikiFuzzyAndInfobox(jsonData.topic, jsonData.lang);
return JSON.stringify(wikiResponse);
} catch (e) {
console.error(e);
return JSON.stringify({ error: `Failed to query Wikipedia: ${e.message}` });
}
};
</script>
</body>
</html>
Requirements and compatibility
Written for: Google AI Edge Gallery
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Google AI Edge
- Publisher
- Google AI Edge (Official)
- Source
- google-ai-edge/gallery · skills/built-in/query-wikipedia · commit 3972f06
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Google AI Edge or Google AI Edge.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download query-wikipedia.zip