Overview
Searches files using ripgrep (or grep fallback) with token-optimized output grouped by file. Automatically truncates long lines and limits results.Syntax
Arguments
string
required
Search pattern (regex supported). BRE alternation
\| auto-converted to PCRE |.string
default:"."
Directory to search (recursive by default)
Options
number
default:"80"
Maximum line length in results. Long lines truncated with
... around match.number
default:"50"
Maximum total results to show across all files.
flag
Show only 20 chars before/after match instead of full line.
string
Filter by file type:
ts, py, rust, js, etc. (ripgrep type names)flag
Show line numbers (always enabled, accepted for grep/rg compatibility)
Pass-through Arguments
Additional ripgrep flags supported via trailing args:-i- Case-insensitive search-w- Match whole words-A N- Show N lines after match-B N- Show N lines before match--glob PATTERN- Include/exclude files by glob
Output Format
- Header:
🔍 12 in 3F(12 matches in 3 files) - Per-file section with match count
- Line numbers auto-enabled
- Shows first 10 matches per file
- Truncates at
--maxtotal results
Token Savings
75% reduction - grouping by file and line truncationSpecial Behaviors
BRE to PCRE Conversion
RTK auto-converts Basic Regular Expression alternation\| to Perl-Compatible | for ripgrep compatibility:
Recursive by Default
Unlike traditional grep, RTK searches recursively. The-r flag is ignored (ripgrep is always recursive).
Smart Truncation
Long lines are truncated intelligently:- Match is centered in output
...prefix...match...suffix...format- Respects
--max-lencharacter limit - Handles multibyte characters (emoji, Unicode) correctly
Exit Codes
0- Matches found1- No matches found2- Error (bad regex, missing directory)
Related Commands
rtk read- View file contentsrtk find- Find files by namertk ls- List directory contents
