# grok-cli

Adopt this skill: https://proskills.md/skills/other/tern-grok-cli-skills-grok-cli

Page: https://proskills.md/skills/other/tern-grok-cli-skills-grok-cli
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: grok-cli/SKILL.md
size: 3677
upstream: https://github.com/tern/grok-cli-skills/blob/main/grok-cli/SKILL.md

````text
---
name: grok-cli
description: Use the locally installed Grok CLI (`grok`) for headless one-shot prompts, repo-aware coding/review prompts, model listing, and lightweight automation on this machine. Trigger when the user explicitly asks to use Grok CLI / grok-cli / `grok`, wants a local Grok run instead of OpenClaw's built-in xAI tools, wants a prompt executed inside Grok against a working directory, or wants Grok CLI-specific behavior like `grok -p`, `grok models`, or resuming a Grok session.
---

# Grok CLI

Use the local `grok` binary on this machine for direct Grok CLI workflows.

## Installed facts for this machine

- Binary path: `/home/deck/.nvm/versions/node/v22.22.0/bin/grok`
- Verified working version: `1.0.0-rc5`
- Basic headless prompt works: `grok -p "Reply with exactly: GROK_CLI_OK"`
- Default workspace to use unless the user specifies another path: `/home/deck/.openclaw/workspace`

## Default behavior

Prefer **headless mode** for agent use:

- Use `grok -p "..."` for one-shot prompts
- Add `-d <dir>` when repo context matters
- Use `--format text` unless machine-readable output is explicitly useful
- Use `--format json` only when you plan to parse structured events

Avoid launching the interactive TUI unless the user explicitly wants the TUI.

## Safe command patterns

### 1) Version / sanity check

```bash
grok -V
grok models
```

### 2) One-shot Q&A or summaries

```bash
grok -p "Summarize the purpose of this repository in 5 bullets." -d /path/to/repo --format text
```

### 3) Repo-aware coding or review prompt

```bash
grok -p "Review the current codebase and list the top 5 risks." -d /path/to/repo --format text
```

### 4) Structured output for downstream parsing

```bash
grok -p "Summarize the repo state" -d /path/to/repo --format json
```

### 5) Resume a Grok session

```bash
grok -s latest
grok -s <session-id>
```

Use session resume only when the user explicitly wants to continue prior Grok CLI context.

## Working directory rules

- Always set `-d` / `--directory` when the task is about a specific repo or folder.
- Default to `/home/deck/.openclaw/workspace` if the user does not specify a path.
- If the task references another repo, resolve the path first and then pass it explicitly.

## Output handling

- Grok CLI may print cosmetic ANSI color codes or a session line before the final answer.
- When relaying results to the user, strip terminal noise and return the useful answer.
- If the user asks for raw output, provide it explicitly.

## Suggested exec usage

Prefer the bundled wrapper for text mode so output is clean:

```bash
/home/deck/.openclaw/workspace/skills/grok-cli/scripts/grok-headless-clean.sh \
  --prompt "<prompt>" \
  --dir /some/path
```

Use raw `grok` directly when you need native behavior such as `grok models`, `grok -V`, or explicit session resume.

If a run may take longer, give `exec` a larger `yieldMs` or poll the spawned process instead of tight loops.

## Bundled resources

- Script: `scripts/grok-headless-clean.sh`
  - Use for headless text prompts with ANSI/progress/session noise stripped
  - Supports `--prompt`, `--dir`, `--format`, `--model`, `--session`
- Reference: `references/usage.md`
  - Read when you need prompt templates, common command patterns, or model-selection hints

## When not to use this skill

Do not use Grok CLI when OpenClaw first-class tools are better:

- Use `web_search` for ordinary web research
- Use `x_search` for X/Twitter search
- Use `image_generate` / `image` for OpenClaw-native image flows

Use this skill when the user specifically wants the **local Grok CLI** behavior, session model, or repo-aware headless prompt execution.
````

## File: README.md
upstream: https://github.com/tern/grok-cli-skills/blob/main/README.md

````text
# grok-cli-skills

Standalone skill bundles for using the local **Grok CLI** in clean, headless, repo-aware workflows.

This repository packages reusable skill variants for both OpenClaw and Codex that help an agent:

- run `grok -p` headless prompts
- target a specific repository with `--dir`
- strip ANSI/session/progress noise from text output
- reuse prompt templates for repo summaries, code review, bug triage, and refactor planning

## Why this exists

OpenClaw and Codex already have strong built-in tools, but sometimes you specifically want the **local Grok CLI** behavior on your own machine:

- use the installed `grok` binary directly
- run repo-aware prompts against a local working tree
- keep behavior aligned with Grok CLI sessions and models
- wrap Grok CLI in a cleaner headless workflow for agent use

This repo isolates that workflow into small skills that can be installed, shared, and versioned separately.

## Source / upstream

These skills are built **for** the local Grok CLI and document how to use it from OpenClaw or Codex.

Upstream Grok CLI project:
- <https://github.com/superagent-ai/grok-cli>

This repository is **not** the Grok CLI itself. It is a companion skill bundle for using that CLI more effectively.

## Contents

- `grok-cli/` — OpenClaw skill
- `codex/grok-cli/` — Codex skill
- `grok-cli/SKILL.md` — OpenClaw trigger description and operating instructions
- `codex/grok-cli/SKILL.md` — Codex trigger description and operating instructions
- `grok-cli/scripts/grok-headless-clean.sh` — OpenClaw wrapper that removes ANSI/session/progress noise
- `codex/grok-cli/scripts/grok-headless-clean.sh` — Codex wrapper that removes ANSI/session/progress noise
- `grok-cli/references/usage.md` — OpenClaw prompt templates, examples, and model-selection notes
- `codex/grok-cli/references/usage.md` — Codex prompt templates, examples, and model-selection notes
- `dist/grok-cli.skill` — packaged skill artifact for distribution

## Install

### Option A — use the packaged `.skill` artifact

Download the latest release asset:
- `grok-cli.skill`

Then install it with your preferred OpenClaw skill workflow.

### Option B — copy the skill folder manually

For OpenClaw:

Copy the `grok-cli/` directory into your skills location and reload/refresh skills in your OpenClaw environment.

For Codex:

Copy `codex/grok-cli/` into your Codex skills location, typically `~/.codex/skills/grok-cli/`.

## Requirements

- OpenClaw or Codex
- A local `grok` CLI installation on PATH
- Valid Grok/xAI credentials configured for the CLI

This skill was verified on a machine where:

- `grok -V` returned `1.0.0-rc5`
- `grok models` worked
- headless prompt execution worked via `grok -p ...`

## Example usage

OpenClaw wrapper script:

```bash
./grok-cli/scripts/grok-headless-clean.sh \
  --prompt "Summarize this repo in 5 bullets" \
  --dir /path/to/repo
```

Codex wrapper script:

```bash
./codex/grok-cli/scripts/grok-headless-clean.sh \
  --prompt "Summarize this repo in 5 bullets" \
  --dir /path/to/repo
```

Raw Grok CLI:

```bash
grok -p "Review this codebase and list top risks" -d /path/to/repo --format text
```

## Release artifacts

Each release may include:

- packaged `.skill` file for import/distribution
- source files for manual inspection or installation

## License

MIT
````
