repomix

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Repomix Skill

Repomix Skill

Repomix packs entire repositories into single, AI-friendly files. Perfect for feeding codebases to LLMs like Claude, ChatGPT, and Gemini.
Repomix 可将整个代码仓库打包为单个AI友好型文件,非常适合将代码库提供给Claude、ChatGPT和Gemini等LLM使用。

When to Use

适用场景

Use when:
  • Packaging codebases for AI analysis
  • Creating repository snapshots for LLM context
  • Analyzing third-party libraries
  • Preparing for security audits
  • Generating documentation context
  • Investigating bugs across large codebases
  • Creating AI-friendly code representations
适用于以下场景:
  • 为AI分析打包代码库
  • 为LLM上下文创建仓库快照
  • 分析第三方库
  • 准备安全审计
  • 生成文档上下文
  • 排查跨大型代码库的Bug
  • 创建AI友好型代码表示

Quick Start

快速开始

Check Installation

检查安装

bash
repomix --version
bash
repomix --version

Install

安装

bash
undefined
bash
undefined

npm

npm

npm install -g repomix
npm install -g repomix

Homebrew (macOS/Linux)

Homebrew (macOS/Linux)

brew install repomix
undefined
brew install repomix
undefined

Basic Usage

基础用法

bash
undefined
bash
undefined

Package current directory (generates repomix-output.xml)

打包当前目录(生成repomix-output.xml)

repomix
repomix

Specify output format

指定输出格式

repomix --style markdown repomix --style json
repomix --style markdown repomix --style json

Package remote repository

打包远程仓库

npx repomix --remote owner/repo
npx repomix --remote owner/repo

Custom output with filters

带过滤规则的自定义输出

repomix --include "src/**/*.ts" --remove-comments -o output.md
undefined
repomix --include "src/**/*.ts" --remove-comments -o output.md
undefined

Core Capabilities

核心功能

Repository Packaging

仓库打包

  • AI-optimized formatting with clear separators
  • Multiple output formats: XML, Markdown, JSON, Plain text
  • Git-aware processing (respects .gitignore)
  • Token counting for LLM context management
  • Security checks for sensitive information
  • 采用AI优化格式,带有清晰分隔符
  • 多种输出格式:XML、Markdown、JSON、纯文本
  • 支持Git感知处理(遵循.gitignore规则)
  • 用于LLM上下文管理的Token计数
  • 敏感信息安全检查

Remote Repository Support

远程仓库支持

Process remote repositories without cloning:
bash
undefined
无需克隆即可处理远程仓库:
bash
undefined

Shorthand

简写形式

npx repomix --remote yamadashy/repomix
npx repomix --remote yamadashy/repomix

Full URL

完整URL

npx repomix --remote https://github.com/owner/repo
npx repomix --remote https://github.com/owner/repo

Specific commit

指定提交版本

undefined
undefined

Comment Removal

移除注释

Strip comments from supported languages (HTML, CSS, JavaScript, TypeScript, Vue, Svelte, Python, PHP, Ruby, C, C#, Java, Go, Rust, Swift, Kotlin, Dart, Shell, YAML):
bash
repomix --remove-comments
可移除支持语言的注释(HTML、CSS、JavaScript、TypeScript、Vue、Svelte、Python、PHP、Ruby、C、C#、Java、Go、Rust、Swift、Kotlin、Dart、Shell、YAML):
bash
repomix --remove-comments

Common Use Cases

常见使用场景

Code Review Preparation

代码审查准备

bash
undefined
bash
undefined

Package feature branch for AI review

打包特性分支用于AI审查

repomix --include "src/**/*.ts" --remove-comments -o review.md --style markdown
undefined
repomix --include "src/**/*.ts" --remove-comments -o review.md --style markdown
undefined

Security Audit

安全审计

bash
undefined
bash
undefined

Package third-party library

打包第三方库

npx repomix --remote vendor/library --style xml -o audit.xml
undefined
npx repomix --remote vendor/library --style xml -o audit.xml
undefined

Documentation Generation

文档生成

bash
undefined
bash
undefined

Package with docs and code

打包文档和代码

repomix --include "src/,docs/,*.md" --style markdown -o context.md
undefined
repomix --include "src/,docs/,*.md" --style markdown -o context.md
undefined

Bug Investigation

Bug排查

bash
undefined
bash
undefined

Package specific modules

打包特定模块

repomix --include "src/auth/,src/api/" -o debug-context.xml
undefined
repomix --include "src/auth/,src/api/" -o debug-context.xml
undefined

Implementation Planning

实施规划

bash
undefined
bash
undefined

Full codebase context

完整代码库上下文

repomix --remove-comments --copy
undefined
repomix --remove-comments --copy
undefined

Command Line Reference

命令行参考

File Selection

文件选择

bash
undefined
bash
undefined

Include specific patterns

包含特定模式

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

Ignore additional patterns

忽略额外模式

repomix -i "tests/**,*.test.js"
repomix -i "tests/**,*.test.js"

Disable .gitignore rules

禁用.gitignore规则

repomix --no-gitignore
undefined
repomix --no-gitignore
undefined

Output Options

输出选项

bash
undefined
bash
undefined

Output format

输出格式

repomix --style markdown # or xml, json, plain
repomix --style markdown # 或 xml, json, plain

Output file path

输出文件路径

repomix -o output.md
repomix -o output.md

Remove comments

移除注释

repomix --remove-comments
repomix --remove-comments

Copy to clipboard

复制到剪贴板

repomix --copy
undefined
repomix --copy
undefined

Configuration

配置

bash
undefined
bash
undefined

Use custom config file

使用自定义配置文件

repomix -c custom-config.json
repomix -c custom-config.json

Initialize new config

初始化新配置

repomix --init # creates repomix.config.json
undefined
repomix --init # 创建repomix.config.json
undefined

Token Management

Token管理

Repomix automatically counts tokens for individual files, total repository, and per-format output.
Typical LLM context limits:
  • Claude Sonnet 4.5: ~200K tokens
  • GPT-4: ~128K tokens
  • GPT-3.5: ~16K tokens
Repomix会自动统计单个文件、整个仓库以及各格式输出的Token数量。
典型LLM上下文限制:
  • Claude Sonnet 4.5: ~200K tokens
  • GPT-4: ~128K tokens
  • GPT-3.5: ~16K tokens

Security Considerations

安全注意事项

Repomix uses Secretlint to detect sensitive data (API keys, passwords, credentials, private keys, AWS secrets).
Best practices:
  1. Always review output before sharing
  2. Use
    .repomixignore
    for sensitive files
  3. Enable security checks for unknown codebases
  4. Avoid packaging
    .env
    files
  5. Check for hardcoded credentials
Disable security checks if needed:
bash
repomix --no-security-check
Repomix使用Secretlint检测敏感数据(API密钥、密码、凭证、私钥、AWS密钥等)。
最佳实践:
  1. 分享前务必检查输出内容
  2. 使用.repomixignore忽略敏感文件
  3. 对未知代码库启用安全检查
  4. 避免打包.env文件
  5. 检查是否存在硬编码凭证
如需禁用安全检查:
bash
repomix --no-security-check

Implementation Workflow

实施流程

When user requests repository packaging:
  1. Assess Requirements
    • Identify target repository (local/remote)
    • Determine output format needed
    • Check for sensitive data concerns
  2. Configure Filters
    • Set include patterns for relevant files
    • Add ignore patterns for unnecessary files
    • Enable/disable comment removal
  3. Execute Packaging
    • Run repomix with appropriate options
    • Monitor token counts
    • Verify security checks
  4. Validate Output
    • Review generated file
    • Confirm no sensitive data
    • Check token limits for target LLM
  5. Deliver Context
    • Provide packaged file to user
    • Include token count summary
    • Note any warnings or issues
当用户请求仓库打包时:
  1. 需求评估
    • 确定目标仓库(本地/远程)
    • 确认所需输出格式
    • 检查敏感数据相关顾虑
  2. 配置过滤规则
    • 设置相关文件的包含模式
    • 添加不必要文件的忽略模式
    • 启用/禁用注释移除
  3. 执行打包
    • 使用合适选项运行repomix
    • 监控Token计数
    • 验证安全检查结果
  4. 验证输出
    • 检查生成的文件
    • 确认无敏感数据
    • 核对目标LLM的Token限制
  5. 交付上下文
    • 向用户提供打包后的文件
    • 包含Token计数摘要
    • 标注任何警告或问题

Reference Documentation

参考文档

For detailed information, see:
  • Configuration Reference - Config files, include/exclude patterns, output formats, advanced options
  • Usage Patterns - AI analysis workflows, security audit preparation, documentation generation, library evaluation
如需详细信息,请查看:
  • 配置参考 - 配置文件、包含/排除模式、输出格式、高级选项
  • 使用模式 - AI分析工作流、安全审计准备、文档生成、库评估

Additional Resources

更多资源