用途:将本地或远程代码仓库打包为单个 AI 友好文件,用于 LLM 分析、生成仓库快照、分析第三方库、安全审计、文档上下文生成、跨大型代码库排查缺陷等场景。
主要能力:
- 仓库打包:采用清晰分隔符的 AI 优化格式,支持 XML、Markdown、JSON、纯文本输出。
- Git 感知处理:遵循 .gitignore。
- Token 统计:统计单文件、整仓库及各输出格式的 token 数,便于控制 LLM 上下文长度。
- 安全检查:使用 Secretlint 检测 API 密钥、密码、凭据、私钥、AWS 密钥等敏感数据。
- 远程仓库支持:无需克隆即可处理远程仓库,支持简写、完整 URL 及指定提交。
- 注释移除:支持 HTML、CSS、JavaScript、TypeScript、Vue、Svelte、Python、PHP、Ruby、C、C#、Java、Go、Rust、Swift、Kotlin、Dart、Shell、YAML 等语言。
使用方式: 检查安装:repomix --version 安装:npm install -g repomix 或 brew install repomix 基本用法: repomix repomix --style markdown repomix --style json npx repomix --remote owner/repo repomix --include "src//*.ts" --remove-comments -o output.md 选择文件:repomix --include "src//.ts,.md"、repomix -i "tests/**,*.test.js"、repomix --no-gitignore 输出选项:repomix --style markdown|xml|json|plain、repomix -o output.md、repomix --remove-comments、repomix --copy 配置:repomix -c custom-config.json、repomix --init(创建 repomix.config.json) 远程示例:npx repomix --remote https://github.com/owner/repo、npx repomix --remote https://github.com/owner/repo/commit/hash
适用场景:代码评审准备、安全审计、文档生成、缺陷调查、实现规划等。
限制与注意事项:分享输出前务必检查;可用 .repomixignore 排除敏感文件;对未知代码库建议启用安全检查;避免打包 .env 文件;留意硬编码凭据;可用 repomix --no-security-check 关闭安全检查。典型 LLM 上下文上限参考:Claude Sonnet 4.5 约 200K、GPT-4 约 128K、GPT-3.5 约 16K tokens。更多文档见 https://github.com/yamadashy/repomix 与 https://repomix.com/guide/,并提供 MCP Server 供 AI 助手集成。