### Plugin catalog example
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/09-plugins.md
Optional plugin-index.json catalog that lets the marketplace browser show plugin components before installation.
```json
{
"version": 1,
"plugins": {
"gdrive": {
"components": {
"skills": [{ "name": "gdrive", "description": "Google Drive access" }]
}
}
}
}
```
--------------------------------
### Add marketplace and install plugin
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/09-plugins.md
Commands to add a marketplace and install a plugin from it, with trust.
```bash
grok plugin marketplace add my-org/my-org-plugins # GitHub shorthand, a git URL, or a local path
grok plugin install gdrive --trust
```
--------------------------------
### Install released binary and check version
Source: https://github.com/asayeed95/asec-grok/blob/main/README.md
Install the prebuilt binary for macOS, Linux, or Windows (Git Bash) and verify the installation with grok --version.
```sh
curl -fsSL https://x.ai/cli/install.sh | bash # macOS / Linux / Git Bash
irm https://x.ai/cli/install.ps1 | iex # Windows PowerShell
grok --version
```
--------------------------------
### Marketplace index example
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/09-plugins.md
Example marketplace.json file that names the marketplace and lists each plugin with its source.
```json
{
"name": "My Org Plugins",
"description": "Internal skills and tools",
"owner": { "name": "Platform Team", "email": "platform@example.com" },
"plugins": [
{
"name": "gdrive",
"description": "Search and edit Google Drive, Docs, Sheets, and Slides",
"category": "productivity",
"source": { "type": "local", "path": "./plugins/gdrive" }
}
]
}
```
--------------------------------
### Start Grok
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/01-getting-started.md
Starts Grok for the first time. On first launch, it opens the browser to authenticate with grok.com and stores credentials in ~/.grok/auth.json.
```bash
grok
```
--------------------------------
### /loop command examples
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/20-background-tasks.md
Example /loop commands with different intervals. The prompt fires immediately on creation, then repeats at the specified interval.
```text
/loop 5m Check if the test suite passes and report any failures
/loop 2h Summarize new commits since the last check
/loop 60s Check if the dev server at localhost:3000 is responding
```
--------------------------------
### Verify installation
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/01-getting-started.md
Verifies the installation by checking the installed version of Grok.
```bash
grok --version
```
--------------------------------
### Install xai-crash-handler and check previous crash
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-crash-handler/README.md
Initialize the crash handler: call check_previous_crash() before install() because install() opens last-crash.bin with O_TRUNC. Install before spawning threads or an async runtime since sigaltstack is per-thread. Creates crash_dir if it does not exist.
```rust
use std::path::PathBuf;
let crash_dir = PathBuf::from("/home/user/.myapp/crash");
// check_previous_crash MUST be called before install(), because
// install() opens last-crash.bin with O_TRUNC.
if let Some(r) = xai_crash_handler::check_previous_crash(&crash_dir) {
eprintln!("Crashed last session: {}", r.signal_name);
eprintln!("Report: {}", r.report_path.display());
}
// install() before any threads or async runtime — sigaltstack is per-thread.
// Creates crash_dir if it does not exist.
xai_crash_handler::install(xai_crash_handler::CrashHandlerConfig {
app_version: env!("CARGO_PKG_VERSION").to_string(),
crash_dir,
});
```
--------------------------------
### Style guide in AGENTS.md
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/12-project-rules.md
Example AGENTS.md content for style guides. Specifies Airbnb style, 2-space indentation, trailing commas, and template literals.
```markdown
# Style Guide
- Follow the Airbnb JavaScript Style Guide
- Use 2-space indentation
- Always use trailing commas in multi-line arrays/objects
- Prefer template literals over string concatenation
```
--------------------------------
### Browse docs with /docs
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/04-slash-commands.md
Use /docs to browse built-in How-to Guides, open online docs, or jump to a specific guide by title. Bare /docs opens the picker, /docs web opens the online docs, and /docs
opens a specific guide.
```text
/docs
/docs web
/docs Getting Started
```
--------------------------------
### Plain output example
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/14-headless-mode.md
Example of the default human-readable output format, suitable for direct display or piping.
```text
Here's a summary of the codebase...
```
--------------------------------
### Install Grok CLI with npm
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/npm/grok/README.md
Install Grok CLI globally via npm.
```bash
npm i -g @xai-official/grok
```
--------------------------------
### Start, Resume, and Create Session with UUID
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/14-headless-mode.md
Shows how to start a headless session, resume it with -r, and create a new session with a client-chosen UUID. The -s flag requires a valid UUID and errors if already in use.
```bash
grok -p "Review the changes in this PR" --output-format json | jq -r '.sessionId'
```
```bash
grok -p "Now check for security issues" --resume ""
```
```bash
grok -p "hello" --session-id "$(uuidgen | tr '[:upper:]' '[:lower:]')" --output-format json
```
--------------------------------
### Slash Commands for Quick Actions
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/01-getting-started.md
Slash commands are typed in the prompt to perform quick actions without writing a full prompt. The example shows commands for switching models, compressing history, toggling approval mode, and starting a new session.
```plaintext
/model grok-build # Switch model
/compact # Compress conversation history
/always-approve # Toggle always-approve mode
/new # Start a new session
```
--------------------------------
### Start a new session with /new
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/17-sessions.md
Starts a fresh conversation by clearing the current context. Alias: /clear.
```text
/new
```
--------------------------------
### Install @xai-official/grok
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/npm/grok-darwin-arm64/README.md
Install the main package globally. The platform-specific binary for darwin-arm64 is pulled automatically via optionalDependencies.
```sh
npm install -g @xai-official/grok
```
--------------------------------
### Install Tool Activity Logger Hook
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-hooks/examples/README.md
Install the Tool Activity Logger hook by copying its JSON configuration and shell script to the hooks directory and making the script executable.
```sh
mkdir -p ~/.grok/hooks/bin
cp examples/hooks/tool-logger.json ~/.grok/hooks/
cp examples/hooks/bin/tool-logger.sh ~/.grok/hooks/bin/
chmod +x ~/.grok/hooks/bin/tool-logger.sh
```
--------------------------------
### /imagine command example
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/04-slash-commands.md
Generates an image from a text description. Use the format /imagine .
```text
/imagine a golden sunset over a calm ocean with silhouetted palm trees
```
--------------------------------
### /imagine-video command example
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/04-slash-commands.md
Generates a video from a text or image description. Plans shots, generates source images, and animates them with image_to_video.
```text
/imagine-video a cat playing piano in a jazz club
```
--------------------------------
### Use Background to Start Dev Server and Continue Coding
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/20-background-tasks.md
Initiates a background task with the dev server and continues coding.
```text
Start the dev server with `npm run dev` in the background, then implement the login form.
```
--------------------------------
### monitor tool example commands
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/20-background-tasks.md
Example shell commands for the monitor tool. Always use grep --line-buffered in pipes to avoid buffering delays. Handle transient failures in poll loops and use selective filters to avoid generating too many events.
```bash
# Watch for errors in a log file
tail -f /var/log/app.log | grep --line-buffered "ERROR"
# Monitor file changes in a directory
inotifywait -m --format '%e %f' /watched/dir
# Poll GitHub for new PR comments
last=$(date -u +%Y-%m-%dT%H:%M:%SZ)
while true; do
now=$(date -u +%Y-%m-%dT%H:%M:%SZ)
gh api "repos/owner/repo/issues/123/comments?since=$last" \
--jq '.[] | "\(.user.login): \(.body)"'
last=$now; sleep 30
done
```
--------------------------------
### Roll a marketplace out to everyone in managed_config.toml
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/09-plugins.md
Add a marketplace source and enable plugins in managed_config.toml. Plugins stay off until enabled; list plugin names or full IDs. For hands-off install, place plugin files in ~/.grok/plugins/ or a managed path and enable them.
```toml
[[marketplace.sources]]
name = "My Org Plugins"
git = "https://github.com/my-org/my-org-plugins.git"
# Plugins stay off until enabled. List plugin names (from `grok plugin list`)
# or full IDs (`//`).
[plugins]
enabled = ["gdrive"]
```
--------------------------------
### Install specific version
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/01-getting-started.md
Installs a specific version of Grok Build (0.1.42) using the bash installer.
```bash
curl -fsSL https://x.ai/cli/install.sh | bash -s 0.1.42
```
--------------------------------
### Install cargo-fuzz and nightly toolchain
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-markdown/fuzz/README.md
Install cargo-fuzz and the nightly Rust toolchain, which are required for fuzzing the markdown renderer.
```bash
cargo install cargo-fuzz # if not already installed
rustup toolchain install nightly
```
--------------------------------
### SKILL.md format with YAML frontmatter
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/08-skills.md
Example of a SKILL.md file with YAML frontmatter and markdown instructions. The frontmatter includes name and description fields.
```markdown
---
name: commit
description: Create well-formatted git commits following conventional commit standards. Use when the user wants to commit changes or asks for /commit.
---
# Git Commit Skill
Review staged changes and create a commit with a clear, conventional message.
## Steps
1. Run `git diff --staged` to see changes
2. Summarize what changed and why
3. Create commit message following conventional commits format
4. Run `git commit -m "..."` with the message
```
--------------------------------
### CLI: Start with always-approve mode
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/22-permissions-and-safety.md
Use these commands to run Grok in always-approve mode, which skips permission prompts. The first runs a one-off prompt, the second starts an agent over stdio, and the third starts an agent server bound to a local address.
```bash
grok -p "Run the tests" --always-approve
grok agent --always-approve stdio
grok agent --always-approve serve --bind 127.0.0.1:2419 --secret
```
--------------------------------
### Install plugin with trust
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/09-plugins.md
Use the --trust flag to grant trust when installing a plugin, which is required for project plugins in .grok/plugins/.
```bash
grok plugin install --trust
```
--------------------------------
### Install specific version (PowerShell)
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/01-getting-started.md
Installs a specific version of Grok Build (0.1.42) on Windows using the PowerShell installer.
```powershell
$env:GROK_VERSION="0.1.42"; irm https://x.ai/cli/install.ps1 | iex
```
--------------------------------
### AGENTS.md example
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/tutorial/08-make-it-yours.md
Drop this AGENTS.md file in your repo root to teach Grok your project's build commands, conventions, and gotchas. Grok reads it automatically in every session.
```markdown
# My Project
- Run tests with `pnpm test`
- Never edit files under generated/
```
--------------------------------
### List all available models with `grok models`
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/11-custom-models.md
Use this command to list all available models, both built-in and custom. This is useful for verifying which models are accessible before starting a session.
```bash
grok models
```
--------------------------------
### Install latest stable release (PowerShell)
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/01-getting-started.md
Installs the latest stable release of Grok Build on Windows using the native PowerShell installer.
```powershell
irm https://x.ai/cli/install.ps1 | iex
```
--------------------------------
### Build and test instructions in AGENTS.md
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/12-project-rules.md
Example AGENTS.md content for build and test instructions. Includes npm test, lint, build, and e2e test commands, noting Docker requirement for integration tests.
```markdown
# Build & Test
- Run `npm test` before committing
- Use `npm run lint` to check code style
- Build with `npm run build` -- ensure no TypeScript errors
- Integration tests: `npm run test:e2e` (requires Docker)
```
--------------------------------
### Claude Code settings.json permissions example
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/22-permissions-and-safety.md
Example of a `.claude/settings.json` file with `permissions` configuration. `defaultMode` supports values like `default`, `auto`, `acceptEdits`, `bypassPermissions`, `dontAsk`, and `plan`. `permissions.allow`, `deny`, and `ask` entries are translated into native rules; MCP rules must use the `MCPTool(server__tool)` form, and unrecognized tools or parameter rules are skipped with a warning.
```json
{
"permissions": {
"defaultMode": "dontAsk",
"allow": [
"Read",
"Grep",
"Bash(git *)",
"Bash(gh *)"
],
"deny": [
"Bash(rm -rf *)"
]
}
}
```
--------------------------------
### Pipe curl installation script to grep
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/tests/fixtures/historic_bash_cmds.txt
Downloads a script from x.ai and pipes it to grep for lines containing 'jq'. Useful for verifying script content.
```bash
curl -fsSL x.ai/cli/install.sh | grep jq
```
--------------------------------
### Configure [hints] table for UI preferences
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/05-configuration.md
Example of the [hints] table in a TOML configuration file. Grok writes these keys to your user ~/.grok/config.toml as you use the TUI; you can edit or delete them by hand, and removing a key restores the default. The table is read from the effective config merge with precedence: system managed → user managed_config.toml → user config.toml → user requirements.toml → system requirements.toml, higher layers winning.
```toml
[hints]
memory_modal_fullscreen = false # remember the memory modal fullscreen state
new_session_worktree_mode = "never" # /new worktree prompt: "ask" | "always" | "never"
fork_worktree_mode = "ask" # /fork worktree prompt: "ask" | "always" | "never"
```
--------------------------------
### JSON output example
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/14-headless-mode.md
Example of the JSON output format, showing response text, stop reason, session ID, request ID, and spend fields including usage, modelUsage, and total cost.
```json
{
"text": "Here's a summary of the codebase...",
"stopReason": "end_turn",
"sessionId": "abc123",
"requestId": "xyz789",
"num_turns": 7,
"usage": {
"input_tokens": 7210,
"cache_read_input_tokens": 41000,
"cache_creation_input_tokens": 0,
"output_tokens": 1893,
"reasoning_tokens": 412,
"total_tokens": 50103
},
"modelUsage": {
"grok-build": {
"inputTokens": 7210,
"outputTokens": 1893,
"cacheReadInputTokens": 41000,
"modelCalls": 7,
"costUSD": 0.01268905
}
},
"total_cost_usd": 0.01268905,
"total_cost_usd_ticks": 126890500
}
```
--------------------------------
### Install and verify DotSlash
Source: https://github.com/asayeed95/asec-grok/blob/main/README.md
Install DotSlash and verify it is on PATH before building. Required for hermetic tools under bin/ (notably bin/protoc).
```sh
cargo install dotslash
# or: prebuilt packages — https://dotslash-cli.com/docs/installation/
/usr/bin/env dotslash --help # sanity check
```
--------------------------------
### Start agent server mode
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/15-agent-mode.md
Starts the agent in server mode, listening on 127.0.0.1:2419. Clients connect over WebSocket and authenticate with the provided secret token. If --secret is omitted, the agent prints a generated token at startup or uses the GROK_AGENT_SECRET environment variable.
```bash
grok agent --always-approve serve --bind 127.0.0.1:2419 --secret
```
--------------------------------
### Start Grok agent with always-approve
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/15-agent-mode.md
Start Grok in agent mode with always-approve for automation. The first uses stdio transport for local processes and many SDKs; the second starts a WebSocket server bound to 127.0.0.1:2419 with a secret token. Deny rules and hooks still apply.
```bash
grok agent --always-approve stdio
```
```bash
grok agent --always-approve serve --bind 127.0.0.1:2419 --secret
```
--------------------------------
### Test MCP server and increase startup timeout
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/07-mcp-servers.md
Test the server command manually and increase the startup timeout in config.toml if the server is not starting.
```bash
npx -y @modelcontextprotocol/server-filesystem /path
```
```toml
[mcp_servers.filesystem]
startup_timeout_sec = 30
```
--------------------------------
### Install Safe Shell Guard Hook
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-hooks/examples/README.md
Install the Safe Shell Guard hook by copying its JSON configuration and guard script to the hooks directory and making the script executable. Requires the hooks directory to exist, hence the mkdir command.
```sh
mkdir -p ~/.grok/hooks/bin
cp examples/hooks/safe-shell.json ~/.grok/hooks/
cp examples/hooks/bin/safe-shell-guard.sh ~/.grok/hooks/bin/
chmod +x ~/.grok/hooks/bin/safe-shell-guard.sh
```
--------------------------------
### Create hooks directory and SessionStart hook configuration
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/10-hooks.md
Creates the hooks directory and a sample SessionStart hook configuration that runs a shell command when a Grok session starts. The hook file is placed at ~/.grok/hooks/session-start.json.
```sh
mkdir -p ~/.grok/hooks
```
```json
{
"hooks": {
"SessionStart": [
{
"hooks": [
{ "type": "command", "command": "echo 'Grok session started in '$(pwd)" }
]
}
]
}
}
```
--------------------------------
### Install Stop Gate Hook
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-hooks/examples/README.md
Install the Stop Gate hook by copying its JSON configuration and shell script to the hooks directory and making the script executable. The hook sets a 300-second timeout because a timed-out Stop hook fails open and lets the agent stop.
```sh
mkdir -p ~/.grok/hooks/bin
cp examples/hooks/stop-verify.json ~/.grok/hooks/
cp examples/hooks/bin/stop-verify.sh ~/.grok/hooks/bin/
chmod +x ~/.grok/hooks/bin/stop-verify.sh
```
--------------------------------
### Install a plugin with trust
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/09-plugins.md
Installs a plugin named 'deploy-tools' with the --trust flag to bypass the trust warning. Without --trust, Grok shows the source and warns about hooks, MCP servers, and skills, then stops.
```bash
grok plugin install deploy-tools --trust
```
--------------------------------
### AGENTS.md directory tree scoping example
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/12-project-rules.md
Shows how AGENTS.md files in subdirectories scope rules to their directory tree, allowing different instructions for different parts of a monorepo.
```text
my-monorepo/
AGENTS.md # Monorepo-wide rules
packages/
frontend/
AGENTS.md # "Use React. Prefer CSS modules."
backend/
AGENTS.md # "Use Express. Follow REST conventions."
shared/
AGENTS.md # "No framework-specific code in this package."
```
--------------------------------
### PromQL queries for token usage, sessions, and tool decisions
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/24-monitoring-usage.md
Example PromQL queries to run against the Prometheus exporter. They compute the 1-hour token usage rate by model and type, the daily session count per team, and the tool-permission denial ratio.
```promql
# Tokens by model and type across the org, 1h rate
sum by (model, type) (rate(grok_code_token_usage_total[1h]))
# Sessions per team per day
sum by (team_id) (increase(grok_code_session_count_total[1d]))
# Tool-permission denial ratio
sum(rate(grok_code_tool_decision_total{decision="deny"}[1h]))
/ sum(rate(grok_code_tool_decision_total[1h]))
```
--------------------------------
### Install No Recursive Grep Hook
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-hooks/examples/README.md
Install the No Recursive Grep hook by copying its JSON configuration and Python guard script to the hooks directory and making the script executable. Requires python3 on PATH.
```sh
mkdir -p ~/.grok/hooks/bin
cp examples/hooks/no-recursive-grep.json ~/.grok/hooks/
cp examples/hooks/bin/no-recursive-grep-guard.py ~/.grok/hooks/bin/
chmod +x ~/.grok/hooks/bin/no-recursive-grep-guard.py
```
--------------------------------
### Install Session Audit Log Hook
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-hooks/examples/README.md
Install the Session Audit Log hook by copying its JSON configuration and shell script to the hooks directory and making the script executable.
```sh
mkdir -p ~/.grok/hooks/bin
cp examples/hooks/session-log.json ~/.grok/hooks/
cp examples/hooks/bin/session-log.sh ~/.grok/hooks/bin/
chmod +x ~/.grok/hooks/bin/session-log.sh
```
--------------------------------
### Hook configuration with timeout
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/10-hooks.md
Example of a hook configuration entry with an explicit timeout for a command hook.
```json
{ "type": "command", "command": "bin/verify.sh", "timeout": 1200 }
```
--------------------------------
### grok du output example
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/17-sessions.md
Example output of `grok du` (alias `grok disk-usage`) showing disk usage for ~/.grok, including worktrees, sessions, and top-level files. It also includes guidance on reclaiming space with `grok worktree gc --max-age 7d --dry-run` and `grok worktree rm --dry-run `. Note that worktree clones share storage with their source, so the total can exceed real disk use.
```text
Disk usage for ~/.grok
412.3 GB worktrees
1.2 GB sessions
412.0 MB (top-level files)
413.9 GB total
Worktree clones share storage with their source, so the total can exceed real disk use.
Worktrees
SIZE TYPE AGE LABEL PATH
380.0 GB session 12d ago my-fix ~/.grok/worktrees/xai/worktree-abc
32.3 GB untracked (session) 40d ago ~/.grok/worktrees/xai/worktree-old
To reclaim space, run `grok worktree gc --max-age 7d --dry-run`, then the same command without `--dry-run`. Without `--max-age`, gc expires nothing.
Untracked rows are not in the registry, so gc never visits them. Remove one with `grok worktree rm --dry-run `, then without `--dry-run`.
```
--------------------------------
### Pipe curl installation script to bash
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/tests/fixtures/historic_bash_cmds.txt
Downloads a script from an internal file server and pipes it directly to bash for execution.
```bash
curl -LsSf "http://file-server.example.internal/cicd/example/install.sh?nocache" | bash
```
--------------------------------
### Build and run xai-grok-pager from source
Source: https://github.com/asayeed95/asec-grok/blob/main/README.md
Build and run the TUI from source. The release binary is named xai-grok-pager; official installs ship it as grok. On first launch it opens your browser to authenticate.
```sh
cargo run -p xai-grok-pager-bin # build + launch the TUI
cargo build -p xai-grok-pager-bin --release # release binary: target/release/xai-grok-pager
cargo check -p xai-grok-pager-bin # fast validation
```
--------------------------------
### Open tutorial with /tutorial
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/04-slash-commands.md
Use /tutorial to open the onboarding tutorial, a short list of topics each about a 30-second read. Nothing auto-shows; this command or the command palette is the way in.
```text
/tutorial
```
--------------------------------
### Start background research with /deep-research
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/04-slash-commands.md
Kick off a background research workflow that plans questions, gathers claims with evidence, and cross-checks on independent verifier shards. Returns immediately; progress is tracked in /workflows and the final report appears in the conversation. Reports are marked Partial if any coverage limitations remain.
```text
/deep-research Compare the migration risks of PostgreSQL 17 and MySQL 9
```
--------------------------------
### Select a model with the `-m` CLI flag
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/11-custom-models.md
Use the `-m` flag with the `grok` command to start a session with a specific model, such as `grok-build`. This overrides the default model for that session.
```bash
grok -p "Hello" -m grok-build
```
--------------------------------
### /loop command examples
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/04-slash-commands.md
Runs a prompt on a recurring interval. Provide interval as 30m, 1 hour, or every 2 days; omit to let Grok ask. Intervals are Ns (seconds, min 60), Nm (minutes), Nh (hours), or Nd (days); under 60 seconds is raised to minimum. Recurring tasks expire after 7 days and can be cancelled with scheduler_delete using the job ID.
```text
/loop 30m check deploy status
```
```text
/loop check deploy status every hour
```
--------------------------------
### Agent options with model and serve flags
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/15-agent-mode.md
Show agent options applied before the mode name. The first selects the grok-build model with stdio; the second starts a WebSocket server with serve --bind and --secret. Mode-specific flags go after the mode.
```bash
grok agent --always-approve --model grok-build stdio
```
```bash
grok agent --always-approve serve --bind 127.0.0.1:2419 --secret
```
--------------------------------
### Config: Set permission mode
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/22-permissions-and-safety.md
Set the default permission mode in the configuration file. The example sets it to always-approve, with alternatives commented.
```toml
[ui]
permission_mode = "always-approve" # or "auto", "ask", …
```
--------------------------------
### Start Grok session in a worktree
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/tutorial/06-worktrees.md
Start a new Grok session in a separate git worktree named my-feature. Use the equals sign (=) after --worktree; otherwise the prompt is taken as the worktree name.
```bash
grok --worktree=my-feature "refactor the auth module"
```
--------------------------------
### Launch Grok TUI or run a single task
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/npm/grok/README.md
Start the interactive TUI or run a single task with the -p flag.
```bash
# Launch the interactive TUI
grok
# Run a single task
grok -p "Explain this codebase"
```
--------------------------------
### Coding conventions in AGENTS.md
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/12-project-rules.md
Example AGENTS.md content for coding conventions. Lists TypeScript usage, functional components, const/let preference, and a 100-character line limit.
```markdown
# Coding Standards
- Use TypeScript for all new code
- Prefer functional components with hooks over class components
- Use `const` by default; only use `let` when reassignment is needed
- Maximum line length: 100 characters
```
--------------------------------
### Example hook file JSON configuration
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-hooks/examples/README.md
Claude-compatible hook file config with a PreToolUse hook matching Bash, running bin/check.sh with a 5-second timeout. Event names (SessionStart, PreToolUse, PostToolUse, Stop, SubagentStop, SessionEnd) and matcher regexes are supported; Claude tool names like Bash are auto-expanded to also match Grok names (run_terminal_cmd, read_file, search_replace). Timeout is in seconds, default 5.
```json
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{ "type": "command", "command": "bin/check.sh", "timeout": 5 }
]
}
]
}
}
```
--------------------------------
### Enter plan mode with /plan
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/04-slash-commands.md
Use /plan to enter plan mode. An optional description can be provided.
```text
/plan [description]
```
--------------------------------
### MCP server configuration in TOML
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/05-configuration.md
Configures external tool integrations over the Model Context Protocol. Includes examples for command-based servers (GitHub, Postgres) and an HTTP/SSE transport server with headers.
```toml
[mcp_servers.github]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-github"]
env = { GITHUB_PERSONAL_ACCESS_TOKEN = "ghp_xxx" }
enabled = true # enable/disable (default: true)
startup_timeout_sec = 30 # init timeout in seconds (default: 30)
tool_timeout_sec = 6000 # tool call timeout in seconds (default: 6000)
tool_timeouts = { create_issue = 120 } # per-tool timeout overrides
[mcp_servers.postgres]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-postgres", "postgresql://user:pass@localhost/db"]
[mcp_servers.my-streamable-server]
url = "https://mcp.example.com/api/mcp" # HTTP/SSE transport
headers = { "x-mcp-session-id" = "{{session_id}}" }
```
--------------------------------
### Configure local stdio MCP servers
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/07-mcp-servers.md
Configure local stdio MCP servers using the `command` and `args` form. Includes filesystem access, local Postgres, and a custom server with startup and per-tool timeouts. On Windows, bare commands like `npx` are resolved to their real launcher path (honoring `PATHEXT`); absolute paths or paths with separators are used as-is.
```toml
# Filesystem access scoped to a directory
[mcp_servers.filesystem]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/directory"]
# Local Postgres
[mcp_servers.postgres]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-postgres", "postgresql://user:pass@localhost/db"]
# Custom server with a longer startup timeout and tuned per-tool timeouts
[mcp_servers.my-tools]
command = "/usr/local/bin/my-mcp-server"
args = ["--config", "/etc/my-mcp.json"]
startup_timeout_sec = 30
tool_timeout_sec = 120
tool_timeouts = { slow_analysis = 300, quick_lookup = 10 }
```
--------------------------------
### Architecture notes in AGENTS.md
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/12-project-rules.md
Example AGENTS.md content for architecture notes. Defines directory responsibilities and a rule against importing routes in services.
```markdown
# Architecture
- API routes go in `src/routes/` with one file per resource
- Business logic goes in `src/services/`
- Database queries go in `src/repositories/`
- Never import from `src/routes/` in `src/services/`
```
--------------------------------
### PR and commit requirements in AGENTS.md
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/12-project-rules.md
Example AGENTS.md content for PR and commit requirements. Covers conventional commits, branch prefixes, PR approval, and squash-merge policy.
```markdown
# Version Control
- Write commit messages in conventional commits format
- Prefix branch names with `feature/`, `fix/`, or `chore/`
- All PRs require at least one approval before merge
- Squash-merge feature branches
```
--------------------------------
### Project structure with AGENTS.md files
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/12-project-rules.md
Shows a sample project tree with AGENTS.md files at the root, src/, and components/ directories. Grok loads all three when running in the components directory, accumulating instructions from each.
```text
~/projects/my-app/
AGENTS.md # "Use TypeScript. Follow ESLint rules."
src/
AGENTS.md # "Prefer functional components."
components/
AGENTS.md # "Use CSS modules for styling."
```
--------------------------------
### Streaming messages JSON example
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/14-headless-mode.md
Example of the JSON streaming messages emitted by Grok in headless mode, showing the four message types: system/init, assistant, user, and result. The example includes real data for session_id, model, tools, and usage fields.
```json
{"type":"system","subtype":"init","session_id":"abc123","apiKeySource":"user","model":"grok-build","cwd":"/repo","permissionMode":"default","tools":["read_file","bash"],"slash_commands":["review"],"mcp_servers":[{"name":"linear","status":"connected"}],"skills":[],"uuid":"..."}
{"type":"assistant","message":{"id":"msg_0","type":"message","role":"assistant","model":"grok-build","content":[{"type":"text","text":"Let me read the file."},{"type":"tool_use","id":"call_1","name":"read_file","input":{"path":"src/main.rs"}}],"stop_reason":"tool_use","stop_sequence":null,"usage":{...}},"parent_tool_use_id":null,"session_id":"abc123","uuid":"..."}
{"type":"user","message":{"role":"user","content":[{"type":"tool_result","tool_use_id":"call_1","content":"fn main() {}","is_error":false}]},"parent_tool_use_id":null,"session_id":"abc123","uuid":"..."}
{"type":"result","subtype":"success","is_error":false,"duration_ms":0,"duration_api_ms":0,"num_turns":7,"result":"Here's a summary...","stop_reason":"end_turn","total_cost_usd":0.0127,"usage":{"input_tokens":812,"output_tokens":210,"cache_read_input_tokens":0,"cache_creation_input_tokens":0,"server_tool_use":{"web_search_requests":0}},"modelUsage":{},"session_id":"abc123","uuid":"..."}
```
--------------------------------
### Manage plugins from the command line
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/09-plugins.md
Lists all plugin management commands: list, uninstall, update, enable, disable, and details. The list command supports --json and --available flags; uninstall has --confirm and --keep-data flags.
```bash
grok plugin list [--json] [--available] # installed plugins (--available requires --json)
grok plugin uninstall [--confirm] [--keep-data] # aliases: rm, remove
grok plugin update [] # omit the name to update every plugin
grok plugin enable
grok plugin disable
grok plugin details # show the plugin's component inventory
```
--------------------------------
### CI/CD usage with JSON output and jq
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/01-getting-started.md
Example CI/CD usage: run Grok headless with JSON output and auto-approve all tool executions, then pipe to jq to extract the text field. The JSON output is a single object with text, stopReason, sessionId, and requestId.
```bash
grok -p "Review changes for bugs" --output-format json --yolo | jq -r '.text'
```
--------------------------------
### Configure stdio MCP server in config.toml
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/07-mcp-servers.md
Configure a local MCP server using the stdio transport. Grok spawns the process and communicates over stdin/stdout. The `enabled` flag defaults to true, `startup_timeout_sec` defaults to 30, and `tool_timeout_sec` defaults to 6000. Per-server `startup_timeout_sec` takes precedence over the global `MCP_TIMEOUT` or `GROK_MCP_STARTUP_TIMEOUT_SECS` environment variables.
```toml
[mcp_servers.my-server]
command = "/path/to/server" # Server executable
args = ["--flag", "value"] # Command arguments
env = { API_KEY = "sk-..." } # Environment variables
enabled = true # Enable or disable the server (default: true)
startup_timeout_sec = 30 # Server startup timeout, seconds (default: 30)
tool_timeout_sec = 6000 # Per-tool-call timeout fallback, seconds (default: 6000)
tool_timeouts = { slow_op = 120 } # Per-tool timeout overrides, seconds
```
--------------------------------
### Install latest stable release
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/01-getting-started.md
Installs the latest stable release of Grok Build on macOS, Linux, or Windows via Git Bash.
```bash
curl -fsSL https://x.ai/cli/install.sh | bash
```
--------------------------------
### Fork a session with /fork
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/17-sessions.md
Branches the current session into a peer agent starting from a copy of the conversation. Pass an optional directive to set the new session's first prompt. Use --worktree or --no-worktree to choose whether the fork runs in a new git worktree; omit both to be asked each time. The --at flag is not supported in this version.
```text
/fork [--worktree|--no-worktree] [directive]
```
--------------------------------
### streaming-json example: newline-delimited JSON events
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/14-headless-mode.md
Example of the streaming-json format, showing a sequence of newline-delimited JSON objects, each tagged with a type field. The example includes thought, tool_call, tool_call_update, text, usage, and end events. The end event is always last and carries final metadata.
```json
{"type":"thought","data":"Analyzing the directory structure..."}
{"type":"tool_call","toolCallId":"call_1","title":"Read","kind":"read","status":"in_progress","toolName":"read_file","rawInput":{"path":"src/main.rs"},"content":[],"locations":[]}
{"type":"tool_call_update","toolCallId":"call_1","status":"completed","content":[],"rawOutput":{"lines":42},"locations":[]}
{"type":"text","data":"Here's a summary"}
{"type":"usage","messageId":"resp_1","stopReason":"end_turn","usage":{"input_tokens":812,"output_tokens":45,"cache_read_input_tokens":0,"cache_creation_input_tokens":0,"reasoning_tokens":0},"signature":"..."}
{"type":"end","stopReason":"end_turn","sessionId":"abc123","requestId":"xyz789","usage":{...},"num_turns":7,"modelUsage":{...}}
```
--------------------------------
### JSON error output example
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/14-headless-mode.md
Example of the JSON error object emitted on failure, with a non-zero process exit. Prompt-level failures may include frozen spend fields when usage was recorded.
```json
{"type":"error","message":"Couldn't start session: ..."}
```
--------------------------------
### Still-running status line example
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/20-background-tasks.md
Example of the status line shown when background work is running while the agent looks idle. It counts running commands, monitors, loops, and subagents, updating live as each finishes.
```plaintext
◎ 1 command · 2 monitors · 1 loop · 1 subagent still running
```
--------------------------------
### settings.json: Configure extraKnownMarketplaces
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/hooks-and-plugins.md
Shows how to define a marketplace source in ~/.grok/settings.json or ~/.claude/settings.json using the extraKnownMarketplaces key with a source object and autoUpdate flag.
```json
{
"extraKnownMarketplaces": {
"my-marketplace": {
"source": { "source": "git", "url": "git@github.com:my-org/plugins.git" },
"autoUpdate": true
}
}
}
```
--------------------------------
### Configure a project-scoped MCP server in .grok/config.toml
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/07-mcp-servers.md
Shows the required project layout and a minimal .grok/config.toml that registers the Linear MCP server via its native HTTP/SSE endpoint. Prefer the url form over a stdio proxy such as npx mcp-remote because Grok handles HTTP/SSE and OAuth directly, avoiding an extra subprocess and registering Grok's own OAuth client.
```text
my-project/
.grok/
config.toml
src/
...
```
```toml
# .grok/config.toml
[mcp_servers.linear]
url = "https://mcp.linear.app/mcp"
enabled = true
```
--------------------------------
### config.toml general settings
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/05-configuration.md
Main configuration file at `~/.grok/config.toml`. If missing, built-in defaults are used. Includes CLI, models, UI, features, session, and tools sections with comments explaining defaults and behavior.
```toml
[cli]
auto_update = true # check for updates on launch
[models]
default = "grok-4.5" # model used for new sessions
web_search = "grok-4.5" # model used by the web_search tool
# Defaults applied to every model; a per-model [model.] value always wins.
# See "Custom Models" for the per-model overrides and full details.
extra_headers = { "X-Request-Tags" = "team=example,env=prod" }
temperature = 0.7
top_p = 0.95
max_completion_tokens = 8192
max_retries = 8
inference_idle_timeout_secs = 600
stream_tool_calls = true
[ui]
simple_mode = true # readline-style prompt editing (default); false = vim editing in the prompt
vim_mode = false # vim-style scrollback navigation keys (default: false)
max_thoughts_width = 120 # max column width for reasoning display
default_selected_permission = "always_allow_all_sessions" # preselected row on the FIRST approval prompt
remember_tool_approvals = false # show per-command "Always allow" options on permission prompts;
# grants are remembered per project (default: false); see 22-permissions-and-safety.md
show_thinking_blocks = true # show agent thinking blocks in the TUI (default: true)
group_tool_verbs = true # fold runs of read/search/list tool calls and subagent rows
# — and finished thoughts among them — into one row (default: true)
collapsed_edit_blocks = false # show edits as one-line +N/-M diffstat summaries and merge
# back-to-back same-file edits into one row, expand for the
# diffs (default: false; pager.toml [scrollback.blocks.edit]
# expanded_by_default/line_summary override its fold shape)
page_flip_on_send = true # pin a just-sent prompt at the top of the viewport so the
# response starts on a fresh page (default: true); set false
# so sending never moves the scroll position
screen_mode = "fullscreen" # default render mode: "fullscreen" | "minimal"
# (unset → fullscreen); set via /settings → Default screen mode
[features]
telemetry = false # anonymous usage telemetry
feedback = true # feedback system (default: true)
lsp_tools = false # expose the lsp tool
codebase_indexing = true # code graph indexing (default: true)
two_pass_compaction = false # prefire two-pass compaction (default: false, opt-in)
remote_fetch = true # allow optional online model-catalog fetches (default: true;
# set false for firewalled/air-gapped deployments; background
# managed-config sync has its own switch: managed_config)
[session]
auto_compact_threshold_percent = 85 # auto-compact at this % of context window (default: 85)
load_envrc = true # load .envrc environment variables
[tools]
respect_gitignore = false # default: false; set true to make every tool skip gitignored files
```
--------------------------------
### config.toml: Define Marketplace Sources
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/hooks-and-plugins.md
Shows how to add git and local path sources in ~/.grok/config.toml. The [[marketplace.sources]] entries require a name and either a git URL or a path.
```toml
[[marketplace.sources]]
name = "My Team Plugins"
git = "https://github.com/my-org/plugins.git"
[[marketplace.sources]]
name = "Local Dev"
path = "~/dev/my-plugins"
```
--------------------------------
### Search config file for composer
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/tests/fixtures/historic_bash_cmds.txt
Gets the content of the Grok config file and filters for lines containing 'composer'.
```bash
cat ~/.grok/config.toml | grep composer
```
--------------------------------
### Launch Grok TUI with common options
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/01-getting-started.md
Common launch options for the Grok TUI. Use --worktree= (with =) so the prompt isn't swallowed as the worktree name; -w without = treats the prompt as the worktree label. --minimal and --fullscreen are sticky: plain grok reopens in the mode last chosen via these flags or /minimal//fullscreen. -p runs headless for scripts.
```bash
grok "fix the failing auth test and run it"
```
```bash
grok --worktree=feat "refactor module X"
```
```bash
grok -w --ref main "implement feature from main"
```
```bash
grok --cwd ~/projects/my-app
```
```bash
grok --rules "Always use TypeScript. Prefer functional components."
```
```bash
grok --yolo
```
```bash
grok -m grok-build
```
```bash
grok --resume
```
```bash
grok -c
```
```bash
grok --minimal
```
```bash
grok --fullscreen
```
```bash
grok -p "Explain this codebase"
```
--------------------------------
### Shell operator precedence example
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/tests/fixtures/historic_bash_cmds.txt
Shows the evaluation order of && and || operators in a single command line, ending with an echo.
```bash
true&&false||true; echo done
```
--------------------------------
### Run a skill by name
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/08-skills.md
Type the skill name as a slash command to run it. Comments show the skill being invoked.
```text
/commit # Runs the "commit" skill
/review-pr # Runs the "review-pr" skill
```
--------------------------------
### Require pinned versions in managed_config.toml
Source: https://github.com/asayeed95/asec-grok/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/09-plugins.md
Refuse any remote plugin install or update that is not pinned to a full commit sha. Publish sha values in plugin-index.json.
```toml
[marketplace]
require_sha = true
```