grok
它能做什么
它指导你的智能体在编程任务上运行 Grok Build 命令行工具。它适合希望由 Grok 担任某项工作的编程智能体的开发者。
适用场景
- ✓你希望 Grok 构建功能或重构部分代码的时候。
- ✓你希望 Grok 审阅某个拉取请求的时候。
- ✓你希望由 Grok 而不是其他编程智能体来批量修复议题的时候。
技能链接
https://github.com/NousResearch/hermes-agent/blob/main/optional-skills/autonomous-ai-agents/grok/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请让 Grok 审阅支付模块中未关闭的拉取请求,并告诉我它发现了什么。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体对一次性任务以无界面模式运行 Grok,对较长的会话则在交互式终端中运行。技能说明登录时使用 SuperGrok 或 X Premium 订阅。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Grok Build CLI — Hermes Orchestration Guide
Delegate coding tasks to Grok Build (xAI's
autonomous coding agent CLI, the grok command) via the Hermes terminal. Grok
can read files, write code, run shell commands, spawn subagents, and manage git
workflows. It runs three ways: an interactive TUI, headless (-p), and as
an ACP agent over JSON-RPC.
This is the third sibling to codex and claude-code. The orchestration
pattern is nearly identical — prefer headless -p for one-shots, use a PTY
for interactive sessions.
When to use
- Building features
- Refactoring
- PR reviews
- Batch issue fixing
- Any task where you'd otherwise reach for Codex / Claude Code but want Grok
Prerequisites
- Install (preferred):
npm install -g @xai-official/grok- The official installer
curl -fsSL https://x.ai/cli/install.sh | bashalso works, but thex.aihost is Cloudflare-walled in some environments. The npm path avoids that dependency entirely.
- The official installer
- Auth — SuperGrok / X Premium+ subscription (primary path):
- Run
grok loginonce → opens a browser for OAuth → token cached in~/.grok/auth.json. This uses your SuperGrok or X Premium+ subscription (no per-token API billing). - Check sign-in state by looking for
~/.grok/auth.json, or run a cheap headless smoke test:grok --no-auto-update -p "Say ok." - In the TUI,
/logoutsigns out and/login(or relaunching) signs back in.
- Run
- No git repo required — unlike Codex, Grok runs fine outside a git directory (good for scratch/throwaway tasks).
- Claude Code / AGENTS.md compatible with zero config — Grok auto-reads
CLAUDE.md,.claude/(skills, agents, MCPs, hooks, rules), and theAGENTS.mdfamily. Existing project context just works.
API-key fallback (not the default for this user): Grok also supports setting the
XAI_API_KEYenvironment variable for pay-as-you-go billing viaapi.x.ai. Only use this ifgrok login/ SuperGrok auth is unavailable. The subscription path (grok login) is the intended setup here.
Two Orchestration Modes
Mode 1: Headless (-p) — Non-Interactive (PREFERRED)
Runs a one-shot task, prints the result, and exits. No PTY, no interactive
dialogs to navigate. This is the cleanest integration path — the analog of
claude -p and codex exec.
terminal(command="grok --no-auto-update -p 'Add a dark mode toggle to settings'", workdir="/path/to/project", timeout=180)
Always pass --no-auto-update in automation to skip background update checks.
When to use headless:
- One-shot coding tasks (fix a bug, add a feature, refactor)
- CI/CD automation and scripting
- Structured output parsing with
--output-format json - Any task that doesn't need multi-turn conversation
Mode 2: Interactive PTY — Multi-Turn TUI Sessions
The TUI is a fullscreen, mouse-interactive app. Drive it with pty=true. For
robust monitoring/input use tmux (same pattern as the claude-code skill).
# Launch in a tmux session for capture-pane monitoring
terminal(command="tmux new-session -d -s grok-work -x 140 -y 40")
terminal(command="tmux send-keys -t grok-work 'cd /path/to/project && grok' Enter")
# Wait for startup, then send a task
terminal(command="sleep 5 && tmux send-keys -t grok-work 'Refactor the auth module to use JWT' Enter")
# Monitor progress
terminal(command="sleep 15 && tmux capture-pane -t grok-work -p -S -50")
# Exit when done
terminal(command="tmux send-keys -t grok-work '/quit' Enter && sleep 1 && tmux kill-session -t grok-work")
Tip for headless-but-inline output: if you want TUI-style output without the
fullscreen alt-screen takeover (e.g. for cleaner logs), add --no-alt-screen.
For pure automation, headless -p is still cleaner than the TUI.
Headless Deep Dive
Common Flags
| Flag | Effect |
|---|---|
-p, --single <PROMPT> |
Send one prompt, run headless, exit |
-m, --model <MODEL> |
Choose a model |
-s, --session-id <UUID> |
Assign a NEW valid UUID to a fresh conversation (must not already exist). Does not resume — use --resume/--continue for that. Only valid with --resume/--continue when paired with --fork-session |
-r, --resume [<UUID>] |
Resume an existing session by its UUID (or the most recent if omitted) |
-c, --continue |
Continue the most recent session in the current directory |
--fork-session |
When resuming, create a n |
常见问题
我如何登录?
运行一次 grok login,它会打开浏览器完成登录,并把令牌保存在你的用户文件夹中。
它使用哪种套餐?
技能说明它使用 SuperGrok 或 X Premium 订阅,而不是按令牌计费的 API。
如何安装?
技能优先使用 npm 安装,并使用官方包名。
详情
热度
- GitHub 星标
- 260k
- 排名
- #442
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
agent-merge-conflict-arbiter
260k以中立第三方的身份,解决两个智能体分支之间的 git 合并冲突,为代码仓库生成一个合并结果。
antigravity-cli
260k指导你安装、更新和排查 Antigravity 命令行工具,包括其插件、登录和沙盒。
blackbox
260k让你的智能体把编程任务交给 Blackbox AI 命令行工具,它会运行多个 AI 模型并挑选最佳结果。
dynamic-workflow
260k教你的智能体把大量相似的工作保存为脚本批量运行,使只有经过验证的结果才返回主对话。