Back to AI Tools & Agents

mgrep-code-search

mgrepsemantic searchcode explorationai agentclaude codecursordeveloper toolscode search
⭐ 273πŸ“„ CC0-1.0πŸ•’ 2026-04-25Source β†—

Install this skill

npx skills add intellectronica/agent-skills

Works across Claude Code, Cursor, Codex, Copilot & Antigravity

mgrep serves as a semantic search engine specifically calibrated for source code and documentation. Unlike traditional text-matching utilities, it interprets the intent of your search queries to identify relevant code segments, logic patterns, or architectural implementations across directories. By indexing files locally, it allows for fast, context-aware discovery in repositories that are too large for manual review. It supports multi-modal search, covering text, PDFs, and images, ensuring that developers can locate hidden definitions or scattered implementations without knowing exact keywords. By running a local watcher, the tool maintains a fresh index that adheres to project-specific exclusion rules like .gitignore. This provides an effective way to navigate legacy systems or unfamiliar codebases where the mental map of the structure has not yet been formed.

When to Use This Skill

  • β€’Locating the specific implementation of an authentication flow
  • β€’Finding scattered patterns of error handling across microservices
  • β€’Identifying all files related to a feature described in plain English
  • β€’Exploring an unfamiliar codebase structure for the first time

How to Invoke This Skill

Example prompts that trigger this skill in Claude Code, Cursor, or Antigravity:

  • β€œWhere is the user session logic handled?
  • β€œShow me the code that validates API request bodies
  • β€œHow does the database connection initialization work?
  • β€œFind patterns for logging inside the payment services directory
  • β€œWhat defines the current UI theme configuration?

Pro Tips

  • πŸ’‘Combine semantic search with traditional `grep`/`ripgrep` for a hybrid approach: use `mgrep` for conceptual understanding and `grep` for precise string matches.
  • πŸ’‘Ensure the `mgrep watch` command is running in your development environment to keep your codebase index up-to-date with file changes.
  • πŸ’‘Refine natural language queries by starting broad and gradually narrowing down the scope to achieve more precise and relevant results.

What this skill does

  • β€’Indexes and maintains searchable code vectors locally
  • β€’Performs semantic retrieval based on natural language intent
  • β€’Generates AI-powered summaries of search results for direct answers
  • β€’Supports scoping searches to specific directory paths
  • β€’Configurable result ranking and output formatting via CLI flags

When not to use it

  • βœ•Searching for precise literal string matches or specific variable names
  • βœ•Performing regex-based bulk refactoring operations
  • βœ•Operating in environments without the Bun runtime

Example workflow

  1. Install and confirm the Bun runtime is available
  2. Run 'bunx @mixedbread/mgrep watch' in the root directory to build the index
  3. Execute a natural language query using 'bunx @mixedbread/mgrep "search query"'
  4. Refine the scope by adding a path argument like 'src/components'
  5. Use the '-a' flag to generate a synthetic AI summary of the findings

Prerequisites

  • –Bun runtime installed on the system
  • –Existing project directory to index

Pitfalls & limitations

  • !Requires active background watcher to keep index synchronized with live file changes
  • !Not suitable for strict exact-match searches where grep is faster
  • !Index bloat in extremely large repositories might affect local performance

FAQ

Do I need to install mgrep globally?
No, it is intended to be executed via bunx, which pulls the latest version directly from the registry for each run.
How does it handle files I do not want indexed?
It automatically respects .gitignore files and allows further configuration via a custom .mgrepignore file.
Does the search work offline?
Yes, once the initial index is built, the search functions locally without needing external network calls.

How it compares

While standard grep requires specific keyword knowledge, mgrep maps abstract concepts to code snippets, acting as a semantic bridge that eliminates the 'what word did I name this function' struggle.

Source & trust

⭐ 273 starsπŸ“„ CC0-1.0πŸ•’ Updated 2026-04-25
πŸ“„ Full skill instructions β€” original source: intellectronica/agent-skills
# mgrep Code Search

## Overview

mgrep is a semantic search tool that enables natural language queries across code, text, PDFs, and images. It is particularly effective for exploring larger or complex codebases where traditional pattern matching falls short.

## When to Use This Skill

Use mgrep when:
- The codebase contains more than 30 non-gitignored files
- There are nested directory structures
- Searching for concepts, features, or intent rather than exact strings
- Exploring an unfamiliar codebase
- Need to understand "where" or "how" something is implemented

Use traditional grep/ripgrep when:
- Searching for exact patterns or symbols
- Regex-based refactoring
- Tracing specific function or variable names

## Quick Start

### Indexing

Before searching, start the watcher to index the repository:

bunx @mixedbread/mgrep watch


The watch command indexes the repository and maintains synchronisation with file changes. It respects .gitignore and .mgrepignore patterns.

### Searching

bunx @mixedbread/mgrep "your natural language query" [path]


## Search Commands

### Basic Search

bunx @mixedbread/mgrep "where is authentication configured?"
bunx @mixedbread/mgrep "how do we handle errors in API calls?" src/
bunx @mixedbread/mgrep "database connection setup" src/lib


### Search Options

| Option | Description |
|--------|-------------|
| -m <count> | Maximum results (default: 10) |
| -c, --content | Display full result content |
| -a, --answer | Generate AI-powered synthesis of results |
| -s, --sync | Update index before searching |
| --no-rerank | Disable relevance optimisation |

### Examples with Options

# Get more results
bunx @mixedbread/mgrep -m 25 "user authentication flow"

# Show full content of matches
bunx @mixedbread/mgrep -c "error handling patterns"

# Get an AI-synthesised answer
bunx @mixedbread/mgrep -a "how does the caching layer work?"

# Sync index before searching
bunx @mixedbread/mgrep -s "payment processing" src/services


## Workflow

1. **Start watcher** (once per session or when files change significantly):
bunx @mixedbread/mgrep watch


2. **Search semantically**:
bunx @mixedbread/mgrep "what you're looking for" [optional/path]


3. **Refine as needed** using path constraints or options:
bunx @mixedbread/mgrep -m 20 -c "refined query" src/specific/directory


## Environment Variables

Configure defaults via environment variables:

| Variable | Purpose |
|----------|---------|
| MGREP_MAX_COUNT | Default result limit |
| MGREP_CONTENT | Enable content display (1/true) |
| MGREP_ANSWER | Enable AI synthesis (1/true) |
| MGREP_SYNC | Pre-search sync (1/true) |

## Important Notes

- Always use bunx @mixedbread/mgrep to run commands (not npm/npx or direct installation)
- Run bunx @mixedbread/mgrep watch before searching to ensure the index is current
- mgrep respects .gitignore patterns automatically
- Create .mgrepignore for additional exclusions

How to Use This Skill Unit

Option A: Project-Specific (Recommended)

  1. Click "Download" above
  2. In your project, create the directory: .agent/skills/mgrep-code-search/
  3. Save the file as SKILL.md
  4. The agent will automatically discover the skill based on its description.

Option B: Global Installation (All Agents)

Save the file to these locations to make it available across all projects:

  • Claude Code: ~/.claude/skills/intellectronica/agent-skills/mgrep-code-search/SKILL.md
  • Cursor: ~/.cursor/skills/intellectronica/agent-skills/mgrep-code-search/SKILL.md
  • Antigravity: ~/.gemini/antigravity/skills/intellectronica/agent-skills/mgrep-code-search/SKILL.md

πŸš€ Install with CLI:
npx skills add intellectronica/agent-skills

Read the Master Guide: Mastering Agent Skills β†’

Recommended Rules

View more rules β†’

Recommended Workflows

View more workflows β†’

Recommended MCP Servers

View more MCP servers β†’

Take It Further

Maximize your productivity with these powerful resources

πŸ“‹

Define Your Standards

Set up coding standards to ensure this workflow produces consistent, high-quality results.

Browse Rules Library
πŸ“–

Master Workflows

Learn how to create custom workflows, use Turbo Mode, and build your automation library.

Complete Guide

How to use this Skill in Claude Code & Cursor

For Claude Code (CLI)

To use this skill in Claude Code, copy the rule content into your project's custom instructions or follow our Add-Skill CLI guide. This ensures Claude follows your standards during every code generation.

For Cursor & Windsurf

For Cursor or Windsurf, individual skills are best used in the "Rules for AI" section. This specific unit helps the agent avoid ai tools & agents issues, leading to cleaner, more efficient code.

Why the skill format matters: the standardized Agent Skills format lets your AI agent load detailed instructions only when they are relevant, keeping your prompt clean while improving results.

Source & attribution

This skill is categorized under AI Tools & Agents and is published by intellectronica, maintained in intellectronica/agent-skills.

← Browse All Agent Skills
Sponsored AI assistant. Recommendations may be paid.