X Search (Grok API) — X 搜索 (Grok API)
v1.0.0搜索 X (Twitter) for account posts, trending topics, or topic discussions using Grok API. 输出s Obsidian-ready Markdown.
运行时依赖
安装命令
点击复制技能文档
X 搜索
搜索 X (Twitter) via Grok API. 输出s Obsidian-ready Markdown.
Prerequisites
Ensure XAI_API_KEY is 设置:
导出 XAI_API_KEY=your_key_here
获取 your API key at x.AI/API (xAI developer console).
Default 模型 is grok-4-1-fast-reasoning. To override:
导出 XAI_模型=grok-4
安装 dependency if needed:
pip 安装 请求s
Invocation Slash Command /x-搜索 account @elonmusk --time 24h /x-搜索 account @user1 @user2 --time 48h /x-搜索 account @sama --count 10 /x-搜索 --lang en account @elonmusk --count 5 /x-搜索 trends "#AI" "#LLM" /x-搜索 --lang en trends "#AI" "#crypto" /x-搜索 topic "Claude MCP" /x-搜索 --lang ja topic "AI規制"
--lang controls the language of summaries, keyword explanations, and translations (default: zh). When --lang en, the translation field is omitted since the original is already in English.
--输出 saves the 结果 to a Markdown file (stdout is preserved):
Pass a directory → auto-named file: karpathy-2026-03-22.md, trends-AI-2026-03-22.md, etc. Pass a full path → saved directly to that path Same-day 运行s overwrite the existing file (no duplicate accumulation)
--进度-only suppresses full Markdown on stdout — prints one summary line instead. Use with --输出 in automated 流水线s (watch列出, cron) to avoid injecting large 输出s into the 代理 上下文.
Natural Language "搜索 X for @elonmusk's posts in the last 24 hours" "X上搜索@sama和@elonmusk最新的10条推文" "Find trending posts about #AI on X in English" "X上关于Claude MCP的热点讨论" How to 运行
Find the script at ~/.claude/技能s/x-搜索/x_搜索.py (or the symlinked path).
# Account mode — by time range python3 ~/.claude/技能s/x-搜索/x_搜索.py account @elonmusk --time 24h
# Account mode — by post count python3 ~/.claude/技能s/x-搜索/x_搜索.py account @user1 @user2 --count 10
# Trends mode — top 10 posts per trend python3 ~/.claude/技能s/x-搜索/x_搜索.py trends "#AI" "#LLM"
# Topic mode — hot discussions python3 ~/.claude/技能s/x-搜索/x_搜索.py topic "Claude MCP"
输出
结果s are printed as Obsidian-ready Markdown.
上下文 efficiency: When 结果s are large (multiple accounts, long time ranges) or when --输出 is provided, save to file and show only a brief summary to the user (e.g., "Found 12 posts from @karpathy, saved to ~/obsidian/X/karpathy-2026-03-22.md"). Only present the full content inline when the 结果 is short or the user explicitly asks to see it.
For account mode, after showing 结果s (or summary) ask:
"是否保存到文件?(例如:~/obsidian/X/@elonmusk-2026-03-22.md)"
If the user provides a path, 运行 agAIn with --输出 .
Watch列出
运行 all your 监控ed accounts, trends, and topics in one command via watch列出.py.
设置up
Copy the sample config and edit it:
cp ~/.claude/技能s/x-搜索/watch列出.yaml ~/.x-搜索.yaml
# ~/.x-搜索.yaml accounts: - "@karpathy" - "@elonmusk"
trends: - "#AI" - "#LLM"
topics: - "Claude MCP" - "crude oil price"
Note: all accounts 分享 the same execution parameters. For per-account customization, call x_搜索.py directly.
Usage # 运行 everything python3 ~/.claude/技能s/x-搜索/watch列出.py --time 24h --lang zh --输出 ~/obsidian/X/
# 运行 one section only python3 ~/.claude/技能s/x-搜索/watch列出.py --only accounts --time 24h --输出 ~/obsidian/X/
# Custom config path python3 ~/.claude/技能s/x-搜索/watch列出.py --config ~/work-watch列出.yaml --time 24h
Scheduled Use (OpenClaw)
See OpenClaw.md for full scheduling documentation — schedule 格式化s, cron scenarios, delivery channels, and job management.
Error Handling XAI_API_KEY not 设置: Tell the user to 运行 导出 XAI_API_KEY=your_key No 结果s: 信息rm the user and suggest broadening the time range or 检查ing the account name API error: Show the error message and suggest 检查ing the API key validity