mcpField
R
repomix

repomix

github.com/jackspace开发1638 次安装12 周前更新
代码仓库

关于 repomix

Repomix Skill 为 Repomix 仓库打包工具提供使用指导,将代码库整理为便于 LLM 分析的单一文件。适用于代码审查、安全审计和文档准备等需要提供代码上下文的任务。

主要功能

  1. 01将代码库打包为单一文件
  2. 02支持 XML、Markdown、JSON 和纯文本
  3. 03处理远程仓库而无需克隆
  4. 04按模式筛选文件并移除注释
  5. 05统计 Token 并检查敏感信息

适用场景

  1. 01准备代码库供 AI 进行代码审查
  2. 02打包第三方库用于安全审计
  3. 03整理代码与文档以生成文档上下文
  4. 04收集相关模块以调查程序错误

MCP 相关

README 提到 Repomix 提供 MCP Server,可用于 AI 助手集成;未说明其具体暴露的能力。

安装

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

$npx skills add https://github.com/jackspace/claudeskillz --skill repomix

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

附带文件SKILL.json

详细介绍

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