repomix
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRepomix Skill
Repomix 技能
Repomix is a powerful tool that packs entire repositories into single, AI-friendly files. Perfect for when you need to feed codebases to Large Language Models (LLMs) or other AI tools like Claude, ChatGPT, and Gemini.
Repomix 是一款强大的工具,可将整个代码仓库打包为单个适配AI的文件。非常适合需要将代码库提交给大语言模型(LLM)或Claude、ChatGPT、Gemini等其他AI工具的场景。
When to Use This Skill
适用场景
Use this skill when:
- User needs to package a codebase for AI analysis
- Preparing repository context for LLM consumption
- Generating codebase snapshots for documentation
- Analyzing third-party libraries or repositories
- Creating AI-friendly representations of code projects
- Investigating bugs across large codebases
- Performing security audits on repositories
- Generating context for implementation planning
在以下场景使用本技能:
- 用户需要为AI分析打包代码库
- 为LLM准备仓库上下文
- 生成代码库快照用于文档编制
- 分析第三方库或代码仓库
- 创建代码项目的AI友好型表示
- 排查大型代码库中的Bug
- 对代码仓库执行安全审计
- 为实现规划生成上下文
Core Capabilities
核心功能
1. Repository Packaging
1. 代码仓库打包
Repomix packages entire repositories into single files with:
- 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
Repomix 可将整个代码仓库打包为单个文件,具备以下特性:
- 采用AI优化格式,带有清晰分隔符
- 支持多种输出格式(XML、Markdown、JSON、纯文本)
- 感知Git的处理逻辑(遵循.gitignore规则)
- 用于LLM上下文管理的Token计数
- 敏感信息安全检查
2. Remote Repository Support
2. 远程仓库支持
Can process remote repositories without cloning:
- Shorthand:
npx repomix --remote yamadashy/repomix - Full URL:
npx repomix --remote https://github.com/owner/repo - Specific commits:
npx repomix --remote https://github.com/owner/repo/commit/hash
无需克隆即可处理远程仓库:
- 简写格式:
npx repomix --remote yamadashy/repomix - 完整URL:
npx repomix --remote https://github.com/owner/repo - 指定提交版本:
npx repomix --remote https://github.com/owner/repo/commit/hash
3. Comment Removal
3. 注释移除
Strips comments from supported languages when needed:
- Supported: HTML, CSS, JavaScript, TypeScript, Vue, Svelte, Python, PHP, Ruby, C, C#, Java, Go, Rust, Swift, Kotlin, Dart, Shell, YAML
- Enable with: or config file
--remove-comments
可按需移除支持语言的注释:
- 支持语言:HTML、CSS、JavaScript、TypeScript、Vue、Svelte、Python、PHP、Ruby、C、C#、Java、Go、Rust、Swift、Kotlin、Dart、Shell、YAML
- 启用方式:参数或配置文件
--remove-comments
Installation
安装
Check if installed first:
bash
repomix --versionInstall using preferred method:
bash
undefined先检查是否已安装:
bash
repomix --version通过以下方式安装:
bash
undefinednpm
npm
npm install -g repomix
npm install -g repomix
yarn
yarn
yarn global add repomix
yarn global add repomix
bun
bun
bun add -g repomix
bun add -g repomix
Homebrew (macOS/Linux)
Homebrew(macOS/Linux)
brew install repomix
undefinedbrew install repomix
undefinedBasic Usage
基础用法
Package Current Directory
打包当前目录
bash
undefinedbash
undefinedBasic packaging (generates repomix-output.xml)
基础打包(生成repomix-output.xml)
repomix
repomix
Specify output format
指定输出格式
repomix --style markdown
repomix --style json
repomix --style plain
repomix --style markdown
repomix --style json
repomix --style plain
Custom output path
自定义输出路径
repomix -o custom-output.xml
undefinedrepomix -o custom-output.xml
undefinedPackage Specific Directory
打包指定目录
bash
repomix /path/to/directorybash
repomix /path/to/directoryPackage Remote Repository
打包远程仓库
bash
undefinedbash
undefinedShorthand format
简写格式
npx repomix --remote owner/repo
npx repomix --remote owner/repo
Full URL
完整URL
npx repomix --remote https://github.com/owner/repo
npx repomix --remote https://github.com/owner/repo
Specific commit
指定提交版本
npx repomix --remote https://github.com/owner/repo/commit/abc123
undefinednpx repomix --remote https://github.com/owner/repo/commit/abc123
undefinedCommand Line Options
命令行选项
File Selection
文件选择
bash
undefinedbash
undefinedInclude 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
repomix --no-gitignore
Disable default ignore patterns
禁用默认忽略模式
repomix --no-default-patterns
undefinedrepomix --no-default-patterns
undefinedOutput Configuration
输出配置
bash
undefinedbash
undefinedOutput 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
Show line numbers
隐藏行号
repomix --no-line-numbers # disable line numbers
undefinedrepomix --no-line-numbers # 禁用行号显示
undefinedSecurity & Analysis
安全与分析
bash
undefinedbash
undefinedRun security checks
运行安全检查
repomix --no-security-check # disable security scanning
repomix --no-security-check # 禁用安全扫描
Copy to clipboard
复制到剪贴板
repomix --copy # copy output to clipboard
repomix --copy # 将输出复制到剪贴板
Verbose output
详细输出
repomix --verbose
undefinedrepomix --verbose
undefinedConfiguration
配置
bash
undefinedbash
undefinedUse custom config file
使用自定义配置文件
repomix -c custom-config.json
repomix -c custom-config.json
Initialize new config
初始化新配置
repomix --init # creates repomix.config.json
undefinedrepomix --init # 创建repomix.config.json
undefinedConfiguration File
配置文件
Create in project root:
repomix.config.jsonjson
{
"output": {
"filePath": "repomix-output.xml",
"style": "xml",
"removeComments": false,
"showLineNumbers": true,
"copyToClipboard": false
},
"include": ["**/*"],
"ignore": {
"useGitignore": true,
"useDefaultPatterns": true,
"customPatterns": [
"additional-folder",
"**/*.log",
"**/tmp/**"
]
},
"security": {
"enableSecurityCheck": true
}
}在项目根目录创建 :
repomix.config.jsonjson
{
"output": {
"filePath": "repomix-output.xml",
"style": "xml",
"removeComments": false,
"showLineNumbers": true,
"copyToClipboard": false
},
"include": ["**/*"],
"ignore": {
"useGitignore": true,
"useDefaultPatterns": true,
"customPatterns": [
"additional-folder",
"**/*.log",
"**/tmp/**"
]
},
"security": {
"enableSecurityCheck": true
}
}Ignore Patterns
忽略模式
.repomixignore File
.repomixignore 文件
Create for Repomix-specific ignore patterns (same format as .gitignore):
.repomixignoreundefined创建 文件定义Repomix专属忽略模式(格式与.gitignore相同):
.repomixignoreundefinedBuild artifacts
构建产物
dist/
build/
*.min.js
dist/
build/
*.min.js
Test files
测试文件
**/.test.ts
**/.spec.ts
coverage/
**/.test.ts
**/.spec.ts
coverage/
Large files
大文件
*.mp4
*.zip
*.mp4
*.zip
Sensitive files
敏感文件
.env*
secrets/
undefined.env*
secrets/
undefinedPrecedence Order
优先级顺序
- CLI ignore patterns (flag)
-i - file
.repomixignore - Custom patterns in config file
- file (if enabled)
.gitignore - Default patterns (if enabled)
- 命令行忽略模式(参数)
-i - 文件
.repomixignore - 配置文件中的自定义模式
- 文件(若启用)
.gitignore - 默认忽略模式(若启用)
Output Formats
输出格式
XML Format (Default)
XML格式(默认)
Best for structured AI consumption:
bash
repomix --style xml最适合结构化AI处理:
bash
repomix --style xmlMarkdown Format
Markdown格式
Human-readable with syntax highlighting:
bash
repomix --style markdown人类可读,支持语法高亮:
bash
repomix --style markdownJSON Format
JSON格式
For programmatic processing:
bash
repomix --style json适合程序化处理:
bash
repomix --style jsonPlain Text
纯文本
Simple concatenation:
bash
repomix --style plain简单拼接格式:
bash
repomix --style plainUse Cases & Examples
用例与示例
1. Code Review Preparation
1. 代码审查准备
bash
undefinedbash
undefinedPackage feature branch for AI review
打包功能分支用于AI审查
repomix --include "src/**/*.ts" --remove-comments -o feature-review.md --style markdown
undefinedrepomix --include "src/**/*.ts" --remove-comments -o feature-review.md --style markdown
undefined2. Security Audit
2. 安全审计
bash
undefinedbash
undefinedPackage third-party library for analysis
打包第三方库用于分析
npx repomix --remote vendor/library --style xml -o audit.xml
undefinednpx repomix --remote vendor/library --style xml -o audit.xml
undefined3. Documentation Generation
3. 文档生成
bash
undefinedbash
undefinedPackage with docs and code
打包文档与代码
repomix --include "src/,docs/,*.md" --style markdown -o context.md
undefinedrepomix --include "src/,docs/,*.md" --style markdown -o context.md
undefined4. Bug Investigation
4. Bug排查
bash
undefinedbash
undefinedPackage specific modules
打包特定模块
repomix --include "src/auth/,src/api/" -o debug-context.xml
undefinedrepomix --include "src/auth/,src/api/" -o debug-context.xml
undefined5. Implementation Planning
5. 实现规划
bash
undefinedbash
undefinedFull codebase context for planning
生成完整代码库上下文用于规划
repomix --remove-comments --copy
undefinedrepomix --remove-comments --copy
undefinedToken Management
Token管理
Repomix automatically counts tokens for:
- Individual files
- Total repository
- Per-format output
Use token counts to manage LLM context limits:
- Claude: ~200K tokens
- GPT-4: ~128K tokens
- GPT-3.5: ~16K tokens
Repomix 自动为以下内容计数Token:
- 单个文件
- 整个仓库
- 各格式输出内容
利用Token计数管理LLM上下文限制:
- Claude:约200K Token
- GPT-4:约128K Token
- GPT-3.5:约16K Token
Security Considerations
安全注意事项
Sensitive Data Detection
敏感数据检测
Repomix uses Secretlint to detect:
- API keys and tokens
- Passwords and credentials
- Private keys
- AWS secrets
- Database connection strings
Disable if needed:
bash
repomix --no-security-checkRepomix 使用Secretlint检测以下内容:
- API密钥与令牌
- 密码与凭证
- 私钥
- AWS密钥
- 数据库连接字符串
按需禁用:
bash
repomix --no-security-checkBest Practices
最佳实践
- Always review output before sharing
- Use for sensitive files
.repomixignore - Enable security checks for unknown codebases
- Avoid packaging files
.env - Check for hardcoded credentials
- 分享前务必检查输出内容
- 使用 忽略敏感文件
.repomixignore - 对未知代码库启用安全检查
- 避免打包 文件
.env - 检查是否存在硬编码凭证
Performance Optimization
性能优化
Large Repositories
大型仓库
Repomix uses worker threads for parallel processing:
- Efficiently handles large codebases
- Example: facebook/react processed 29x faster (123s → 4s)
Repomix 使用工作线程并行处理:
- 高效处理大型代码库
- 示例:facebook/react 处理速度提升29倍(123秒 → 4秒)
Optimization Tips
优化技巧
bash
undefinedbash
undefinedExclude unnecessary files
排除不必要的文件
repomix -i "node_modules/,dist/,*.min.js"
repomix -i "node_modules/,dist/,*.min.js"
Process specific directories only
仅处理指定目录
repomix --include "src/**/*.ts"
repomix --include "src/**/*.ts"
Disable line numbers for smaller output
禁用行号以减小输出体积
repomix --no-line-numbers
undefinedrepomix --no-line-numbers
undefinedWorkflow Integration
工作流集成
With Claude Code
与Claude Code集成
bash
undefinedbash
undefinedPackage and analyze in one workflow
一键打包并分析
repomix --style markdown --copy
repomix --style markdown --copy
Then paste into Claude for analysis
然后粘贴到Claude中进行分析
undefinedundefinedWith CI/CD
与CI/CD集成
bash
undefinedbash
undefinedGenerate codebase snapshot for releases
为版本发布生成代码库快照
repomix --style markdown -o release-snapshot.md
undefinedrepomix --style markdown -o release-snapshot.md
undefinedWith Git Hooks
与Git钩子集成
bash
undefinedbash
undefinedPre-commit hook to generate context
预提交钩子生成上下文
repomix --include "src/**" -o .context/latest.xml
undefinedrepomix --include "src/**" -o .context/latest.xml
undefinedCommon Patterns
常见模式
Full Repository Package
完整仓库打包
bash
repomix --remove-comments --style markdown -o full-repo.mdbash
repomix --remove-comments --style markdown -o full-repo.mdSource Code Only
仅源代码
bash
repomix --include "src/**/*.{ts,tsx,js,jsx}" -i "**/*.test.*"bash
repomix --include "src/**/*.{ts,tsx,js,jsx}" -i "**/*.test.*"Documentation Bundle
文档打包
bash
repomix --include "**/*.md,docs/**" --style markdownbash
repomix --include "**/*.md,docs/**" --style markdownTypeScript Project
TypeScript项目
bash
repomix --include "**/*.ts,**/*.tsx" --remove-comments --no-line-numbersbash
repomix --include "**/*.ts,**/*.tsx" --remove-comments --no-line-numbersRemote Analysis
远程分析
bash
npx repomix --remote owner/repo --style xml -o analysis.xmlbash
npx repomix --remote owner/repo --style xml -o analysis.xmlTroubleshooting
故障排除
Issue: Output Too Large
问题:输出体积过大
bash
undefinedbash
undefinedExclude unnecessary files
排除不必要的文件
repomix -i "node_modules/,dist/,coverage/**"
repomix -i "node_modules/,dist/,coverage/**"
Process specific directories
仅处理指定目录
repomix --include "src/**"
undefinedrepomix --include "src/**"
undefinedIssue: Missing Files
问题:文件缺失
bash
undefinedbash
undefinedDisable .gitignore rules
禁用.gitignore规则
repomix --no-gitignore
repomix --no-gitignore
Check ignore patterns
检查忽略模式
cat .repomixignore
undefinedcat .repomixignore
undefinedIssue: Sensitive Data Warnings
问题:敏感数据警告
bash
undefinedbash
undefinedReview flagged files
检查标记的文件
Add to .repomixignore
添加到.repomixignore
Or disable checks: --no-security-check
或禁用检查:--no-security-check
undefinedundefinedImplementation Workflow
实现工作流
When user requests repository packaging:
-
Assess Requirements
- Identify target repository (local/remote)
- Determine output format needed
- Check for sensitive data concerns
-
Configure Filters
- Set include patterns for relevant files
- Add ignore patterns for unnecessary files
- Enable/disable comment removal
-
Execute Packaging
- Run repomix with appropriate options
- Monitor token counts
- Verify security checks
-
Validate Output
- Review generated file
- Confirm no sensitive data
- Check token limits for target LLM
-
Deliver Context
- Provide packaged file to user
- Include token count summary
- Note any warnings or issues
当用户请求仓库打包时:
-
评估需求
- 确定目标仓库(本地/远程)
- 确认所需输出格式
- 检查敏感数据风险
-
配置过滤规则
- 设置需包含的文件模式
- 添加需忽略的文件模式
- 启用/禁用注释移除
-
执行打包
- 使用合适参数运行repomix
- 监控Token计数
- 验证安全检查结果
-
验证输出
- 检查生成的文件
- 确认无敏感数据
- 检查是否符合目标LLM的Token限制
-
交付上下文
- 向用户提供打包文件
- 包含Token计数摘要
- 标注警告或问题
Best Practices
最佳实践
- Start with defaults: Run basic first, then refine
repomix - Use .repomixignore: Better than CLI flags for complex patterns
- Enable security checks: Especially for third-party code
- Choose right format: XML for AI, Markdown for humans
- Monitor token counts: Stay within LLM limits
- Remove comments: When focusing on logic over documentation
- Version output: Include in .gitignore, regenerate as needed
- Test patterns: Verify include/exclude work as expected
- 从默认配置开始:先运行基础 命令,再逐步优化
repomix - 使用.repomixignore:复杂模式优先用文件而非命令行参数
- 启用安全检查:尤其是处理第三方代码时
- 选择合适格式:XML适合AI,Markdown适合人类阅读
- 监控Token计数:确保在LLM限制范围内
- 移除注释:专注代码逻辑而非文档时启用
- 版本化输出:将输出文件加入.gitignore,按需重新生成
- 测试规则:验证包含/排除模式是否符合预期
Related Tools
相关工具
- Context7: For up-to-date library documentation
- Git: For repository history analysis
- Secretlint: For security scanning
- Token counters: For LLM context management
- Context7:用于获取最新库文档
- Git:用于仓库历史分析
- Secretlint:用于安全扫描
- Token计数器:用于LLM上下文管理
Additional Resources
额外资源
- GitHub: https://github.com/yamadashy/repomix
- Documentation: https://repomix.com/guide/
- MCP Server: Available for AI assistant integration
- Claude Code Plugin: Official integration available
- GitHub:https://github.com/yamadashy/repomix
- 文档:https://repomix.com/guide/
- MCP Server:支持AI助手集成
- Claude Code插件:官方集成可用