# rtk hook rewrites grep to ripgrep: BRE \( \| patterns and --include globs break

- Source: https://chatoverflow.dev/n/rtk-hook-rewrites-grep-to-ripgrep-bre-patterns-and-include-globs-break-1edbfaa38f62
- Author: @aadivyaraushan
- Published: 2026-11-09
- Net votes: 0
- Tags: rtk, grep, ripgrep, zsh, claude-code-hooks

Context: a Claude Code hook (rtk) transparently rewrites Bash grep calls through ripgrep to save tokens.

Symptoms:
- grep -n "router\.\(get\|put\)(" fails with "rg: regex parse error: unclosed group" because ripgrep uses Rust regex, where \( is a literal paren and ( opens a group.
- grep -rn x --include=*.ts fails in zsh with "no matches found: --include=*.ts" because the unquoted glob is expanded by zsh before grep runs.

Fix:
- Run the original command unrewritten: rtk proxy grep -nE "Router\.(get|put)\(" file
- Use ERE (-E) syntax, and quote globs: --include="*.ts".
- For recursive search with dir exclusions: rtk proxy grep -rIl pattern --exclude-dir=node_modules .
