Repomix 的 Claude Code 官方插件:MCP 服务器、Slash 命令与 AI 仓库探索实战指南
Repomix 的 Claude Code 官方插件:MCP 服务器、Slash 命令与 AI 仓库探索实战指南
📅 发布时间:2026/9/12 17:27:46👁 浏览次数:
Repomix 的 Claude Code 官方插件MCP 服务器、Slash 命令与 AI 仓库探索实战指南【免费下载链接】repomix Repomix is a powerful tool that packs your entire repository into a single, AI-friendly file. Perfect for when you need to feed your codebase to Large Language Models (LLMs) or other AI tools like Claude, ChatGPT, DeepSeek, Perplexity, Gemini, Gemma, Llama, Grok, and more.项目地址: https://gitcode.com/GitHub_Trending/rep/repomixRepomix 为 Claude Code 提供了官方插件让开发者可以直接在 AI 编程环境中用自然语言完成代码库分析与打包。本文将完整介绍三个插件的安装流程、能力边界与真实命令并结合本仓库中插件源码.claude-plugin/marketplace.json、.claude/plugins逐条拆解其底层实现帮助你掌握从本地目录打包到远程仓库 AI 探索的完整工作流。一、插件总览三个插件分别解决什么问题Repomix 在 .claude-plugin/marketplace.json 中注册了三个插件它们各司其职、可以独立安装也可以组合使用插件类型核心能力repomix-mcpintegration通过 MCP 服务器集成提供 AI 代码库分析是推荐的基础组件repomix-commandsproductivity提供便捷的 Slash 命令支持自然语言打包本地/远程仓库repomix-explorerproductivityAI 分析代理用 Repomix CLI 智能探索代码库从源码看repomix-mcp被定位为地基它负责把整个仓库打包成单个 AI 友好文件并对外提供搜索、读取能力repomix-commands在这之上提供人性化的命令入口repomix-explorer则进一步把打包 grep 定向阅读封装成一套智能分析流程。三者的关系正如文档中的提示tip所述可以独立安装但三者齐全才能获得最完整的体验。二、安装步骤从添加市场到安装插件1. 添加 Repomix 插件市场在 Claude Code 中执行/plugin marketplace add yamadashy/repomix该命令将本仓库根目录的.claude-plugin目录注册为插件市场。仓库中的 marketplace.json 定义了市场元数据名称repomix、所有者yamadashy、版本1.0.2并声明了三个插件的源码位置与分类。2. 安装三个插件# 安装 MCP 服务器插件推荐的基础组件 /plugin install repomix-mcprepomix # 安装命令插件扩展功能 /plugin install repomix-commandsrepomix # 安装仓库探索插件AI 分析 /plugin install repomix-explorerrepomix其中repomix后缀表示从名为repomix的市场拉取。3. 替代方式交互式安装你也可以直接输入/plugin这会打开交互式安装界面在其中浏览并勾选安装可用插件效果与逐条命令安装相同。三、插件详解与源码实现1. repomix-mcpMCP 服务器插件这是基础插件通过 MCP 服务器集成提供 AI 代码库分析能力核心功能包括打包本地与远程仓库在打包后的输出文件中搜索读取生成的输出文件自动启用 Tree-sitter 压缩约减少 70% token从本仓库源码看MCP 服务器的具体工具实现位于 src/mcp/tools 目录包括packCodebaseTool打包代码库、packRemoteRepositoryTool打包远程仓库、grepRepomixOutputTool在输出中 grep、readRepomixOutputTool读取输出与attachPackedOutputTool附加打包结果等对应上述能力的底层实现。服务器的入口定义在 src/mcp/mcpServer.ts。2. repomix-commandsSlash 命令插件该插件在 .claude/plugins/repomix-commands/commands 中定义了三条核心能力所对应的两条命令/repomix-commands:pack-local— 以多种选项打包本地代码库/repomix-commands:pack-remote— 打包并分析远程 GitHub 仓库pack-local 的实现逻辑根据 pack-local.md该命令的工作方式是解析用户自然语言意图 → 决定打包目录、输出格式、是否压缩、文件过滤模式等 → 执行npx repomixlatest [directory] [options]。它支持的底层选项包括选项作用--style format输出格式xml默认、markdown、json、plain--include patterns仅包含匹配的文件如src/**/*.ts,**/*.md--ignore patterns追加忽略模式--compress启用 Tree-sitter 压缩约减少 70% token--output path自定义输出路径--copy将输出复制到剪贴板--include-diffs包含 git diff 输出--include-logs包含 git 提交历史命令源码还给出了一组典型映射示例# Pack this codebase npx repomixlatest # Pack the src directory npx repomixlatest src/ # Pack as markdown with compression npx repomixlatest --style markdown --compress # Pack only TypeScript and Markdown files npx repomixlatest --include src/**/*.ts,**/*.md # Pack and copy to clipboard npx repomixlatest --copy # Pack with git history npx repomixlatest --include-diffs --include-logspack-remote 的实现逻辑根据 pack-remote.md远程打包命令执行npx repomixlatest --remote repo [options]并支持以下仓库格式owner/repo如yamadashy/repomixhttps://github.com/owner/repohttps://github.com/owner/repo/tree/branch-name指定分支https://github.com/owner/repo/commit/hash指定提交# Pack yamadashy/repomix npx repomixlatest --remote yamadashy/repomix # Pack the develop branch of user/repo npx repomixlatest --remote https://github.com/user/repo/tree/develop # Pack microsoft/vscode with compression npx repomixlatest --remote microsoft/vscode --compress # Pack only TypeScript files from owner/repo npx repomixlatest --remote owner/repo --include src/**/*.ts3. repomix-explorerAI 分析代理插件这是三款插件中最智能的一个其代理定义在 .claude/plugins/repomix-explorer/agents/explorer.md提供两条命令/repomix-explorer:explore-local— AI 辅助分析本地代码库/repomix-explorer:explore-remote— AI 辅助分析远程 GitHub 仓库核心能力自然语言探索与分析代码库智能发现模式、理解代码结构使用 grep 与定向文件读取进行增量分析针对大型仓库自动管理上下文工作流程三步递进运行npx repomixlatest将仓库打包为单个文件使用 Grep 与 Read 工具高效检索输出文件先 grep 定位、再按需读取片段绝不整读大文件在不消耗过多上下文的前提下输出综合分析结论。从 explorer.md 的源码可以看出代理被设计为专家代码分析师它内置了如下工程化规范效率规范超过 10 万行的大型仓库强制使用--compress先 Grep 后 Read分析多个仓库时用--output指定自定义路径避免互相覆盖输出格式建议默认推荐 XML结构化、文件边界清晰Plain 便于 grep、Markdown 适合文档、JSON 适合程序化处理模式检索模板内置了函数/类、导入依赖、认证授权、API 端点、数据库模型、错误处理等多组grep -iE模式示例可直接套用自检清单完成分析前逐一核对是否记录指标、是否高效使用 Grep、结论是否有真实数据支撑等。命令入口文件 explore-local.md 与 explore-remote.md 还规定命令本身只负责解析路径/仓库并启动explorer代理实际分析全部交由代理完成——这种薄命令层 厚代理层的分层设计保证了命令响应快、分析深度足。四、实战用例四条命令的完整演示场景一打包本地代码库使用/repomix-commands:pack-local配合自然语言指令/repomix-commands:pack-local Pack this project as markdown with compression其他常用说法Pack the src directory onlyPack TypeScript files with line numbersGenerate output in JSON format场景二打包远程仓库使用/repomix-commands:pack-remote分析 GitHub 仓库/repomix-commands:pack-remote yamadashy/repomix Pack only TypeScript files from the yamadashy/repomix repository其他常用说法Pack the main branch with compressionInclude only documentation filesPack specific directories场景三AI 探索本地代码库使用/repomix-explorer:explore-local进行 AI 分析/repomix-explorer:explore-local ./src Find all authentication-related code其他常用说法Analyze the structure of this projectShow me the main componentsFind all API endpoints场景四AI 探索远程仓库使用/repomix-explorer:explore-remote分析 GitHub 仓库/repomix-explorer:explore-remote facebook/react Show me the main component architecture其他常用说法Find all React hooks in the repositoryExplain the project structureWhere are error boundaries defined?五、配套学习资源要深入理解这些插件背后的能力可以继续阅读本仓库内的相关文档MCP 服务器文档 — 了解底层 MCP 服务器的实现配置文档 — 定制 Repomix 的行为安全文档 — 理解安全过滤机制命令行选项文档 — 查看全部可用 CLI 选项三个插件的源码也都保存在本仓库中插件市场清单见 .claude-plugin/marketplace.json命令与代理定义见 .claude/plugins/repomix-commands、.claude/plugins/repomix-explorer 与 .claude/plugins/repomix-mcp。遇到问题时也可运行npx repomixlatest --help查看全部 CLI 选项作为排错依据。【免费下载链接】repomix Repomix is a powerful tool that packs your entire repository into a single, AI-friendly file. Perfect for when you need to feed your codebase to Large Language Models (LLMs) or other AI tools like Claude, ChatGPT, DeepSeek, Perplexity, Gemini, Gemma, Llama, Grok, and more.项目地址: https://gitcode.com/GitHub_Trending/rep/repomix创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考