mcpField
R
repomix

repomix

github.com/mrgoonieAgent 工作流2.2k403 次安装30 周前更新
代码仓库

关于 repomix

用于调用 Repomix 将本地或远程代码库打包为 AI 可读文件的技能,帮助开发者为 LLM 分析准备代码上下文,并提供格式选项、令牌计数和敏感信息检查。

主要功能

  1. 01打包本地和远程代码库
  2. 02输出 XML、Markdown、JSON 或纯文本
  3. 03按包含和忽略模式筛选文件
  4. 04统计令牌以规划上下文
  5. 05检查敏感信息
  6. 06移除受支持语言的注释

适用场景

  1. 01为 AI 代码审查准备代码库
  2. 02为安全审计创建上下文
  3. 03收集代码和文档以辅助文档编写
  4. 04打包指定模块以排查错误

MCP 相关

README 提到可通过 MCP Server 集成 AI 助手,但未提供更多细节。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/mrgoonie/claudekit-skills --skill repomix

安装后在 Claude Code 中输入/repomix确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

references/
configuration.md
usage-patterns.md
scripts/
.coverage
README.md
repomix_batch.py
repos.example.json
requirements.txt
scripts/tests/
test_repomix_batch.py

详细介绍

Repomix 技能

Repomix 可将整个代码仓库打包成单个适合 AI 使用的文件,非常适合将代码库提供给 Claude、ChatGPT 和 Gemini 等大模型。

适用场景

适用于:

  • 为 AI 分析打包代码库
  • 为大模型上下文创建代码仓库快照
  • 分析第三方库
  • 为安全审计做准备
  • 生成文档上下文
  • 调查大型代码库中的错误
  • 创建适合 AI 使用的代码表示

快速开始

检查安装情况
repomix --version
安装
# npm
npm install -g repomix

# Homebrew (macOS/Linux)
brew install repomix
基本用法
# Package current directory (generates repomix-output.xml)
repomix

# Specify output format
repomix --style markdown
repomix --style json

# Package remote repository
npx repomix --remote owner/repo

# Custom output with filters
repomix --include "src/**/*.ts" --remove-comments -o output.md

核心功能

代码仓库打包
  • 针对 AI 优化的格式,并使用清晰的分隔符
  • 多种输出格式:XML、Markdown、JSON、纯文本
  • 感知 Git 的处理方式(遵循 .gitignore)
  • 统计 token 数量,便于管理大模型上下文
  • 检查敏感信息,确保安全
远程代码仓库支持

无需克隆即可处理远程代码仓库:

# Shorthand
npx repomix --remote yamadashy/repomix

# Full URL
npx repomix --remote https://github.com/owner/repo

# Specific commit
npx repomix --remote https://github.com/owner/repo/commit/hash
移除注释

移除受支持语言中的注释(HTML、CSS、JavaScript、TypeScript、Vue、Svelte、Python、PHP、Ruby、C、C#、Java、Go、Rust、Swift、Kotlin、Dart、Shell、YAML):

repomix --remove-comments

常见用例

准备代码审查
# Package feature branch for AI review
repomix --include "src/**/*.ts" --remove-comments -o review.md --style markdown
安全审计
# Package third-party library
npx repomix --remote vendor/library --style xml -o audit.xml
生成文档
# Package with docs and code
repomix --include "src/**,docs/**,*.md" --style markdown -o context.md
调查错误
# Package specific modules
repomix --include "src/auth/**,src/api/**" -o debug-context.xml
规划实现方案
# Full codebase context
repomix --remove-comments --copy

命令行参考

文件选择
# Include specific patterns
repomix --include "src/**/*.ts,*.md"

# Ignore additional patterns
repomix -i "tests/**,*.test.js"

# Disable .gitignore rules
repomix --no-gitignore
输出选项
# Output format
repomix --style markdown  # or xml, json, plain

# Output file path
repomix -o output.md

# Remove comments
repomix --remove-comments

# Copy to clipboard
repomix --copy
配置
# Use custom config file
repomix -c custom-config.json

# Initialize new config
repomix --init  # creates repomix.config.json

Token 管理

Repomix 会自动统计单个文件、整个代码仓库以及各类输出格式的 token 数量。

大模型的典型上下文限制:

  • Claude Sonnet 4.5:约 200K 个 token
  • GPT-4:约 128K 个 token
  • GPT-3.5:约 16K 个 token

安全注意事项

Repomix 使用 Secretlint 检测敏感数据(API 密钥、密码、凭据、私钥、AWS 密钥)。

最佳实践:

  1. 分享前务必检查输出
  2. 使用 .repomixignore 忽略敏感文件
  3. 处理未知代码库时启用安全检查
  4. 避免打包 .env 文件
  5. 检查是否存在硬编码凭据

如有需要,可禁用安全检查:

repomix --no-security-check

实施工作流

用户请求打包代码仓库时:

  1. 评估需求

    • 确定目标代码仓库(本地/远程)
    • 确定所需的输出格式
    • 检查是否涉及敏感数据
  2. 配置筛选条件

    • 设置相关文件的包含模式
    • 添加不必要文件的忽略模式
    • 启用/禁用注释移除
  3. 执行打包

    • 使用合适的选项运行 repomix
    • 监控 token 数量
    • 验证安全检查
  4. 验证输出

    • 检查生成的文件
    • 确认不包含敏感数据
    • 检查是否符合目标大模型的 token 限制
  5. 提供上下文

    • 向用户提供打包后的文件
    • 附上 token 数量摘要
    • 说明任何警告或问题

参考文档

详细信息请参阅:

  • 配置参考 - 配置文件、包含/排除模式、输出格式和高级选项
  • 用法模式 - AI 分析工作流、安全审计准备、文档生成和库评估

其他资源

评论

支持 Markdown