AI

GrepAI: Semantic Code Search Tool by Yoan Bernabeu

Tool using local semantic search to replace Claude's keyword-based search, reducing input tokens by 97%.

February 23, 2026
7 min read
By ClawList Team

GrepAI: How Semantic Code Search Is Cutting Claude's Token Usage by 97%

Published on ClawList.io | Category: AI Automation | Reading Time: ~6 minutes


If you've ever watched Claude frantically scan through thousands of lines of code trying to find the function you're talking about, you already understand the problem. Keyword-based search is fast, but it's also dumb — it has no idea what your code means. A developer named Yoan Bernabeu decided to fix that, and the result is a tool called GrepAI.

The headline stat is hard to ignore: 97% reduction in input tokens. That's not a rounding error. That's a fundamental rethink of how AI assistants interact with your codebase.

Let's break down what GrepAI actually does, why it matters, and how it could change the way you build AI-powered development workflows.


The Problem: Claude's "Brute Force" Approach to Code Search

When you ask Claude (or most LLM-based coding assistants) to work with your codebase, the typical approach looks something like this:

  1. Dump the entire file — or worse, the entire repository — into the context window
  2. Ask the model to find what you're looking for
  3. Pay (in tokens, latency, and cost) for every irrelevant line it had to read through

This is what Yoan refers to as brute-force search. It works, but it's incredibly wasteful. Imagine asking a librarian to find a book about "machine learning optimization" and their solution is to read every single book out loud before deciding. That's essentially what's happening.

The core issue is that keyword matching doesn't understand semantics. If your function is called compute_gradient_descent but you ask about "how weight updates work," a keyword search might come up empty. The meaning is there; the exact words aren't.

This problem compounds at scale. As your codebase grows:

  • Context windows fill up faster
  • Token costs increase dramatically
  • Response latency climbs
  • The signal-to-noise ratio in the prompt drops

For production applications or large monorepos, this isn't just inconvenient — it's a hard ceiling on what AI-assisted development can realistically achieve.


The Solution: Local Semantic Search with GrepAI

GrepAI takes a fundamentally different approach by introducing local semantic search as a layer between your codebase and Claude.

Instead of keyword matching, semantic search works by converting code and queries into vector embeddings — mathematical representations that capture meaning, not just syntax. When you ask a question, GrepAI finds the code that is semantically closest to your intent, even if the exact words don't match.

Here's a simplified mental model of what's happening under the hood:

User Query: "how does authentication work?"
         ↓
GrepAI Embedding Model
         ↓
Vector Search → [auth_middleware.py, jwt_handler.py, session_manager.py]
         ↓
Only relevant files sent to Claude
         ↓
Claude responds with focused, accurate context

Compare that to the brute-force approach where Claude might receive your entire src/ directory just to answer the same question.

Why "Local" Matters

The local aspect of GrepAI is worth highlighting. The semantic search layer runs on your machine, meaning:

  • Your code never leaves your environment during the indexing phase
  • No additional API calls to a third-party embedding service (no hidden costs)
  • Faster retrieval since there's no network latency for the search step
  • Privacy-first architecture, which matters enormously in enterprise and regulated environments

This is a meaningful distinction from cloud-based RAG (Retrieval-Augmented Generation) solutions that route your source code through external servers.


Real-World Use Cases: Where GrepAI Shines

1. Large Monorepos

If you're working in a monorepo with dozens of microservices, asking Claude to "find where we handle payment retries" without GrepAI means potentially sending hundreds of thousands of tokens. With GrepAI, the semantic search narrows it down to the three or four files that actually matter.

# Example: Querying a large codebase semantically
grepai search "payment retry logic"
# Returns: payments/retry_handler.py, billing/webhooks.py
# Only these files get forwarded to Claude

2. Onboarding to Unfamiliar Codebases

One of the most painful parts of joining a new team is navigating an unfamiliar codebase. GrepAI lets you ask questions in natural language — "show me how database connections are initialized" — and instantly surfaces the relevant code, without needing to know the project's naming conventions or folder structure.

3. Debugging with Semantic Context

Debugging often involves understanding related code, not just the exact file throwing the error. Semantic search excels here because it can surface conceptually related modules — like finding all the places where a particular design pattern is used, even if the implementations look different syntactically.

4. AI Agent Workflows and OpenClaw Skills

For developers building AI automation pipelines or OpenClaw skills, GrepAI is a natural fit as a pre-processing step. Instead of feeding entire codebases into your agent's context, you can use GrepAI's semantic retrieval to pass only the high-signal code snippets your agent actually needs.

# Pseudocode: Integrating GrepAI into an AI agent workflow
relevant_files = grepai.search(query=user_intent, top_k=5)
context = load_file_contents(relevant_files)
response = claude.complete(prompt=user_intent, context=context)

This keeps your agents lean, fast, and cost-efficient — which is critical when you're making dozens or hundreds of LLM calls in a single automation run.


The Numbers: Understanding the 97% Token Reduction

Let's put the 97% figure in perspective.

Suppose your codebase is 500,000 tokens worth of source code. Without semantic search, a brute-force approach might send 100,000 tokens per query to Claude (a subset, but still a large chunk). With GrepAI, the semantic layer might retrieve just 3,000 tokens of genuinely relevant code before passing it to the model.

| Approach | Tokens per Query | Cost per 1,000 Queries (est.) | |---|---|---| | Brute Force | ~100,000 | ~$300 (Claude Sonnet) | | GrepAI Semantic | ~3,000 | ~$9 (Claude Sonnet) |

The math speaks for itself. For teams running AI-assisted development at scale, this isn't a minor optimization — it's the difference between a tool that's economically viable and one that isn't.

Beyond cost, there's also the quality angle: smaller, more focused prompts generally produce better outputs. Claude isn't wading through irrelevant boilerplate; it's working with exactly the code it needs.


Getting Started with GrepAI

GrepAI is open source and available on GitHub (check the original post by @vista8 for the direct repository link). If you're working with Claude on any non-trivial codebase, it's worth evaluating.

A few things to look for when you explore the repo:

  • Embedding model options — what models are supported for local indexing?
  • Chunking strategies — how does it split code into searchable units?
  • Integration points — does it work with your existing Claude toolchain or MCP setup?
  • Index update frequency — how does it handle rapidly changing codebases?

Conclusion: Semantic Search Is the Missing Layer

GrepAI represents a pattern that's going to become increasingly important as AI coding assistants mature: intelligent context retrieval. The raw power of models like Claude is impressive, but that power is wasted when the model is drowning in irrelevant context.

By introducing a semantic search layer that understands meaning rather than just matching keywords, Yoan Bernabeu has built something that makes Claude meaningfully smarter — not by changing the model, but by changing what the model sees.

A 97% reduction in input tokens isn't just a performance stat. It's a signal that we've been approaching AI-assisted development inefficiently, and that there's still enormous low-hanging fruit in how we structure human-to-model communication.

Whether you're building OpenClaw skills, running AI automation pipelines, or just trying to use Claude more effectively in your daily development work — GrepAI is worth a serious look.


Found this useful? Explore more AI developer tools and OpenClaw skill resources at ClawList.io. Follow @vista8 on X for more AI development insights.

Tags: GrepAI semantic search Claude AI token optimization AI coding tools vector embeddings RAG developer tools AI automation OpenClaw

Tags

#AI#Claude#semantic-search#code-search#optimization

Related Articles