mgrep-code-search
Install this skill
npx skills add intellectronica/agent-skillsWorks 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
- Install and confirm the Bun runtime is available
- Run 'bunx @mixedbread/mgrep watch' in the root directory to build the index
- Execute a natural language query using 'bunx @mixedbread/mgrep "search query"'
- Refine the scope by adding a path argument like 'src/components'
- 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
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.
π Full skill instructions β original source: intellectronica/agent-skills
## 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 watchThe
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 watch2. **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 exclusionsHow to Use This Skill Unit
Option A: Project-Specific (Recommended)
- Click "Download" above
- In your project, create the directory:
.agent/skills/mgrep-code-search/ - Save the file as
SKILL.md - 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