# CLI Flags

## Basic Usage

```bash
sgrep [FLAGS] <query> <paths...>
```

## Flags

| Flag | Default | Description |
|------|---------|-------------|
| `--threshold` | 0.5 | Minimum similarity score (0.0–1.0) |
| `--top-k` | 10 | Maximum results to show |
| `--model` | auto | Embedding model alias |
| `--hybrid` | off | Enable BM25 + semantic hybrid search |
| `--alpha` | 0.7 | Hybrid blend (0.0 = pure BM25, 1.0 = pure semantic) |
| `--json` | off | JSON output for piping |
| `--color` | auto | Color mode: auto, always, never |
| `-e, --classify` | — | Zero-shot classification labels (comma-separated) |
| `-C, --context` | — | Show N lines of context before and after |
| `-B, --before-context` | — | Show N lines before each result |
| `-A, --after-context` | — | Show N lines after each result |
| `--chunk-size` | — | Lines per chunk (overrides --granularity) |
| `--granularity` | line | Chunking: line or paragraph |
| `-r, --recursive` | off | Recursive directory search |
| `-l, --filenames-only` | off | Show filenames only |
| `-c, --count` | off | Count matches per file |
| `--no-score` | off | Hide similarity scores |
| `--no-filter` | off | Disable junk line filtering |
| `--no-ignore` | off | Disable .gitignore filtering |
| `--hidden` | off | Include hidden files |
| `--files` | off | Search file paths instead of contents |
| `--verbose` | off | Show backend, model, and timing info |
| `--model-path` | — | Path to a local model directory |
| `--dtype` | f32 | Neural model precision: f32 or f16 |
| `--index` | `.sgrep/index.db` | Path to sqlite-vec index cache |
| `--reindex` | off | Force re-embedding (ignore cache) |
| `--no-cache` | off | Disable caching entirely |

## Caching

sgrep caches embeddings in a local sqlite-vec database (`.sgrep/index.db` by default) so repeated searches are instant. The cache is keyed by file path + modification time.

```bash
# Force re-embed everything
sgrep --reindex "query" src/

# Skip cache entirely (useful for one-off searches)
sgrep --no-cache "query" src/

# Use a custom cache location
sgrep --index /tmp/my-index.db "query" src/
```