ig
instant-grep
โšก Jutsu Compendium โ€” All Techniques

CLI Reference

Six commands. Each one mastered to perfection. No bloat, no ceremony โ€” pure power.

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.

syntax
ig index [OPTIONS]   # default: current directory
examples
# 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.

output example
โฏ 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.

usage
# 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)
๐Ÿ’ก
Combine with 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.

usage
# 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.

syntax
ig query [OPTIONS] <PATTERN> [PATH]
examples
# 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
  }
}