Commands, package names, and image names on this page come from the open-source project that Mibyan Desktop is built on, and can differ from the Mibyan Desktop installer. For the supported Mibyan install and update path, see Install and update.
Skill metadata
Reference: full SKILL.md
The following is the complete skill definition that Mibyan loads when this skill is triggered. This is what the agent sees as instructions when the skill is active.
Grok Build CLI — Mibyan Orchestration Guide
Delegate coding tasks to Grok Build (xAI’s autonomous coding agent CLI, thegrok command) via the Mibyan 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 theXAI_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.
--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 withpty=true. For
robust monitoring/input use tmux (same pattern as the claude-code skill).
--no-alt-screen.
For pure automation, headless -p is still cleaner than the TUI.
Headless Deep Dive
Common Flags
Output Formats
plain— human-readable text (default)json— one JSON object at the end of the run (parse the result cleanly)streaming-json— newline-delimited JSON events as they arrive
Background Mode (Long Tasks)
pty=true + tmux and monitor
with tmux capture-pane, exactly like the claude-code / codex skills.
Session Continuation
Sessions are keyed by UUID, not by name.--session-id assigns a new UUID
to a fresh run (it does not resume); --resume takes an existing session’s
UUID (or omit the value to resume the most recent).
Read-Only Audit → Markdown Note Pattern
To have Grok review local artifacts and return a clean markdown note (for Obsidian or a repo) without mutating anything:- Prepare stable input files first with Mibyan tools (
read_file,write_file). Snapshot only the relevant context into a temp file rather than dumping raw paths. - Run Grok headless without
--always-approveso it cannot auto-write, and demandmarkdown only, no preamble. - Save Grok’s stdout straight into the destination note with
write_file().
Return ONLY the full revised markdown document. No intro, no explanation, no code fences. Start immediately with '# Title'. Verify the
first lines with read_file() before overwriting the destination.
PR Review Patterns
Quick Review (Headless)
Clone-to-temp Review (safe, no repo mutation)
Post the review
Parallel Issue Fixing with Worktrees
Useful Subcommands & TUI Commands
TUI slash commands (interactive only):
/model <name>, /always-approve,
/plan, /context, /compact, /resume, /sessions, /fork, /usage,
/quit. Shift+Tab cycles session modes (including Plan mode, which blocks
write tools except the session plan file).
Config (~/.grok/config.toml)
~/.grok/config.toml (not project-scoped
.grok/config.toml). permission_mode supersedes the legacy approval_mode /
yolo = true keys.
Pitfalls & Gotchas
- Auth is subscription-gated.
grok loginrequires a SuperGrok or X Premium+ subscription. If login fails or there’s no~/.grok/auth.json, confirm the subscription is active before falling back toXAI_API_KEY. - Don’t conflate Mibyan’ xAI auth with the
grokCLI’s auth. Mibyan’x_searchruns on its own xAI OAuth; the standalonegrokCLI has a separate token in~/.grok/auth.json. A workingx_searchdoes NOT meangrokis logged in. - Always pass
--no-auto-updatein automation — otherwise Grok phones home for update checks (andx.ai/storage.googleapis.commay be unreachable). - Prefer npm install over the curl installer —
npm install -g @xai-official/grokavoids the Cloudflare-walledx.aihost. --always-approveis the autonomous-build switch. Without it, headless runs may stall waiting on tool-approval prompts. Omit it deliberately for read-only review/audit work so Grok can’t mutate files.- Headless
-pskips TUI dialogs; the TUI needspty=true(+ tmux for monitoring), just like Claude Code. - Use
--no-alt-screenif you run the TUI inline and the fullscreen alt-screen takeover garbles captured output. - No git repo needed, but for PR/commit workflows you still want one — use
mktemp -d && git initfor scratch commit tasks. - Clean up tmux sessions with
tmux kill-session -t <name>when done.
Rules for Mibyans
- Prefer headless
-pfor single tasks — cleanest integration, structured output via--output-format json. - Always set
workdir(or--cwd) so Grok targets the right project. - Pass
--no-auto-updatein every automated invocation. - Use
--always-approveonly when Grok should write autonomously; omit it for read-only reviews and audits. - Background long tasks with
background=true, notify_on_complete=trueand monitor via theprocesstool. - Use tmux for multi-turn interactive work and monitor with
tmux capture-pane -t <session> -p -S -50. - Verify auth before relying on it — check
~/.grok/auth.jsonor run a cheapgrok -p "Say ok."smoke test; don’t assume Mibyan’ xAI auth carries over. - Report results to the user — summarize what Grok changed and what’s left.

