用途:Repomix 用于把整个代码仓库打包成单个 AI 友好的文件,方便将代码库作为上下文喂给 Claude、ChatGPT、Gemini 等大模型,适用于 AI 分析代码库、生成仓库快照、分析第三方库、准备安全审计、生成文档上下文、排查大型代码库缺陷等场景。
主要能力:支持 AI 优化格式与清晰分隔符;输出格式包括 XML、Markdown、JSON 和纯文本;遵循 .gitignore 的 Git 感知处理;统计单个文件、整个仓库及各格式输出的 Token 数;使用 Secretlint 检测 API 密钥、密码、凭据、私钥、AWS 密钥等敏感信息;支持不克隆直接处理远程仓库,可指定提交;可移除 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-output.xml;repomix --style markdown 或 --style json 指定格式;npx repomix --remote owner/repo 打包远程仓库;repomix --include "src/**/*.ts" --remove-comments -o output.md 自定义过滤与输出。文件选择可用 --include、-i 忽略模式、--no-gitignore;输出可用 --style、-o、--remove-comments、--copy;配置可用 -c custom-config.json 或 --init 生成 repomix.config.json。
限制与注意:分享前应始终检查输出,使用 .repomixignore 排除敏感文件,对未知代码库启用安全检查,避免打包 .env 文件,检查硬编码凭据;必要时可用 repomix --no-security-check 关闭安全检查。典型 LLM 上下文限制:Claude Sonnet 4.5 约 200K tokens,GPT-4 约 128K tokens,GPT-3.5 约 16K tokens。更多信息见 GitHub https://github.com/yamadashy/repomix 与文档 https://repomix.com/guide/,另有 MCP Server 可用于 AI 助手集成。