关于 repomix
用于调用 Repomix 将本地或远程代码库打包为 AI 可读文件的技能,帮助开发者为 LLM 分析准备代码上下文,并提供格式选项、令牌计数和敏感信息检查。
主要功能
- 01打包本地和远程代码库
- 02输出 XML、Markdown、JSON 或纯文本
- 03按包含和忽略模式筛选文件
- 04统计令牌以规划上下文
- 05检查敏感信息
- 06移除受支持语言的注释
适用场景
- 01为 AI 代码审查准备代码库
- 02为安全审计创建上下文
- 03收集代码和文档以辅助文档编写
- 04打包指定模块以排查错误
MCP 相关
README 提到可通过 MCP Server 集成 AI 助手,但未提供更多细节。
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ mrgoonie/ claudekit-skills --skill repomix安装后在 Claude Code 中输入/repomix确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
references/configuration.mdusage-patterns.mdscripts/.coverageREADME.mdrepomix_batch.pyrepos.example.jsonrequirements.txtscripts/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 密钥)。
最佳实践:
- 分享前务必检查输出
- 使用
.repomixignore忽略敏感文件 - 处理未知代码库时启用安全检查
- 避免打包
.env文件 - 检查是否存在硬编码凭据
如有需要,可禁用安全检查:
repomix --no-security-check
实施工作流
用户请求打包代码仓库时:
-
评估需求
- 确定目标代码仓库(本地/远程)
- 确定所需的输出格式
- 检查是否涉及敏感数据
-
配置筛选条件
- 设置相关文件的包含模式
- 添加不必要文件的忽略模式
- 启用/禁用注释移除
-
执行打包
- 使用合适的选项运行 repomix
- 监控 token 数量
- 验证安全检查
-
验证输出
- 检查生成的文件
- 确认不包含敏感数据
- 检查是否符合目标大模型的 token 限制
-
提供上下文
- 向用户提供打包后的文件
- 附上 token 数量摘要
- 说明任何警告或问题
参考文档
详细信息请参阅:
其他资源
- GitHub:https://github.com/yamadashy/repomix
- 文档:https://repomix.com/guide/
- MCP 服务:可用于集成 AI 助手
评论
支持 Markdown