CLI Reference

Complete documentation for every ig command and flag. The search subcommand is the default — most commands listed here have no required subcommand prefix.

v2.0.0: ig is process-per-invocation — there is no daemon. The daemon, query, watch, warm, hold, and projects subcommands were removed. v2.0.0 also adds 33 RTK-parity command wrappers (test runners, linters, build tools, git platforms, cloud CLIs) — see Command wrappers below.

Global flags

These flags work on any subcommand (they are declared global = true).

Flag Short Description
--ultra-compact-uOne-liner per item, no snippets, aggressive truncation — the minimum-signal mode for AI agents
--verbose-v / -vv / -vvvVerbosity level. 0 = quiet (default), 3 = trace. Repeatable
--explainPrint the action ig is about to take (rewrite, filter selection, permission verdict) without changing behaviour
--semanticExpand the query with PMI-learned synonyms (search only)

ig index

Build or rebuild the sparse n-gram index for a directory. The index is written under ~/.cache/ig/projects/<hash>/ (XDG cache; ~/Library/Caches/ig/ on macOS) — never inside the repo. ig search calls this automatically when no index exists or the index is stale, so you rarely run it by hand.

syntax
ig index [PATH]   # default: current directory
examples
# Index current directory
ig index

# Index specific path
ig index /path/to/project

ig status

Display statistics about the current index — file count, index size, n-gram count, version, and last build time. Use ig cache-ls to list every cached project.

output example
ig status .

instant-grep index status
──────────────────────────
Location:    ~/.cache/ig/projects/2e0c.../
Version:     13
Files:       1,552
N-grams:     48,392
Lexicon:     31 MB
Postings:    7.1 MB
Metadata:    111 KB
Built:       2026-05-20 10:12:08

ig files

List all project files, respecting .gitignore and default exclusions. Ideal for AI agents needing a file inventory before deciding what to read.

syntax
ig files [OPTIONS] [PATH]
Flag Short Description
--compactTree-compressed listing — groups files by directory with counts and extension breakdown
--type EXT-tFilter by file extension
--glob PATTERN-gFilter files by glob pattern
--jsonOutput results as JSON (for AI agents)
examples
# List all project files
ig files

# Only Rust files
ig files -t rust

# JSON output for agents
ig files --json

# With glob filter
ig files -g "src/**/*.ts"

# Tree-compressed view — directories with file counts
ig files --compact

# Compact view filtered to PHP files
ig files --compact -t php

Auto-compact on pipe v1.10.0

When stdout is a pipe and the listing has 40+ files, ig files emits a one-line aggregate instead of enumerating every path. A TTY or IG_COMPACT=0 keeps the verbose listing.

example
$ ig files | head
3201 files in 911 dirs · 972 tsx, 890 php, 790 ts, 80 mdx, 70 py, 47 json
(compact view set IG_COMPACT=0 or run in a TTY for the full listing)

# iautos monorepo: 176 KB → 149 B (≈1180×)

ig symbols

Extract symbol definitions (functions, classes, structs, interfaces) from source files. Language-aware patterns for Rust, TypeScript, Python, Go, PHP, and more.

syntax
ig symbols [OPTIONS] [PATH]
examples
# All symbols in project
ig symbols

# Only Rust symbols
ig symbols -t rust

# JSON output (for agents)
ig symbols --json

# Symbols in specific directory
ig symbols src/

ig context

Show the full code block (function, class, struct) containing a specific line. Automatically detects block boundaries using brace matching or indentation.

syntax
ig context <FILE> <LINE>
examples
# Show function containing line 42
ig context src/main.rs 42

# JSON output
ig context --json src/main.rs 42

ig ls

Compact directory listing optimized for AI agents. Groups files by directory, shows file counts, and respects .gitignore and default exclusions. Generates a tree-like overview without the noise.

syntax
ig ls [PATH]   # default: current directory
examples
# Compact listing of current project
ig ls

src/          (12 files)
  index/      (6 files)  ngram.rs  reader.rs  writer.rs  ...
  query/      (2 files)  extract.rs  mod.rs
  main.rs  cache.rs  read.rs  smart.rs

# Listing a subdirectory
ig ls src/

ig read

Smart file reading with multiple compression modes. Full mode returns the complete file; --signatures extracts only function/class/struct definitions — dramatically reducing tokens when an AI agent only needs the API surface. Advanced modes offer aggressive compression, token budgets, relevance boosting, and delta views.

syntax
ig read <FILE> [OPTIONS]
Flag Short Description
--signatures-sSignatures only — function/class/struct definitions
--aggressive-aStrip comments, collapse blanks, elide function bodies. Keep signatures + struct fields
--budget N-b NMax output tokens — uses entropy scoring to keep the most informative lines
--relevance PAT-r PATBoost score for lines matching pattern. Best combined with -b
--delta-dShow only git-changed lines with enclosing function context
examples
# Full file content
ig read src/index/reader.rs

# Signatures only (functions + structs — much smaller)
ig read -s src/index/reader.rs

pub fn open_for(root: &Path) -> Result<IndexReader>
pub fn query(&self, ngrams: &NgramQuery) -> Vec<DocId>
pub fn intersect_postings(&self, lists: &[&[u8]]) -> Vec<DocId>

# Aggressive compression — strip comments, collapse blanks, elide bodies
ig read -a src/index/reader.rs

# Budget mode — keep the 500 most informative tokens
ig read -b 500 src/index/reader.rs

# Budget + relevance boost — prioritize payment-related code
ig read -b 500 -r "payment" src/billing.php

# Delta mode — only git-changed lines with enclosing signatures
ig read -d src/main.rs

# Raw output — byte-for-byte identical to cat
ig read -p src/main.rs

ig smart

Generate 2-line heuristic summaries for every file in the project. Each summary captures the file's purpose in minimal tokens — ideal for giving an AI agent a high-level map before deciding which files to read in full.

syntax
ig smart [PATH]   # default: current directory
examples
# 2-line summaries for all project files
ig smart

src/index/reader.rs
  mmap-backed index query — hash table lookup + posting intersection.
  Decodes VByte postings on the fly, applies bloom/loc masks.

src/index/ngram.rs
  Sparse n-gram generation via hash_bigram + covering set selection.
  Core algorithm — port of danlark1/sparse_ngrams.

Directory aggregate mode v1.10.0

When the target is a directory and stdout is a pipe, ig smart emits a one-block structural summary instead of reading every file. The per-file mode was O(N files) — hitting 5+ seconds on a 1000-file subtree — and produced a wall of text an agent rarely needs in full. The aggregate is three lines, fast, and usually more useful for orienting in an unfamiliar codebase.

example
$ ig smart apps/api
apps/api: 1042 files, 249 dirs · 890 php, 39 yaml, 31 twig, 29 sh, 10 md
top: src/ (664), migrations/ (109), tests/ (103), config/ (42)
key: composer.json, README.md, Makefile

# 345 B / 19 ms — down from 69 KB / 5.3 s (≈200× smaller, ≈280× faster)
# Force full per-file summary: IG_COMPACT=0 ig smart apps/api

ig pack

Generate a context.md project map (under the XDG cache dir) — a structured project snapshot for AI agents. Includes directory tree, symbol definitions, dependencies (Cargo.toml / package.json), API routes (Next.js), and environment variables (.env.example). Replaces manual context-building.

syntax
ig pack [PATH]   # writes the context.md project map
output sections
# context.md contains:

## Directory Tree    — compact ig ls output
## Symbols          — all function/class/struct definitions
## Dependencies     — Cargo.toml or package.json (v1.3+)
## API Routes       — Next.js app/api/** routes (v1.3+)
## Environment      — .env.example keys (v1.3+)

Token savings: a typical Next.js project context shrinks from 1,517 lines to 263 lines when using ig pack vs naive directory listing. Also auto-generated by ig index on every rebuild.

ig gain

Token savings dashboard. Reads the JSONL tracking log written by the rewrite hook and displays cumulative token savings, cost estimates, and per-command breakdowns.

syntax
ig gain [OPTIONS]    # show savings dashboard
ig gain --clear      # reset history
Flag Short Description
--graphASCII chart of daily savings (last 14 days)
--quotaMonthly quota savings estimate
--tier TIERSubscription tier: pro, 5x, 20x (default: 20x)
--project-pFilter to current project only
--daily-dShow daily breakdown
--weeklyShow weekly breakdown
--monthly-mShow monthly breakdown
--discoverScan Claude Code sessions for missed savings
--since NDays to scan for --discover (default: 30)
--historyPer-command history with individual savings
--jsonMachine-readable JSON output
--fullv1.10.0 — Show the full By Command table instead of the top 20
--clearReset history

v1.10.0: the default dashboard now shows the top 20 commands (was 15). Long-tail ig run <cmd> variants usually fill positions 15-20 and collectively account for a big chunk of savings. Use --full when you need every row.

output example
ig gain

instant-grep token savings
────────────────────────────────
Session:      47 rewrites
Tokens saved: 142,380
Cost saved:   $0.13
Top command:  git status  (38 rewrites, 91K tokens)
examples
# Main dashboard
ig gain

# Daily savings chart (last 14 days)
ig gain --graph

# Monthly token projection
ig gain --quota

# Current project only
ig gain -p

# Find missed optimization opportunities
ig gain --discover

# Per-command history with individual savings (new in v1.4)
ig gain --history

# Machine-readable JSON output (new in v1.4)
ig gain --json
--history output example
command history (last 10)
────────────────────────────────────────────
2026-03-27 14:32  git status    -605B   (-83%)
2026-03-27 14:35  git log -10   -7,864B (-89%)
2026-03-27 14:41  grep -r …     -2,100B (-94%)
2026-03-27 14:50  git diff      -19,382B (-74%)

ig setup alias: ig init

Auto-configure AI CLI agents to use ig. Detects installed agents and injects configuration — hook scripts, settings.json patches, and managed rule-file blocks. Idempotent and non-destructive — safe to run multiple times. ig init is an accepted alias for RTK muscle memory.

ig setup supports 11 agents: claude, codex, cursor, copilot, gemini, opencode, windsurf, cline, hermes, kilocode, antigravity.

Flag Description
--agent NAMETarget one agent instead of all (e.g. --agent claude); default all
--showList currently installed artifacts for the selected agent(s) and exit
--uninstallRemove ig artifacts for the selected agent(s)
--hook-onlyInstall only the hook scripts / settings.json patches, skip the rule files
--auto-patchCreate missing agent config dirs (default: only patch existing ones)
--no-patchRefuse to patch existing settings.json files even if stale
--import-rtkAlso import RTK filter files into ig's filter format
--dry-runPreview every planned action without writing any files
--quiet / -qSuppress the banner and skip already-up-to-date lines (used by ig update)

Claude Code's PreToolUse hook uses the RTK 0/1/2/3 exit-code protocol: 0 = rewrite/allow, 1 = passthrough, 2 = deny, 3 = ask. Run ig hook-audit to audit installed hooks and the recent permission-verdict histogram.

examples
# Configure every detected agent
ig setup

# One agent only
ig setup --agent claude

# Preview without writing
ig setup --dry-run

# Show what is installed
ig setup --show

# Configure + import RTK filters in one shot
ig setup --import-rtk

ig import-rtk v2.0.0

One-shot translation of RTK filter files into ig's filter format. Reads ~/.config/rtk/filters.toml and ./.rtk/filters.toml and writes the equivalent ig filters. RTK fields (match, strip_ansi, keep, drop, truncate, head, tail, max_lines, on_empty, dedup_consecutive) map 1:1; RTK-only features that ig already covers with a native parser are skipped with a comment.

syntax
ig import-rtk             # translate RTK filter files
ig import-rtk --dry-run   # preview the translation without writing

ig git

Token-compressed git proxy. Strips verbose output, filters noise, and tracks token savings. Supports status, log, diff, show, and branch. Transparent — the output is still valid git output, just compressed.

syntax
ig git <SUBCOMMAND> [GIT OPTIONS]
Subcommand Native size After ig git Savings
git status732B127B-83%
git log -108,861B997B-89%
git show HEAD11,920B5,812B-51%
git diff26,288B6,906B-74%
examples
# Compressed git status (127B instead of 732B)
ig git status

# Compact log — 10 entries, -89% token reduction
ig git log -10

# Diff with noise stripped
ig git diff

# Show last commit
ig git show HEAD

# Branch list
ig git branch

ig discover

Scan agent session history (and optionally shell history) for missed token-saving opportunities — commands that could have gone through ig run but didn't. Helps you tune your hook coverage.

syntax
ig discover [OPTIONS]   # scan agent + shell history
Flag Description
--since NOnly scan sessions/history from the last N days (default: 30)
--limit NMaximum entries to show per section (default: 15)
--shellAlso scan ~/.zsh_history / ~/.bash_history
--allScan all available history, ignoring --since
--formatOutput format: text (default) or json
examples
# Scan the last 30 days of sessions
ig discover

# Scan everything, including shell history
ig discover --all --shell

# Cap to top 20 entries per section
ig discover --limit 20

ig run alias: ig proxy

Run any command through ig's token-optimized filter pipeline. The output is compacted by a TOML-driven filter (8 stages: ansi, replace, keep, drop, truncate, head, tail, fallback) and the wrapped command's exit code is propagated. When the output can't be parsed, ig falls back to raw passthrough. ig run also transparently routes ls, find, cat, and git status/log/diff to the dedicated ig subcommands (opt out with IG_RUN_ROUTE=0).

syntax
ig run <COMMAND> [ARGS...]    # run through the filter pipeline
ig proxy <COMMAND> [ARGS...]  # alias
examples
# Run a build command with filtered output
ig run cargo build

# Routes to the dedicated subcommand automatically
ig run git status     # → ig git status
ig run ls src/        # → ig ls src/

# See the filter / rewrite decision without changing behaviour
ig --explain run cargo test

Command wrappers v2.0.0

v2.0.0 ships native Rust wrappers for 33 common developer tools — feature parity with rtk. Each wrapper parses the tool's output (JSON where available), emits a compact summary, propagates the wrapped tool's exit code, honours -u/--ultra-compact, and falls back to raw passthrough when the output can't be parsed.

Group Subcommands
Test runnersvitest jest playwright pytest cargo-test go-test rspec rake
Linters / formatterseslint biome tsc prettier ruff mypy rubocop golangci-lint
Build / packagenext prisma pnpm npm pip
Git platformsgh glab gt
Cloud / dataaws kubectl psql curl wget
Systemlog summary tree wc
examples
# Test runners — compact pass/fail summary
ig vitest
ig pytest tests/
ig cargo-test

# Linters — only files with diagnostics
ig eslint src/
ig tsc --noEmit
ig ruff check .

# Git platforms / cloud
ig gh pr list
ig kubectl get pods
ig aws s3 ls

# Ultra-compact, minimum signal
ig -u jest

Meta commands

ig setup / ig init (agent configuration), ig import-rtk (RTK filter migration), ig hook-audit (audit installed hooks + recent permission verdicts), and ig telemetry (opt-in anonymous telemetry — off by default; the public build compiles in no endpoint, so it is a hard no-op).

JSON output format (--json)

Structured, parseable, minimal tokens. Supported by search, files, symbols, and context.

schema
{
  "pattern": "async fn",
  "matches": [
    {
      "file": "src/index/reader.rs",
      "line": 23,
      "text": "pub fn open_for(root: &Path) -> Result<IndexReader> {"
    }
  ],
  "stats": {
    "duration_ms": 0.9,
    "candidates": 47,
    "matches": 3
  }
}