CLI Reference
Six commands. Each one mastered to perfection. No bloat, no ceremony โ pure power.
ig search
The primary command. Searches for regex patterns across indexed files. Auto-builds index on first run. The most-used jutsu in the arsenal.
search subcommand is optional.
ig "pattern" . and ig search "pattern" . are equivalent.
All flags work the same way in both forms.
ig [OPTIONS] <PATTERN> [PATH]
ig search [OPTIONS] <PATTERN> [PATH] # also works | Flag | Short | Description |
|---|---|---|
| --ignore-case | -i | Case-insensitive matching |
| --after-context N | -A N | Show N lines after each match |
| --before-context N | -B N | Show N lines before each match |
| --context N | -C N | Show N lines before and after (overrides -A/-B) |
| --type EXT | Filter by file extension (e.g. --type rs) | |
| --glob PATTERN | Filter files by glob pattern (e.g. --glob '*.rs') | |
| --json | Output results as JSON (for AI agents) | |
| --stats | Print search statistics (candidates, time, etc.) | |
| --no-index | Skip index, grep files directly (slow but always fresh) |
# Basic regex search
ig "async fn \w+" src/
# Case-insensitive with 2 lines of context
ig -i -C 2 "TODO" .
# JSON output for AI agents
ig --json "impl \w+ for" src/
# Only Rust files
ig --type rs "pub fn" .
# Files matching glob
ig --glob 'src/**/*.rs' "Result<" .
# Show stats (candidates filtered, time)
ig --stats "use std" . ig index
Build or rebuild the sparse n-gram index for a directory.
Creates .ig/ with three binary files.
Called automatically by ig search when no index exists.
ig index [OPTIONS] # default: current directory # Index current directory
ig index
# Index specific path
ig index /path/to/project
# Force rebuild (even if index exists)
ig index --force . ig status
Display statistics about the current index โ file count, index size, n-gram count, version, and last build time.
โฏ ig status .
instant-grep index status
โโโโโโโโโโโโโโโโโโโโโโโโโโ
Location: /home/user/project/.ig/
Version: 5
Files: 1,247
N-grams: 48,392
Lexicon: 2.1 MB
Postings: 218 KB
Built: 2025-03-22 14:30:12 ig watch
Watch a directory for file changes and automatically rebuild the index when files are created, modified, or deleted. Continuous chakra flow โ the index is always fresh.
# Watch and auto-rebuild on changes
ig watch .
[watching] src/ โ press Ctrl+C to stop
[rebuild] src/main.rs modified โ rebuilding... done (43ms)
[rebuild] src/lib.rs created โ rebuilding... done (51ms) ig daemon for best results:
watch keeps the index fresh, daemon keeps it in memory.
Together they give you permanent sub-ms search on a live codebase.
ig daemon
Sage Mode
Start the Sage Mode daemon โ a Unix socket server that keeps the index mmap'd in process memory.
Use ig query to send queries to the running daemon.
Ideal for AI agents making repeated searches.
# Start daemon in background
ig daemon . &
[sage-mode] Daemon started
[sage-mode] Socket: .ig/daemon.sock
[sage-mode] Index loaded: 1,247 files (2.3 MB)
[sage-mode] Ready for queries... ig query
Send a query to a running daemon via Unix socket.
Same interface as ig search but routes through the socket.
Requires ig daemon to be running.
ig query [OPTIONS] <PATTERN> [PATH] # Query daemon (sub-ms)
ig query "async fn" .
# JSON output via daemon
ig query --json "Result<" .
# p50 latency: 0.3ms (warm daemon) JSON Output Format (--json)
Used by AI agents โ structured, parseable, minimal tokens.
{
"pattern": "async fn",
"matches": [
{
"file": "src/daemon.rs",
"line": 23,
"text": "pub async fn handle_connection(stream: UnixStream) {"
}
],
"stats": {
"duration_ms": 0.9,
"candidates": 47,
"matches": 3
}
}