Dianel555/DSkills / skills/grok-search
grok-search
VerifiedEnhanced web search and real-time content retrieval via Grok API with forced tool routing. Use when: (1) Web search / information retrieval / fact-checking, (2) Webpage content extraction / URL parsing, (3) Breaking knowledge cutoff limits for current information, (4) Real-time news and technical documentation, (5) Multi-source information aggregation. Triggers: "search for", "find information about", "latest news", "current", "fetch webpage", "get content from URL". IMPORTANT: This skill REPLACES built-in WebSearch/WebFetch with Grok Search tools.
| File | Kind | Size |
|---|---|---|
| .env.example | other | 3.2 KB |
| README.md | markdown | 8.5 KB |
| SKILL.md | skill md | 6.6 KB |
| ruff.toml | config | 904 B |
| scripts/groksearch/__init__.py | script | 47 B |
| scripts/groksearch/cli.py | script | 5.0 KB |
| scripts/groksearch/commands.py | script | 9.1 KB |
| scripts/groksearch/config.py | script | 14.0 KB |
| scripts/groksearch/env.py | script | 1.4 KB |
| scripts/groksearch/formatting.py | script | 3.0 KB |
| scripts/groksearch/http.py | script | 2.9 KB |
| scripts/groksearch/prompts.py | script | 704 B |
| scripts/groksearch/provider.py | script | 5.7 KB |
| scripts/groksearch/tavily.py | script | 18.0 KB |
| scripts/groksearch_cli.py | script | 6.8 KB |
| scripts/tests/test_groksearch_cli.py | script | 62.8 KB |
| scripts/tests/test_retry_budget.py | script | 703 B |
scripts/groksearch/commands.py
View on GitHubimport asyncio
import json
import sys
import time
from pathlib import Path
import httpx
from .config import config
from .formatting import merge_search_results
from .provider import GrokSearchProvider
from .tavily import (
_call_tavily_crawl,
_call_tavily_extract,
_call_tavily_map,
_call_tavily_research,
_call_tavily_search,
_tavily_unavailable_reason,
)
async def cmd_web_search(args):
try:
provider = GrokSearchProvider(config.grok_api_url, config.grok_api_key, config.grok_model)
extra_sources = getattr(args, "extra_sources", 0) or 0
if args.raw:
grok_result = await provider.search(args.query, args.platform, args.min_results, args.max_results)
print(grok_result)
return
if extra_sources > 0 and _tavily_unavailable_reason() is None:
grok_task = provider.search(args.query, args.platform, args.min_results, args.max_results)
tavily_task = _call_tavily_search(args.query, extra_sources)
grok_result, tavily_results = await asyncio.gather(grok_task, tavily_task)
else:
grok_result = await provider.search(args.query, args.platform, args.min_results, args.max_results)
tavily_results = None
merged = merge_search_results(grok_result, tavily_results, tavily_requested=extra_sources > 0)
print(json.dumps(merged, ensure_ascii=False, indent=2))
except ValueError as e:
print(json.dumps({"error": str(e)}, ensure_ascii=False), file=sys.stderr)
sys.exit(1)
except httpx.HTTPStatusError as e:
print(json.dumps({"error": f"API error: {e.response.status_code}"}, ensure_ascii=False), file=sys.stderr)
sys.exit(1)
async def cmd_web_fetch(args):
via = getattr(args, "via", "grok")
try:
if via == "tavily":
reason = _tavily_unavailable_reason()
if reason:
print(json.dumps({"error": reason}, ensure_ascii=False), file=sys.stderr)
sys.exit(1)
result = await _call_tavily_extract(args.url)
if result is None:
print(
json.dumps({"error": "Tavily extract failed or returned empty content"}, ensure_ascii=False),
file=sys.stderr,
)
sys.exit(1)
else:
provider = GrokSearchProvider(config.grok_api_url, config.grok_api_key, config.grok_model)
result = await provider.fetch(args.url)
if args.out:
Path(args.out).write_text(result, encoding="utf-8")
print(f"Content saved to {args.out}")
else:
print(result)
except ValueError as e:
print(f"Error: {e}", file=sys.stderr)
sys.exit(1)
except httpx.HTTPStatusError as e:
print(f"API error: {e.response.status_code}", file=sys.stderr)
sys.exit(1)
async def _print_or_fail(coro):
"""Print a Tavily command result, or report a config error as JSON on stderr.
Tuning values are validated lazily on property access, so an invalid TAVILY_* env
surfaces as a ValueError from inside the call rather than at startup.
"""
try:
print(await coro)
except ValueError as e:
print(json.dumps({"error": str(e)}, ensure_ascii=False), file=sys.stderr)
sys.exit(1)
async def cmd_web_map(args):
await _print_or_fail(
_call_tavily_map(
args.url,
args.instructions,
args.max_depth,
args.max_breadth,
args.limit,
args.timeout,
)
)
async def cmd_web_crawl(args):
await _print_or_fail(
_call_tavily_crawl(
args.url,
args.instructions,
args.max_depth,
args.max_breadth,
args.limit,
args.timeout,
args.select_paths,
args.exclude_paths,
)
)
async def cmd_web_research(args):
await _print_or_fail(
_call_tavily_research(
args.input,
args.model,
args.output_length,
args.citation_format,
getattr(args, "output_schema", None),
)
)
async def cmd_get_config_info(args):
config_info = config.get_config_info()
if not args.no_test:
test_result = {"status": "Not tested", "message": "", "response_time_ms": 0}
try:
api_url = config.grok_api_url
api_key = config.grok_api_key
models_url = f"{api_url}/models"
start_time = time.time()
async with httpx.AsyncClient(timeout=10.0) as client:
response = await client.get(
models_url,
headers={"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"},
)
response_time = (time.time() - start_time) * 1000
if response.status_code == 200:
test_result["status"] = "✅ Connection Successful"
test_result["response_time_ms"] = round(response_time, 2)
try:
models_data = response.json()
except ValueError as e:
# A 200 with a non-JSON body still means the endpoint is reachable.
if config.debug_enabled:
print(f"[DEBUG] Could not parse models response: {e}", file=sys.stderr)
models_data = {}
if "data" in models_data:
model_count = len(models_data["data"])
test_result["message"] = f"Retrieved {model_count} models"
test_result["available_models"] = [
m.get("id") for m in models_data["data"] if isinstance(m, dict)
]
else:
test_result["status"] = "⚠️ Connection Issue"
test_result["message"] = f"HTTP {response.status_code}"
except httpx.TimeoutException:
test_result["status"] = "❌ Connection Timeout"
test_result["message"] = "Request timed out (10s)"
except Exception as e:
test_result["status"] = "❌ Connection Failed"
test_result["message"] = str(e)
config_info["connection_test"] = test_result
print(json.dumps(config_info, ensure_ascii=False, indent=2))
async def cmd_switch_model(args):
try:
previous = config.set_model(args.model)
result = {
"status": "✅ Success",
"previous_model": previous,
"current_model": args.model,
"config_file": str(config.config_file),
}
print(json.dumps(result, ensure_ascii=False, indent=2))
except Exception as e:
print(json.dumps({"status": "❌ Failed", "error": str(e)}, ensure_ascii=False), file=sys.stderr)
sys.exit(1)
async def cmd_toggle_builtin_tools(args):
if args.root:
root = Path(args.root)
if not root.exists():
print(
json.dumps({"error": f"Specified root does not exist: {args.root}"}, ensure_ascii=False),
file=sys.stderr,
)
sys.exit(1)
else:
root = Path.cwd()
while root != root.parent and not (root / ".git").exists():
root = root.parent
if not (root / ".git").exists():
print(
json.dumps(
{
"error": "No .git directory found. Use --root to specify project root.",
"hint": "Run this command from within a git repository or specify --root PATH",
},
ensure_ascii=False,
),
file=sys.stderr,
)
sys.exit(1)
settings_path = root / ".claude" / "settings.json"
tools = ["WebFetch", "WebSearch"]
if settings_path.exists():
with open(settings_path, encoding="utf-8") as f:
settings = json.load(f)
else:
settings = {"permissions": {"deny": []}}
deny = settings.setdefault("permissions", {}).setdefault("deny", [])
blocked = all(t in deny for t in tools)
action = args.action.lower()
if action in ["on", "enable"]:
for t in tools:
if t not in deny:
deny.append(t)
settings_path.parent.mkdir(parents=True, exist_ok=True)
with open(settings_path, "w", encoding="utf-8") as f:
json.dump(settings, f, ensure_ascii=False, indent=2)
msg = "Built-in tools disabled"
blocked = True
elif action in ["off", "disable"]:
deny[:] = [t for t in deny if t not in tools]
settings_path.parent.mkdir(parents=True, exist_ok=True)
with open(settings_path, "w", encoding="utf-8") as f:
json.dump(settings, f, ensure_ascii=False, indent=2)
msg = "Built-in tools enabled"
blocked = False
else:
msg = f"Built-in tools currently {'disabled' if blocked else 'enabled'}"
print(
json.dumps(
{"blocked": blocked, "deny_list": deny, "file": str(settings_path), "message": msg},
ensure_ascii=False,
indent=2,
)
)
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: 472k | 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 |