AI 优化
以 AI 易于理解和处理的方式格式化代码库。
Pack your codebase into AI-friendly formats
使用 Repomix 生成打包文件(repomix-output.txt
)后,您可以将其发送给 AI 助手,并附上这样的提示:
此文件包含了仓库中所有文件的合并内容。
我想重构代码,请先帮我审查一下。
AI 将分析您的整个代码库并提供全面的见解:
在讨论具体修改时,AI 可以帮助生成代码。通过像 Claude 的 Artifacts 这样的功能,您甚至可以一次性接收多个相互依赖的文件:
祝您编码愉快!🚀
对于需要更多控制的高级用户,Repomix 通过其 CLI 界面提供了广泛的自定义选项。
您可以在项目目录中无需安装即可立即尝试 Repomix:
npx repomix
或者全局安装以便重复使用:
# 使用 npm 安装
npm install -g repomix
# 或使用 yarn 安装
yarn global add repomix
# 或使用 Homebrew 安装(macOS/Linux)
brew install repomix
# 然后在任意项目目录中运行
repomix
就是这么简单!Repomix 将在您的当前目录中生成一个 repomix-output.txt
文件,其中包含了以 AI 友好格式整理的整个代码库。
打包整个代码库:
repomix
打包特定目录:
repomix path/to/directory
使用 glob 模式打包特定文件:
repomix --include "src/**/*.ts,**/*.md"
排除特定文件:
repomix --ignore "**/*.log,tmp/"
处理远程仓库:
repomix --remote https://github.com/yamadashy/repomix
# 也可以使用 GitHub 简写形式:
repomix --remote yamadashy/repomix
# 可以指定分支名称、标签或提交哈希:
repomix --remote https://github.com/yamadashy/repomix --remote-branch main
# 或使用特定的提交哈希:
repomix --remote https://github.com/yamadashy/repomix --remote-branch 935b695
初始化配置文件(repomix.config.json
):
repomix --init
生成打包文件后,您可以将其用于 Claude、ChatGPT、Gemini 等生成式 AI 工具。
您也可以使用 Docker 运行 Repomix 🐳
如果您想在隔离环境中运行 Repomix 或更偏好使用容器,这是一个很好的选择。
基本用法(当前目录):
docker run -v .:/app -it --rm ghcr.io/yamadashy/repomix
打包特定目录:
docker run -v .:/app -it --rm ghcr.io/yamadashy/repomix path/to/directory
处理远程仓库并输出到 output
目录:
docker run -v ./output:/app -it --rm ghcr.io/yamadashy/repomix --remote https://github.com/yamadashy/repomix
选择您偏好的输出格式:
# XML 格式(默认)
repomix --style xml
# Markdown 格式
repomix --style markdown
# 纯文本格式
repomix --style plain
创建 repomix.config.json
进行持久化设置:
{
"output": {
"style": "markdown",
"filePath": "custom-output.md",
"removeComments": true,
"showLineNumbers": true,
"topFilesLength": 10
},
"ignore": {
"customPatterns": ["*.test.ts", "docs/**"]
}
}
TIP
💡 查看我们的 GitHub 仓库获取完整文档和更多示例!