rtk-ai/rtk

Feature request : add command for grepai

Open

#304 opened on Mar 2, 2026

View on GitHub
 (1 comment) (0 reactions) (0 assignees)Rust (2,914 forks)batch import
area:clieffort-largeeffort-mediumenhancementhelp wantedpriority:medium

Repository metrics

Stars
 (48,085 stars)
PR merge metrics
 (Avg merge 11d 1h) (45 merged PRs in 30d)

Description

Summary

Add rtk grepai to filter grepai semantic code search output. Despite being AI-native, grepai's default output is verbose for LLM consumption — it includes full code bodies, separator lines, and metadata that waste tokens. Its built-in --toon flag paradoxically makes output 2-3x larger.

Motivation

grepai is increasingly used in Claude Code workflows for semantic search (grepai search) and call graph tracing (grepai trace callers/callees). These are high-volume commands that return large outputs with embedded code blocks that the LLM already has access to via other tools.

Current pain:

  • grepai search "auth logic" (10 results) → ~716 tokens of code bodies, separators, whitespace
  • grepai trace callers login (27 callers) → ~319 tokens with repeated file entries and code snippets

Proposed Filters

filter_search() — 90%+ savings

Strip code bodies, keep one line per result:

Before (716 tokens)

Found 10 results for: "authentication logic" ────────────────────── Result 1 (score: 0.68) ────────────────────── File: backend/src/some/path/api/auth.py:223-228

def authenticate_user(credentials): """Authenticate user with the given credentials.""" validated = validate_credentials(credentials) ... After (48 tokens)

grepai: "authentication logic" — 10 results

0.68  auth.py:223-228              (backend/src/.../api/)
0.38  SKILL.md:330-394 (+51 lines) (.claude/skills/auth-flow/)

filter_trace() — 85%+ savings

Group callers/callees by file, deduplicate:

Before (319 tokens — 27 separate caller entries with code)

After (30 tokens)

login (function) @ auth.py:117 — 27 callers in 8 files:

authRepository.test.ts  18x (lines: 61,96,126,...)
test_exercise_library.py  2x (lines: 120,145)
conftest.py:598  1x

Passthrough

Other subcommands (init, watch, status, graph) pass through unfiltered but still tracked.

Hook Rewrite

Only rewrite search and trace (the filtered subcommands):

grepai search "query"        → rtk grepai search "query"
grepai trace callers login   → rtk grepai trace callers login
grepai init                  → (no rewrite, stays raw)

Expected Savings

┌────────────────────────────┬──────────────┬───────────────┬──────────────────┐
│         Subcommand         │ Input tokens │ Output tokens │     Savings      │
├────────────────────────────┼──────────────┼───────────────┼──────────────────┤
│ search (10 results)        │ ~716         │ ~48           │ 93%              │
├────────────────────────────┼──────────────┼───────────────┼──────────────────┤
│ trace callers (27 callers) │ ~319         │ ~30           │ 91%              │
├────────────────────────────┼──────────────┼───────────────┼──────────────────┤
│ trace graph                │ ~52          │ ~52           │ 0% (passthrough) │
├────────────────────────────┼──────────────┼───────────────┼──────────────────┤
│ status                     │ ~26          │ ~26           │ 0% (passthrough) │
└────────────────────────────┴──────────────┴───────────────┴──────────────────┘

Contributor guide