# Tool Ripgrep

> tool-ripgrep

- Skill: `niksavis/tool-ripgrep-2` (Agent Skill)
- Install (CLI): `npx skillmds@latest add niksavis/tool-ripgrep-2`
- Raw SKILL.md: https://api.skillmd.com/api/skills/niksavis/tool-ripgrep-2/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: niksavis (https://skillmd.com/u/niksavis)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/niksavis/tool-ripgrep-2

---

# tool-ripgrep

## When To Use

- Search file contents across large codebases faster than grep.
- Find symbols, flags, and text patterns before opening files.
- Build parseable discovery pipelines for agent workflows.

## Trusted Commands

```bash
rg "pattern" path/
rg -F "exact string"
rg "pattern" -t py
rg "pattern" -g '*.py'
rg "pattern" -C 3
rg -l "pattern"
rg -c "pattern"
rg -i "pattern"
rg "pattern" --json
rg --exit-status "pattern"
```

## Safe Defaults

- Use `-n` when actionable line references are needed.
- Use `-F` for literal strings to avoid regex escaping mistakes.
- Use `--glob`/`-g` and type filters to keep results relevant and fast.

## Common Pitfalls

- Hidden and ignored files are skipped by default.
- Regex mode can over-match when fixed-string matching was intended.
- `--json` emits begin/match/end/summary events, not a single flat schema.

## Output Interpretation

- Default output is `path:line:column:matched_text`.
- Exit code 1 means no matches and can be a valid outcome.
- `--exit-status` is useful in conditional shell pipelines.

## Why It Matters For Agents

- `rg --json` produces structured, machine-parseable search events.
- It is the fastest practical first-pass search in repository workflows.

## Repo Conventions

- Prefer ripgrep for discovery before semantic or AST-level tools.
- Include ignored files only when the task explicitly requires them.

## Trigger Examples

- Should trigger: "Find where `--user-install` is referenced."
- Should trigger: "Search all markdown docs for stale command examples."
- Should not trigger: "Rename a Python symbol across semantic references only."

