Mgrep Code Search

作者 intellectronica9b0e00ad1b94無授權條款295 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫5 個月前更新

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.

AI 產生的概覽

指導使用 mgrep 命令列工具進行語意程式碼搜尋,以自然語言查詢探索大型或不熟悉的程式碼庫。

功能
此技能提供使用 mgrep 命令列工具進行語意化自然語言搜尋的說明,可搜尋程式碼、文字、PDF 與圖片。內容涵蓋透過監看程序為儲存庫建立索引、加上路徑限制執行搜尋,以及使用結果數量上限、完整內容顯示、AI 合成答案與索引同步等選項。它也列出用於設定預設值的環境變數,並說明 mgrep 會遵循 .gitignore 與 .mgrepignore 模式。
適用情境
適用於探索包含 30 個以上未被 gitignore 忽略的檔案或具有巢狀目錄結構的程式碼庫,或需要依概念、功能或意圖而非精確字串進行搜尋的情境。它用於理解不熟悉的程式碼中某功能在何處或如何實作,而精確模式比對與正規表達式重構仍適合使用傳統 grep 或 ripgrep。
執行需求
需要 bunx 執行階段來執行從網路取得的 @mixedbread/mgrep 套件;此技能不附帶指令碼。選用環境變數(MGREP_MAX_COUNT、MGREP_CONTENT、MGREP_ANSWER、MGREP_SYNC)用於設定預設值。

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

OptionDescription
-m <count>Maximum results (default: 10)
-c, --contentDisplay full result content
-a, --answerGenerate AI-powered synthesis of results
-s, --syncUpdate index before searching
--no-rerankDisable relevance optimisation

Examples with Options

bash
# Get more resultsbunx @mixedbread/mgrep -m 25 "user authentication flow"
# Show full content of matchesbunx @mixedbread/mgrep -c "error handling patterns"
# Get an AI-synthesised answerbunx @mixedbread/mgrep -a "how does the caching layer work?"
# Sync index before searchingbunx @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:

VariablePurpose
MGREP_MAX_COUNTDefault result limit
MGREP_CONTENTEnable content display (1/true)
MGREP_ANSWEREnable AI synthesis (1/true)
MGREP_SYNCPre-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

來源與署名

來源:intellectronica/agent-skills位於skills/mgrep-code-search提交9b0e00a

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架