Most people blame the model when AI debugging goes sideways.
Wrong diagnosis. The model isn’t the problem. The context is.
A dev on r/PromptEngineering (u/jse78) spent time debugging large codebases and kept hitting the same wall: the AI reasoned fine, it just didn’t know enough about the repo to reason correctly. So they built a terminal tool called grab to fix it.
The twist: instead of pushing more code at the AI, grab flips it. The AI requests exactly what it needs, incrementally, as the session goes. No full repo dump. No giant index. Context on demand.
The workflow:
- 🔍 Search for relevant symbols and functions with ripgrep
- 📋 Build a lightweight function index from the results
- Let the AI request the exact code ranges it needs
- Accumulate context incrementally as the debug session grows
- 🎯 Expand only the parts of the repo that actually matter
The core framing from the builder: “You are not copying results. You are exporting context.”
That’s the shift. You stop deciding what the AI sees. The AI decides what it needs and asks for it.
Pro tip: The comment thread confirms this is a real pattern. One person already pipes ripgrep output with function bodies and callers straight into Claude. No indexing, zero friction. Both approaches prove the same thing: targeted context beats broad context every time.
Pro tip 2: When handing off a buggy function, give the AI the callers first, not the implementation. It often needs “why this gets called” before it can figure out “why it breaks.”
Repo: github.com/johnsellin93/grab
If you’ve ever handed an AI a bug and watched it confidently explain the wrong thing, this is worth 10 minutes. 🚀
Frequently Asked Questions
Q: How is grab different from using ripgrep + a simple wrapper?
Great question! Some users already have lean solutions like this that work perfectly. Grab’s real advantage is systematization: it combines function indexing with exact range extraction, tmux/clipboard integration, and a structured workflow that scales with codebase complexity. If you’ve got a ripgrep routine that works, that’s totally valid. Grab shines when that starts becoming a bottleneck.
Q: Why not just dump my entire repository into Claude?
Here’s the thing: you’ll hit token limits on large codebases, waste context on irrelevant code, and dilute the AI’s reasoning. Incremental context keeps your prompts laser-focused on what actually matters, reduces costs, and often gets you better debugging results. The AI requests specific ranges instead of wading through thousands of lines.
Q: Do I need to pre-index my repository to use grab?
Nope. Grab builds its function index on the fly using ripgrep and fetches exact code ranges as you need them. No upfront indexing or separate database. Context accumulates naturally as you debug.
Q: How does grab integrate with my terminal workflow?
Pretty seamlessly. The clipboard and tmux integration means you can pipe context directly to Claude without manual copy-paste, and the search-then-request pattern keeps everything in your shell. If you already live in the terminal, this’ll feel native.
Rapid AI-assisted debugging and repository analysis from the terminal
by u/jse78 in PromptEngineering