repomix
关于
Repomix is a tool that packages entire code repositories into single, AI-friendly files. It is primarily used to generate context for LLMs like Claude, enabling AI analysis, codebase snapshots, and security audits. This makes it ideal for preparing a codebase for an AI to review or summarize.
技能文档
Repomix Skill
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.
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
Core Capabilities
1. Repository Packaging
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
2. Remote Repository Support
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
3. Comment Removal
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:
--remove-commentsor config file
Installation
Check if installed first:
repomix --version
Install using preferred method:
# npm
npm install -g repomix
# yarn
yarn global add repomix
# bun
bun add -g repomix
# Homebrew (macOS/Linux)
brew install repomix
Basic Usage
Package Current Directory
# Basic packaging (generates repomix-output.xml)
repomix
# Specify output format
repomix --style markdown
repomix --style json
repomix --style plain
# Custom output path
repomix -o custom-output.xml
Package Specific Directory
repomix /path/to/directory
Package Remote Repository
# Shorthand format
npx repomix --remote owner/repo
# Full URL
npx repomix --remote https://github.com/owner/repo
# Specific commit
npx repomix --remote https://github.com/owner/repo/commit/abc123
Command Line Options
File Selection
# Include specific patterns
repomix --include "src/**/*.ts,*.md"
# Ignore additional patterns
repomix -i "tests/**,*.test.js"
# Disable .gitignore rules
repomix --no-gitignore
# Disable default ignore patterns
repomix --no-default-patterns
Output Configuration
# Output format
repomix --style markdown # or xml, json, plain
# Output file path
repomix -o output.md
# Remove comments
repomix --remove-comments
# Show line numbers
repomix --no-line-numbers # disable line numbers
Security & Analysis
# Run security checks
repomix --no-security-check # disable security scanning
# Copy to clipboard
repomix --copy # copy output to clipboard
# Verbose output
repomix --verbose
Configuration
# Use custom config file
repomix -c custom-config.json
# Initialize new config
repomix --init # creates repomix.config.json
Configuration File
Create repomix.config.json in project root:
{
"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
Create .repomixignore for Repomix-specific ignore patterns (same format as .gitignore):
# Build artifacts
dist/
build/
*.min.js
# Test files
**/*.test.ts
**/*.spec.ts
coverage/
# Large files
*.mp4
*.zip
# Sensitive files
.env*
secrets/
Precedence Order
- CLI ignore patterns (
-iflag) .repomixignorefile- Custom patterns in config file
.gitignorefile (if enabled)- Default patterns (if enabled)
Output Formats
XML Format (Default)
Best for structured AI consumption:
repomix --style xml
Markdown Format
Human-readable with syntax highlighting:
repomix --style markdown
JSON Format
For programmatic processing:
repomix --style json
Plain Text
Simple concatenation:
repomix --style plain
Use Cases & Examples
1. Code Review Preparation
# Package feature branch for AI review
repomix --include "src/**/*.ts" --remove-comments -o feature-review.md --style markdown
2. Security Audit
# Package third-party library for analysis
npx repomix --remote vendor/library --style xml -o audit.xml
3. Documentation Generation
# Package with docs and code
repomix --include "src/**,docs/**,*.md" --style markdown -o context.md
4. Bug Investigation
# Package specific modules
repomix --include "src/auth/**,src/api/**" -o debug-context.xml
5. Implementation Planning
# Full codebase context for planning
repomix --remove-comments --copy
Token Management
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
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:
repomix --no-security-check
Best Practices
- Always review output before sharing
- Use
.repomixignorefor sensitive files - Enable security checks for unknown codebases
- Avoid packaging
.envfiles - Check for hardcoded credentials
Performance Optimization
Large Repositories
Repomix uses worker threads for parallel processing:
- Efficiently handles large codebases
- Example: facebook/react processed 29x faster (123s → 4s)
Optimization Tips
# Exclude unnecessary files
repomix -i "node_modules/**,dist/**,*.min.js"
# Process specific directories only
repomix --include "src/**/*.ts"
# Disable line numbers for smaller output
repomix --no-line-numbers
Workflow Integration
With Claude Code
# Package and analyze in one workflow
repomix --style markdown --copy
# Then paste into Claude for analysis
With CI/CD
# Generate codebase snapshot for releases
repomix --style markdown -o release-snapshot.md
With Git Hooks
# Pre-commit hook to generate context
repomix --include "src/**" -o .context/latest.xml
Common Patterns
Full Repository Package
repomix --remove-comments --style markdown -o full-repo.md
Source Code Only
repomix --include "src/**/*.{ts,tsx,js,jsx}" -i "**/*.test.*"
Documentation Bundle
repomix --include "**/*.md,docs/**" --style markdown
TypeScript Project
repomix --include "**/*.ts,**/*.tsx" --remove-comments --no-line-numbers
Remote Analysis
npx repomix --remote owner/repo --style xml -o analysis.xml
Troubleshooting
Issue: Output Too Large
# Exclude unnecessary files
repomix -i "node_modules/**,dist/**,coverage/**"
# Process specific directories
repomix --include "src/**"
Issue: Missing Files
# Disable .gitignore rules
repomix --no-gitignore
# Check ignore patterns
cat .repomixignore
Issue: Sensitive Data Warnings
# Review flagged files
# Add to .repomixignore
# Or disable checks: --no-security-check
Implementation 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
Best Practices
- Start with defaults: Run basic
repomixfirst, then refine - 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
Related Tools
- Context7: For up-to-date library documentation
- Git: For repository history analysis
- Secretlint: For security scanning
- Token counters: For LLM context management
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
快速安装
/plugin add https://github.com/Elios-FPT/EliosCodePracticeService/tree/main/repomix在 Claude Code 中复制并粘贴此命令以安装该技能
GitHub 仓库
相关推荐技能
llamaguard
其他LlamaGuard是Meta推出的7-8B参数内容审核模型,专门用于过滤LLM的输入和输出内容。它能检测六大安全风险类别(暴力/仇恨、性内容、武器、违禁品、自残、犯罪计划),准确率达94-95%。开发者可通过HuggingFace、vLLM或Sagemaker快速部署,并能与NeMo Guardrails集成实现自动化安全防护。
sglang
元SGLang是一个专为LLM设计的高性能推理框架,特别适用于需要结构化输出的场景。它通过RadixAttention前缀缓存技术,在处理JSON、正则表达式、工具调用等具有重复前缀的复杂工作流时,能实现极速生成。如果你正在构建智能体或多轮对话系统,并追求远超vLLM的推理性能,SGLang是理想选择。
evaluating-llms-harness
测试该Skill通过60+个学术基准测试(如MMLU、GSM8K等)评估大语言模型质量,适用于模型对比、学术研究及训练进度追踪。它支持HuggingFace、vLLM和API接口,被EleutherAI等行业领先机构广泛采用。开发者可通过简单命令行快速对模型进行多任务批量评估。
langchain
元LangChain是一个用于构建LLM应用程序的框架,支持智能体、链和RAG应用开发。它提供多模型提供商支持、500+工具集成、记忆管理和向量检索等核心功能。开发者可用它快速构建聊天机器人、问答系统和自主代理,适用于从原型验证到生产部署的全流程。
