| name | repomix |
| description | Pack entire codebases into AI-friendly files for LLM analysis. Use when consolidating code for AI review, generating codebase summaries, or preparing context for ChatGPT, Claude, or other AI tools. |
Repomix - Codebase Packing for AI
Pack your entire repository into a single, AI-friendly file optimized for LLMs like Claude, ChatGPT, Gemini, and more.
When to Use This Skill
- Feeding codebase to AI for analysis or refactoring
- Generating comprehensive code reviews
- Creating documentation from code
- Preparing context for AI-assisted development
- Analyzing remote repositories without cloning
- Token counting for LLM context limits
Quick Start
npx repomix@latest
npx repomix path/to/directory
npx repomix --compress
npx repomix --copy
Default output: ./repomix-output.xml in current directory
Examples
Example: Prepare codebase for Claude review
User: "Pack my src folder for Claude to review the architecture"
→ npx repomix --include "src/**/*" --style xml --copy
→ Output copied to clipboard, ready to paste into Claude
Example: Analyze remote repo without cloning
User: "I want to understand how shadcn/ui implements its button"
→ npx repomix --remote shadcn-ui/ui --include "**/button/**/*" --compress
→ Generates focused output of button component
Example: Prepare PR diff for review
User: "Pack only the files I changed for a code review"
→ git diff --name-only main | npx repomix --stdin --compress
→ Packs only modified files with compression
Example: Check token usage before sending to AI
User: "Is my codebase too large for GPT-4?"
→ npx repomix --token-count-tree
→ Shows token breakdown per file/directory
Example: Generate skills reference from library
User: "Create a Claude skill from the zod repository"
→ npx repomix --remote colinhacks/zod --skill-generate zod-reference
→ Generates AI-optimized reference documentation
Output Formats
npx repomix --style xml
npx repomix --style markdown
npx repomix --style json
npx repomix --style plain
Token Optimization
LLM Context Limits Reference
| Model | Context Window | Typical Repo Fit |
|---|
| Claude 3.5/Opus | 200K tokens | Large monorepos |
| GPT-4 Turbo/4o | 128K tokens | Medium projects |
| Gemini 1.5 Pro | 1M tokens | Very large codebases |
| Gemini 1.5 Flash | 1M tokens | Very large codebases |
Token Analysis
npx repomix --token-count-tree
npx repomix --token-count-tree 1000
npx repomix --split-output 1mb
File Selection
Include Patterns
npx repomix --include "**/*.ts"
npx repomix --include "src/**/*.ts,**/*.md"
npx repomix --include "src/**/*,tests/**/*"
Ignore Patterns
npx repomix --ignore "**/*.test.ts"
npx repomix --ignore "**/*.log,tmp/,dist/"
npx repomix --include "src/**/*.ts" --ignore "**/*.test.ts"
Stdin Input
find src -name "*.ts" -type f | npx repomix --stdin
git ls-files "*.ts" | npx repomix --stdin
find . -name "*.ts" -type f | fzf -m | npx repomix --stdin
rg --files --type ts | npx repomix --stdin
Common Workflows
PR Review Preparation
git diff --name-only main | npx repomix --stdin --compress
npx repomix --include-diffs --compress
Architecture Analysis
npx repomix --compress --include "src/**/*" --ignore "**/*.test.*"
npx repomix --include "src/api/**/*,src/services/**/*" --compress
Documentation Generation
npx repomix --include "src/**/*,**/*.md" --style markdown
npx repomix --include-logs --include-logs-count 50
Dependency Analysis
npx repomix --include "package.json,tsconfig.json,**/*.config.*"
Remote Repositories
npx repomix --remote https://github.com/user/repo
npx repomix --remote user/repo
npx repomix --remote user/repo --remote-branch main
npx repomix --remote user/repo --remote-branch 935b695
npx repomix --remote https://github.com/user/repo/tree/feature-branch
Code Compression
Tree-sitter powered compression extracts signatures while removing implementation details.
Supported Languages
Tree-sitter compression works with: JavaScript, TypeScript, Python, Ruby, Go, Rust, Java, C, C++, C#, PHP, Swift, Kotlin, and more.
Usage
npx repomix --compress
npx repomix --remote user/repo --compress
Before compression:
const calculateTotal = (items: Item[]) => {
let total = 0;
for (const item of items) {
total += item.price * item.quantity;
}
return total;
};
After compression:
const calculateTotal = (items: Item[]) => { };
Git Integration
npx repomix --include-logs
npx repomix --include-logs --include-logs-count 20
npx repomix --include-diffs
npx repomix --include-logs --include-diffs
Configuration
Initialize Config
npx repomix --init
npx repomix --init --global
Configuration File
{
"$schema": "https://repomix.com/schemas/latest/schema.json",
"output": {
"filePath": "repomix-output.xml",
"style": "xml",
"compress": false,
"removeComments": false,
"showLineNumbers": false,
"copyToClipboard": false
},
"include": ["src/**/*", "**/*.md"],
"ignore": {
"useGitignore": true,
"useDefaultPatterns": true,
"customPatterns"
Docker Usage
docker run -v .:/app -it --rm ghcr.io/yamadashy/repomix
docker run -v .:/app -it --rm ghcr.io/yamadashy/repomix path/to/directory
docker run -v ./output:/app -it --rm ghcr.io/yamadashy/repomix --remote user/repo
MCP Server Integration
Run as Model Context Protocol server for AI assistants:
npx repomix --mcp
Configure for Claude Code
claude mcp add repomix -- npx -y repomix --mcp
Available MCP Tools
When running as MCP server, provides:
| Tool | Description |
|---|
pack_codebase | Pack local directory into AI-friendly format |
pack_remote_repository | Pack GitHub repository without cloning |
read_repomix_output | Read contents of generated output file |
file_system_tree | Get directory tree structure |
Claude Agent Skills Generation
Generate skills format output for Claude:
npx repomix --skill-generate
npx repomix --skill-generate my-project-reference
npx repomix --remote user/repo --skill-generate
CLI Options Reference
| Option | Description |
|---|
-o, --output <file> | Output file path |
--style <style> | Output format: xml, markdown, json, plain |
--compress | Enable Tree-sitter compression |
--include <patterns> | Include files matching glob patterns |
-i, --ignore <patterns> | Exclude files matching patterns |
--remote <url> | Process remote repository |
--remote-branch <name> | Branch, tag, or commit for remote |
--stdin | Read file paths from stdin |
--copy | Copy output to clipboard |
--token-count-tree | Show token counts per file |
--split-output <size> | Split output by size (e.g., 1mb) |
--include-logs | Include git commit history |
--include-diffs | Include git diffs |
--no-security-check | Skip sensitive data detection |
--mcp | Run as MCP server |
--skill-generate | Generate Claude skills format |
--init | Create configuration file |
--help | Show all available options |
Troubleshooting
| Issue | Solution |
|---|
| Output too large for LLM | Use --compress or filter with --include |
| Missing expected files | Check .repomixignore, .gitignore, and ignore patterns |
| Secrets detected (blocking) | Review flagged files; use --no-security-check if false positive |
| Memory issues on large repos | Use --split-output 1mb to chunk output |
| Remote repo access denied | Check URL format; ensure repo is public or use SSH |
| Compression not working | Verify language is supported by Tree-sitter |
| Output not in clipboard | Ensure clipboard access; try --output - | pbcopy on macOS |
Ignore Files
Repomix respects multiple ignore sources (priority order):
ignore.customPatterns in config
.repomixignore (Repomix-specific)
.ignore (ripgrep compatible)
.gitignore
- Default patterns (node_modules, .git, etc.)
Security
Repomix includes Secretlint for detecting sensitive information:
npx repomix
npx repomix --no-security-check
Detected secret types: API keys, tokens, passwords, private keys, AWS credentials, database connection strings, and more.
Best Practices
- Use compression for large codebases to reduce token count (~70% reduction)
- Filter with --include to focus on relevant files
- Use --token-count-tree to identify large files before packing
- Split output when hitting AI context limits
- Include git logs for evolution context when needed
- Use XML style for Claude (optimized for XML tags)
- Use Markdown for human-readable output or other LLMs
- Check token counts against your target LLM's context window
- Review security warnings before sharing packed output
Requirements
- Node.js 18.0.0 or higher
- npm or npx available in PATH
Resources
Gotchas
--compress strips function bodies but keeps signatures — great for architecture review, useless for "why is this function buggy" questions. The LLM literally cannot see the implementation.
- Security check blocks output entirely on detected secrets — even a single false-positive AWS-key-shaped string in a test fixture kills the run. Use
--no-security-check only after reviewing the flagged files.
.gitignore is respected but .dockerignore is not — your node_modules is excluded but the giant dist/ your Dockerfile ignores will be packed. Add a .repomixignore to match.
- Token counts are tiktoken-based (GPT) — Claude's tokenizer differs by ~10-20%. A repo reported as "180K tokens" can blow past Claude's 200K window or fit comfortably depending on content.
--remote user/repo clones the default branch to a temp dir and runs locally — no GitHub API magic. Private repos require SSH keys configured; the error message just says "access denied" without explaining auth path.
--stdin reads NUL or newline-separated paths and silently drops paths that don't exist or are outside the cwd. A typo in git diff --name-only output produces a smaller pack with no warning.
--copy on macOS via pbcopy truncates at ~1MB in some terminal multiplexers (tmux without set-clipboard on). Verify the paste size before assuming the full output made it.