Install
openclaw skills install @albert-lv/sngs-helperSearch source code with the sngs sparse n-gram index. Use for fast literal or regex searches, repeated repository searches, machine-readable code-search results, index initialization, incremental Git updates, and search diagnostics.
openclaw skills install @albert-lv/sngs-helpersngs builds a sparse n-gram inverted index for fast literal and regex search without rescanning every file. Use it for symbols, strings, configuration values, error messages, and repeated searches in a repository.
If sngs cannot find content that should exist, use rg as a fallback and report the discrepancy rather than assuming the content is absent.
Requires Rust 1.75 or newer:
git clone https://github.com/nano-harness/sparse-ngram-search.git
cd sparse-ngram-search
cargo build -p sngs --release
mkdir -p ~/.local/bin
install -m 755 ./target/release/sngs ~/.local/bin/sngs
Ensure ~/.local/bin is on PATH, then run sngs doctor when diagnosing an existing installation.
Search with automatic index creation:
sngs search --auto-init --json "ConnectionPool"
Use the smallest useful output format:
sngs search -l "TODO"sngs search -c "unsafe"sngs search --grep -C 2 "TODO"sngs search --json "ConnectionPool"Add filters to reduce irrelevant results:
sngs search --grep --glob "src/*" --exclude "*/tests/*" --type rs "ConnectionPool"
After changes, run sngs sync when the next search must observe them immediately.
| Goal | Command |
|---|---|
| Build an index | sngs init --path <repo> |
| Search a literal | sngs search "fn parse_header" |
| Search a regex | sngs search -e "impl\\s+Display" |
| Limit results | sngs search -n 20 "unsafe" |
| Auto-build a missing index | sngs search --auto-init "ConnectionPool" |
| Update an index | sngs sync --path <repo> |
| Inspect index metadata | sngs status --path <repo> |
| Force a full rebuild | sngs rebuild --path <repo> |
| Diagnose setup and index health | sngs doctor --path <repo> |
| Warm the OS page cache | sngs warmup --path <repo> |
| Explain the current index | sngs explain-index --path <repo> |
| Generate completions | sngs completion zsh |
Global options include --timeout <seconds> for bounded searches and --index-dir <dir> for external or read-only-repository index storage.
sngs sync forces a full freshness scan. Set SNGS_SYNC_TTL_SECS=0 to disable the dirty-scan cache.sync.--no-ignore currently has no effect in Git repositories and produces a warning; use it only for non-Git directories.0 means matches, 1 means no matches, and 2 means an error.Indexes are stored in .sngi-store/ by default, or under the directory supplied with --index-dir. Usage statistics are local, not required for search, and can be disabled with SNGS_NO_STATS=1.
Do not publish indexes, search output, or local statistics when they reveal private source code or sensitive paths.
--json for programmatic processing and --grep for human-readable context.1 from an execution error.