xai-grok
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesexAI Grok Integration with Agentic Tool Calling
集成Agent工具调用的xAI Grok模型
This skill enables Claude to delegate queries to xAI's Grok model with powerful agentic capabilities including real-time X (Twitter) search, web browsing, and code execution.
该功能可让Claude将查询任务委托给xAI的Grok模型,借助其强大的智能工具调用能力,实现实时X(Twitter)搜索、网页浏览与代码执行。
When to Use This Skill
何时使用该功能
Use this skill when:
- User explicitly asks to use Grok or xAI
- User needs real-time X (Twitter) search - finding tweets, users, trends
- User requests "another opinion" or "alternative perspective"
- Query requires very recent information or current events
- User wants social media analysis or Twitter/X insights
- Task benefits from Grok's unique training and perspective
- Complex research requiring multiple tools (web search + code + Twitter)
在以下场景中使用该功能:
- 用户明确要求使用Grok或xAI
- 用户需要实时X(Twitter)搜索——查找推文、用户、趋势
- 用户请求「另一种观点」或「不同视角分析」
- 查询需要最新资讯或时事内容
- 用户需要社交媒体分析或Twitter/X洞察
- 任务可借助Grok独特的训练背景与视角完成
- 需要多工具配合的复杂研究(网页搜索+代码+Twitter)
Core Capabilities
核心功能
1. X (Twitter) Search
1. X(Twitter)搜索
- Semantic and keyword search across X posts, users, and threads
- User search by name or handle
- Thread fetching for full conversation context
- Real-time data from the X platform
- 针对X平台帖子、用户与话题串的语义与关键词搜索
- 按名称或账号名进行用户搜索
- 获取完整对话上下文的话题串提取
- 来自X平台的实时数据
2. Web Search
2. 网页搜索
- Real-time search across the internet
- Browse web pages and extract content
- 全网实时搜索
- 浏览网页并提取内容
3. Code Execution
3. 代码执行
- Write and execute Python code
- Data analysis and complex computations
- Generate visualizations and process data
- 编写并执行Python代码
- 数据分析与复杂计算
- 生成可视化图表与数据处理
4. Agentic Orchestration
4. 智能任务编排
- Server-side tool calling - Grok autonomously decides which tools to use
- Multi-step reasoning - Combines multiple tools to answer complex queries
- Streaming mode - Real-time progress and observability (always used per xAI recommendation)
- Citations - Full traceability of information sources
- 服务端工具调用——Grok自主决定使用哪些工具
- 多步骤推理——结合多种工具完成复杂查询
- 流式响应模式——实时进度反馈与可观测性(遵循xAI建议默认启用)
- 引用标注——信息来源可完全追溯
Usage
使用方法
The skill uses a modern Typer-based CLI at :
.claude/skills/xai-grok/src/grok.py该功能基于现代化Typer CLI开发,路径为:
.claude/skills/xai-grok/src/grok.pyBasic Usage (X Search + Web Search enabled by default)
基础用法(默认启用X搜索+网页搜索)
bash
python3 grok.py "Find recent tweets from Israeli tech nano-influencers"bash
python3 grok.py "Find recent tweets from Israeli tech nano-influencers"With All Tools Including Code Execution
启用全部工具(含代码执行)
bash
python3 grok.py "Analyze tech trends with charts" --enable-code-executionbash
python3 grok.py "Analyze tech trends with charts" --enable-code-executionGet Help
获取帮助
bash
python grok.py --helpbash
python grok.py --helpTwitter/X Search Examples
Twitter/X搜索示例
bash
undefinedbash
undefinedFind specific users
查找特定用户
python3 grok.py "Who are the top Israeli tech influencers on X?"
python3 grok.py "Who are the top Israeli tech influencers on X?"
Search for recent tweets
搜索最新推文
python3 grok.py "Latest tweets about Israeli startups"
python3 grok.py "Latest tweets about Israeli startups"
Analyze trends
分析趋势
python3 grok.py "What are Israeli tech companies tweeting about today?"
python3 grok.py "What are Israeli tech companies tweeting about today?"
Use fast model with custom temperature (short options)
使用快速模型并自定义温度参数(短选项)
python3 grok.py "Recent AI tweets" -m grok-4-fast-reasoning -t 0.5
undefinedpython3 grok.py "Recent AI tweets" -m grok-4-fast-reasoning -t 0.5
undefinedDisable Specific Tools
禁用特定工具
bash
undefinedbash
undefinedOnly X search, no web search
仅启用X搜索,禁用网页搜索
python3 grok.py "Find tweets" --disable-web-search
python3 grok.py "Find tweets" --disable-web-search
Only web search, no X search
仅启用网页搜索,禁用X搜索
python3 grok.py "Latest news" --disable-x-search
python3 grok.py "Latest news" --disable-x-search
No tools (basic chat)
禁用所有工具(基础聊天模式)
python3 grok.py "Explain AI" --disable-all-tools
undefinedpython3 grok.py "Explain AI" --disable-all-tools
undefinedAvailable Options
可用选项
bash
--model, -m # Model selection (default: grok-4)
--temperature, -t # Temperature for response generation (default: 0.3)
--disable-x-search # Disable X (Twitter) search (enabled by default)
--disable-web-search # Disable web search (enabled by default)
--enable-code-execution # Enable Python code execution (opt-in)
--disable-all-tools # Disable all tools (basic chat mode)
--show-citations # Show source URLs (default: enabled)
--no-show-citations # Hide source URLs
--show-usage # Show token usage statistics
--show-tool-calls # Show real-time tool calls
--install-completion # Install shell completion for the current shell
--show-completion # Show completion script for customizationbash
--model, -m # 模型选择(默认:grok-4)
--temperature, -t # 响应生成温度参数(默认:0.3)
--disable-x-search # 禁用X(Twitter)搜索(默认启用)
--disable-web-search # 禁用网页搜索(默认启用)
--enable-code-execution # 启用Python代码执行(需主动开启)
--disable-all-tools # 禁用所有工具(基础聊天模式)
--show-citations # 显示来源URL(默认启用)
--no-show-citations # 隐藏来源URL
--show-usage # 显示Token使用统计
--show-tool-calls # 显示实时工具调用记录
--install-completion # 为当前Shell安装命令补全功能
--show-completion # 显示自定义补全脚本Available Grok 4 Models
可用Grok 4模型
- - Highest quality model, 256k context [DEFAULT]
grok-4 - - Cost-efficient with reasoning, 2M context
grok-4-fast-reasoning - - Cost-efficient without reasoning, 2M context
grok-4-fast-non-reasoning
- - 最高质量模型,256k上下文长度【默认】
grok-4 - - 高性价比推理模型,2M上下文长度
grok-4-fast-reasoning - - 高性价比非推理模型,2M上下文长度
grok-4-fast-non-reasoning
Requirements
前置要求
- XAI_API_KEY environment variable in project's .env file
- 需在项目的.env文件中配置XAI_API_KEY环境变量
How It Works
工作原理
When you invoke this skill with tools enabled, Grok uses agentic tool calling:
- Analyzes your query to understand what information is needed
- Autonomously selects tools - decides whether to search X, browse web, execute code, or combine multiple approaches
- Executes tools server-side - no need for you to handle tool responses
- Iterates and refines - uses tool results to make better decisions
- Returns comprehensive answer with citations and sources
This means a single query like "What are Israeli tech companies tweeting about and how does it compare to global trends?" can automatically:
- Search X for Israeli tech company tweets
- Search the web for global tech trends
- Execute Python code to analyze patterns
- Synthesize everything into a comprehensive answer
当你启用工具调用功能时,Grok会执行以下智能工具调用流程:
- 分析查询内容,明确所需信息
- 自主选择工具——决定是否使用X搜索、网页浏览、代码执行,或组合多种方式
- 服务端执行工具——无需你手动处理工具响应
- 迭代优化——利用工具结果做出更优决策
- 返回全面答案,附带引用标注与来源
这意味着像「以色列科技公司在讨论什么?与全球趋势相比如何?」这样的单个查询,可自动完成以下操作:
- 搜索X平台上以色列科技公司的推文
- 搜索网页获取全球科技趋势
- 执行Python代码分析模式规律
- 将所有信息整合为完整的分析结果
Output
输出内容
The script provides:
- Streaming responses with real-time progress
- Citations - URLs of all sources Grok used
- Tool call visibility - See which tools Grok invoked (optional)
- Token usage - Detailed cost tracking (optional)
- Professional CLI - Rich formatted help text with boxed sections
- Shell completion - Tab completion support for all commands and options
该脚本提供:
- 流式响应,实时展示进度
- 引用标注——Grok使用的所有来源URL
- 工具调用可见性——可查看Grok调用了哪些工具(可选)
- Token使用统计——详细的成本追踪(可选)
- 专业CLI界面——带框体分区的格式化帮助文本
- Shell补全——支持所有命令与选项的Tab补全
Notes
注意事项
- Typer-powered CLI provides a modern, user-friendly interface with rich formatting
- Grok responses are clearly indicated in output
- X search provides real-time data from the Twitter/X platform
- Citations show full traceability of information sources
- This is a supplementary tool; Claude remains the primary assistant
- API usage incurs costs on the user's xAI account
- Streaming mode is always used for agentic workflows (per xAI strong recommendation)
- Image/video understanding is not supported in this implementation
- 基于Typer开发的CLI提供现代化、用户友好的界面与丰富格式化效果
- 输出内容中会清晰标注Grok的响应
- X搜索提供来自Twitter/X平台的实时数据
- 引用标注确保信息来源可完全追溯
- 这是辅助工具,Claude仍为主要助手
- API使用会产生费用,由用户的xAI账户承担
- 流式模式始终用于智能工作流(遵循xAI强烈建议)
- 本实现暂不支持图片/视频识别