BumpyClock/agent-templates / skills_archive/brave-search
brave-search
FlaggedWeb search and content extraction via Brave Search API. Use for searching documentation, facts, or any web content. Lightweight, no browser required.
| File | Kind | Size |
|---|---|---|
| .gitignore | other | 14 B |
| SKILL.md | skill md | 1.2 KB |
| content.js | script | 2.5 KB |
| package-lock.json | manifest | 20.0 KB |
| package.json | manifest | 332 B |
| search.js | script | 5.2 KB |
search.js
View on GitHub#!/usr/bin/env node
import { Readability } from "@mozilla/readability";
import { JSDOM } from "jsdom";
import TurndownService from "turndown";
import { gfm } from "turndown-plugin-gfm";
const args = process.argv.slice(2);
const contentIndex = args.indexOf("--content");
const fetchContent = contentIndex !== -1;
if (fetchContent) args.splice(contentIndex, 1);
let numResults = 5;
const nIndex = args.indexOf("-n");
if (nIndex !== -1 && args[nIndex + 1]) {
numResults = parseInt(args[nIndex + 1], 10);
args.splice(nIndex, 2);
}
const query = args.join(" ");
if (!query) {
console.log("Usage: search.js <query> [-n <num>] [--content]");
console.log("\nOptions:");
console.log(" -n <num> Number of results (default: 5)");
console.log(" --content Fetch readable content as markdown");
console.log("\nExamples:");
console.log(' search.js "javascript async await"');
console.log(' search.js "rust programming" -n 10');
console.log(' search.js "climate change" --content');
process.exit(1);
}
async function fetchBraveResults(query, numResults) {
const url = `https://search.brave.com/search?q=${encodeURIComponent(query)}`;
const response = await fetch(url, {
headers: {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
"Accept-Language": "en-US,en;q=0.9",
"sec-ch-ua": '"Chromium";v="142", "Google Chrome";v="142", "Not_A Brand";v="99"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"macOS"',
"sec-fetch-dest": "document",
"sec-fetch-mode": "navigate",
"sec-fetch-site": "none",
"sec-fetch-user": "?1",
}
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
const html = await response.text();
const dom = new JSDOM(html);
const doc = dom.window.document;
const results = [];
// Find all search result snippets with data-type="web"
const snippets = doc.querySelectorAll('div.snippet[data-type="web"]');
for (const snippet of snippets) {
if (results.length >= numResults) break;
// Get the main link and title
const titleLink = snippet.querySelector('a.svelte-14r20fy');
if (!titleLink) continue;
const link = titleLink.getAttribute('href');
if (!link || link.includes('brave.com')) continue;
const titleEl = titleLink.querySelector('.title');
const title = titleEl?.textContent?.trim() || titleLink.textContent?.trim() || '';
// Get the snippet/description
const descEl = snippet.querySelector('.generic-snippet .content');
let snippetText = descEl?.textContent?.trim() || '';
// Remove date prefix if present
snippetText = snippetText.replace(/^[A-Z][a-z]+ \d+, \d{4} -\s*/, '');
if (title && link) {
results.push({ title, link, snippet: snippetText });
}
}
return results;
}
function htmlToMarkdown(html) {
const turndown = new TurndownService({ headingStyle: "atx", codeBlockStyle: "fenced" });
turndown.use(gfm);
turndown.addRule("removeEmptyLinks", {
filter: (node) => node.nodeName === "A" && !node.textContent?.trim(),
replacement: () => "",
});
return turndown
.turndown(html)
.replace(/\[\\?\[\s*\\?\]\]\([^)]*\)/g, "")
.replace(/ +/g, " ")
.replace(/\s+,/g, ",")
.replace(/\s+\./g, ".")
.replace(/\n{3,}/g, "\n\n")
.trim();
}
async function fetchPageContent(url) {
try {
const response = await fetch(url, {
headers: {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
},
signal: AbortSignal.timeout(10000),
});
if (!response.ok) {
return `(HTTP ${response.status})`;
}
const html = await response.text();
const dom = new JSDOM(html, { url });
const reader = new Readability(dom.window.document);
const article = reader.parse();
if (article && article.content) {
return htmlToMarkdown(article.content).substring(0, 5000);
}
// Fallback: try to get main content
const fallbackDoc = new JSDOM(html, { url });
const body = fallbackDoc.window.document;
body.querySelectorAll("script, style, noscript, nav, header, footer, aside").forEach(el => el.remove());
const main = body.querySelector("main, article, [role='main'], .content, #content") || body.body;
const text = main?.textContent || "";
if (text.trim().length > 100) {
return text.trim().substring(0, 5000);
}
return "(Could not extract content)";
} catch (e) {
return `(Error: ${e.message})`;
}
}
// Main
try {
const results = await fetchBraveResults(query, numResults);
if (results.length === 0) {
console.error("No results found.");
process.exit(0);
}
if (fetchContent) {
for (const result of results) {
result.content = await fetchPageContent(result.link);
}
}
for (let i = 0; i < results.length; i++) {
const r = results[i];
console.log(`--- Result ${i + 1} ---`);
console.log(`Title: ${r.title}`);
console.log(`Link: ${r.link}`);
console.log(`Snippet: ${r.snippet}`);
if (r.content) {
console.log(`Content:\n${r.content}`);
}
console.log("");
}
} catch (e) {
console.error(`Error: ${e.message}`);
process.exit(1);
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file). | Stars: 198k | Updated | Claude CodeCodex | Unverified | Install |
| doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |