grok-oauth-router

A routing guide for using Grok, xAI's AI service, for chat, searches on X, image and video generation, text-to-speech, speech-to-text and agent connections.

In plain words
What is it for?
Use it when a task must be handled by Grok, including chatting, searching X, creating media, converting speech and connecting compatible tools.
Why use it?
It determines which Grok capability fits the request and handles the required OAuth sign-in before continuing the task.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/moore-developers/grok-cli/archive
Any agent
npx skills add Moore-developers/grok-cli --skill archive
Clone the repo
git clone --depth 1 https://github.com/Moore-developers/grok-cli

Made for: Claude Code, Codex.

Per session 130 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,216 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00130 $0.02216
Opus 5 $0.00065 $0.01108
Sonnet 5 $0.00026 $0.00443
Haiku 4.5 $0.00013 $0.00222

Measured 2d ago against content hash 57ad482527ba, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

grok-oauth-router scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/archive/SKILL.md · 267 lines

How it starts

The opening of the file, as written. The whole thing — 267 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Grok OAuth Router

任务定义

这个技能的目标不是单纯解释 Grok OAuth,也不是只把模型切换到 Grok。

你的职责是把用户的“用 Grok 做 X”转换成一个可执行的完整流程:

  1. 判断用户要用的是哪一种 Grok 能力。
  2. 判断当前是否已经具备可复用的 Grok OAuth。
  3. 如果还没有,则先走 OAuth。
  4. 保存凭据以供后续复用。
  5. 恢复并继续执行用户原始任务。

默认使用用户自己的 OAuth。

默认坚持 OAuth-first。不要静默退回 API key 模式。只有在用户明确允许时, 才把 API key 作为异常回退路径。

何时触发

当出现下面这些情况时,应当触发本技能:

  • 用户明确说“用 Grok 做……”
  • 用户明确说“走 Grok OAuth”
  • 用户明确说“用 xAI / Grok 来处理这个任务”
  • 用户希望统一通过 Grok 完成聊天、搜索、图片、视频、语音或转写能力
  • 用户当前任务已经表明必须优先使用 Grok,而不是其他 provider

高频示例:

  • 用 Grok 总结这个仓库
  • 用 Grok 去 X 上搜大家怎么评价这个发布
  • 用 Grok 生成一张图
  • 用 Grok 生成一个短视频
  • 用 Grok 把这段话读出来
  • 用 Grok 把这段录音转成文字
  • 用 Grok 的代理接口给别的工具使用

能力分类

先把用户任务归类到以下内部模式之一:

  • chat
  • x_search
  • image_gen
  • video_gen
  • tts
  • stt
  • proxy

归类原则:

  • 没有明确媒体或工具诉求时,默认按 chat 处理
  • 提到 X / Twitter / 推文 / 线程 / 社交反应时,优先考虑 x_search
  • 提到生成图片、海报、概念图、插画、渲染时,优先考虑 image_gen
  • 提到生成视频、动画、图生视频时,优先考虑 video_gen
  • 提到朗读、配音、语音播报时,优先考虑 tts
  • 提到转录、转写、语音识别、字幕时,优先考虑 stt
  • 提到 OpenAI-compatible、代理端点、给别的工具接入时,优先考虑 proxy

执行流程

始终按下面的顺序处理:

1. 先识别原始任务

不要一看到 Grok 就只讨论认证。先提炼出用户真正想完成的任务。

你需要在内部保留一个简短的“原始任务摘要”,用于认证完成后的自动续跑。

2. 检查 OAuth 状态

优先复用已有的 Grok OAuth 状态。检查重点包括:

  • 是否已有已保存的 xAI OAuth 状态
  • access token 是否存在
  • token 是否仍可用
  • 是否已经进入需要重新登录的状态
  • 是否属于 entitlement / tier 被拒绝,而不是普通登录失效

如果 OAuth 已可用,就直接继续执行原始任务。

3. 没有 OAuth 时先认证

如果没有可用 OAuth,就先完成认证,再继续任务。

认证模式优先级:

  • 本地桌面环境:使用浏览器 loopback 回调
  • SSH / 远程环境:使用远程 listener + 本地端口转发
  • 浏览器型远端环境:使用手动粘贴 callback 的方式

认证完成后要做两件事:

  • 保存凭据,供未来 Grok 任务复用
  • 自动恢复原始任务,而不是停在“登录成功”

4. 把任务路由到正确能力面

认证通过后,按能力类型继续:

  • chat 用 Grok 作为主模型完成聊天、推理、分析、总结、工具调用等任务

  • x_search 优先使用 Grok 的 X 搜索能力,而不是泛化成普通网页搜索

  • image_gen 路由到 Grok 图片生成能力

  • video_gen 路由到 Grok 视频生成能力

  • tts 路由到 Grok 文本转语音能力

  • stt 路由到 Grok 语音转文字能力

  • proxy 路由到 Grok 兼容代理能力

5. 自动续跑原任务

认证只是前置步骤,不是结果。

认证成功后,直接继续执行原始任务,不要要求用户重复说一遍“刚才那个任务”。

错误处理规则

必须区分两类问题:

需要重新登录

这类问题通常意味着:

  • 本地没有可用 OAuth
  • refresh token 失效
  • token 过期且无法正常刷新
  • 需要重新完成浏览器授权

遇到这种情况时,应该把重点放在“先完成认证,再自动恢复原任务”。

Read the full file on GitHub · 267 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 267 lines · 130 tokens per session scan A 57ad482527ba

Subscribe to this mod's changes

grok-oauth-router is a skill published in the GitHub repository Moore-developers/grok-cli (52 stars, last pushed 19d ago), licensed MIT. It adds 130 tokens to every session and 2,216 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

next-cache-components-adoption

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…

vercel/next.js · 95 tokens

babysit-pr

Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep…

openai/codex · 114 tokens

imagegen

Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output…

openai/codex · 113 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

next-cache-components-optimizer

Drive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route at a time; the shipped test then…

vercel/next.js · 170 tokens