# Mgrep Code Search > Semantic code search using mgrep for efficient codebase exploration. This skill should be used when searching or exploring codebases with more than 30 non-gitignored files and/or nested directory structures. It provides natural language semantic search that complements traditional grep/ripgrep for finding features, understanding intent, and exploring unfamiliar code. Source: https://skillsagentes.com/skills/intellectronica/agent-skills/mgrep-code-search Repository: https://github.com/intellectronica/agent-skills Author: intellectronica License: CC0-1.0 Updated: hace 6 meses Context cost: 92 tok installed, 870 tok once triggered, 870 tok with every bundled file Bundle: 1 file, 3 KB Permissions requested: none declared ## Install ```bash npx -y skills add intellectronica/agent-skills --skill mgrep-code-search --agent claude-code ``` ## What it does - Realiza búsquedas semánticas en lenguaje natural sobre código, texto, PDFs e imágenes usando mgrep - Indexa el repositorio con bunx @mixedbread/mgrep watch, respetando .gitignore y .mgrepignore - Permite refinar búsquedas con opciones como -m, -c, -a y -s, y restringir por ruta ## Use it when - El codebase tiene más de 30 archivos no ignorados por git - Hay estructuras de directorios anidadas - Se busca por concepto, funcionalidad o intención en vez de una cadena exacta - Se explora un codebase desconocido o se necesita entender dónde o cómo está implementado algo ## Don't bother when - Se busca un patrón o símbolo exacto - Es una refactorización basada en regex - Se rastrea un nombre específico de función o variable (usar grep/ripgrep en su lugar) ## What triggers it - "¿Dónde está configurada la autenticación en este proyecto?" - "¿Cómo manejamos los errores en las llamadas a la API?" - "Explora cómo funciona la capa de caché en este codebase" - "Busca semánticamente cómo se procesa el pago en src/services" ## Before you install - Requiere ejecutar bunx @mixedbread/mgrep (no npm/npx ni instalación directa) y correr `watch` antes de buscar para mantener el índice actualizado. ## Files - SKILL.md — 3 KB ## SKILL.md Reproduced verbatim from intellectronica/agent-skills under CC0-1.0. This section is the upstream document and is in English. # 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: ```bash bunx @mixedbread/mgrep watch ``` The `watch` command indexes the repository and maintains synchronisation with file changes. It respects `.gitignore` and `.mgrepignore` patterns. ### Searching ```bash bunx @mixedbread/mgrep "your natural language query" [path] ``` ## Search Commands ### Basic Search ```bash 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 ` | 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 ```bash # 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): ```bash bunx @mixedbread/mgrep watch ``` 2. **Search semantically**: ```bash bunx @mixedbread/mgrep "what you're looking for" [optional/path] ``` 3. **Refine as needed** using path constraints or options: ```bash 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 --- Skills Agentes — https://skillsagentes.com/skills/intellectronica/agent-skills/mgrep-code-search