Skip to content

Repomix

Pack your codebase into AI-friendly formats

Output Format

Include Patterns (using glob patterns)

Ignore Patterns

Output Options

快速开始

使用 Repomix 生成打包文件(repomix-output.txt)后,您可以将其发送给 AI 助手,并附上这样的提示:

此文件包含了仓库中所有文件的合并内容。
我想重构代码,请先帮我审查一下。

AI 将分析您的整个代码库并提供全面的见解:

Repomix 使用示例1

在讨论具体修改时,AI 可以帮助生成代码。通过像 Claude 的 Artifacts 这样的功能,您甚至可以一次性接收多个相互依赖的文件:

Repomix 使用示例2

祝您编码愉快!🚀

进阶使用指南

对于需要更多控制的高级用户,Repomix 通过其 CLI 界面提供了广泛的自定义选项。

快速上手

您可以在项目目录中无需安装即可立即尝试 Repomix:

bash
npx repomix

或者全局安装以便重复使用:

bash
# 使用 npm 安装
npm install -g repomix

# 或使用 yarn 安装
yarn global add repomix

# 或使用 Homebrew 安装(macOS/Linux)
brew install repomix

# 然后在任意项目目录中运行
repomix

就是这么简单!Repomix 将在您的当前目录中生成一个 repomix-output.txt 文件,其中包含了以 AI 友好格式整理的整个代码库。

基本用法

打包整个代码库:

bash
repomix

打包特定目录:

bash
repomix path/to/directory

使用 glob 模式打包特定文件:

bash
repomix --include "src/**/*.ts,**/*.md"

排除特定文件:

bash
repomix --ignore "**/*.log,tmp/"

处理远程仓库:

bash
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):

bash
repomix --init

生成打包文件后,您可以将其用于 Claude、ChatGPT、Gemini 等生成式 AI 工具。

Docker 使用方法

您也可以使用 Docker 运行 Repomix 🐳
如果您想在隔离环境中运行 Repomix 或更偏好使用容器,这是一个很好的选择。

基本用法(当前目录):

bash
docker run -v .:/app -it --rm ghcr.io/yamadashy/repomix

打包特定目录:

bash
docker run -v .:/app -it --rm ghcr.io/yamadashy/repomix path/to/directory

处理远程仓库并输出到 output 目录:

bash
docker run -v ./output:/app -it --rm ghcr.io/yamadashy/repomix --remote https://github.com/yamadashy/repomix

输出格式

选择您偏好的输出格式:

bash
# XML 格式(默认)
repomix --style xml

# Markdown 格式
repomix --style markdown

# 纯文本格式
repomix --style plain

自定义设置

创建 repomix.config.json 进行持久化设置:

json
{
  "output": {
    "style": "markdown",
    "filePath": "custom-output.md",
    "removeComments": true,
    "showLineNumbers": true,
    "topFilesLength": 10
  },
  "ignore": {
    "customPatterns": ["*.test.ts", "docs/**"]
  }
}

更多示例

TIP

💡 查看我们的 GitHub 仓库获取完整文档和更多示例!

Released under the MIT License.