Repomix is a powerful tool that packages your codebase into a single, AI-friendly file, making it easy to analyze your code with Large Language Models like Claude, ChatGPT, and others. It creates optimized representations of your repository that work within AI context windows.
You can run Repomix instantly without installation:
npx repomix@latest
Or install it globally for repeated use:
# Using npm
npm install -g repomix
# Using yarn
yarn global add repomix
# Using bun
bun add -g repomix
# Using Homebrew (macOS/Linux)
brew install repomix
If you prefer Docker:
# Run on current directory
docker run -v .:/app -it --rm ghcr.io/yamadashy/repomix
# Process a remote repository and output to local 'output' directory
docker run -v ./output:/app -it --rm ghcr.io/yamadashy/repomix --remote https://github.com/yamadashy/repomix
In your project directory, simply run:
repomix
This generates a repomix-output.xml
file containing your entire codebase in an AI-friendly format.
# Process a specific directory
repomix path/to/directory
# Include only specific files using glob patterns
repomix --include "src/**/*.ts,**/*.md"
# Exclude specific files
repomix --ignore "**/*.log,tmp/"
# Using full URL
repomix --remote https://github.com/yamadashy/repomix
# Using shorthand
repomix --remote yamadashy/repomix
# Specify branch or commit
repomix --remote yamadashy/repomix --remote-branch main
repomix --remote https://github.com/yamadashy/repomix/tree/main
# Using find command
find src -name "*.ts" -type f | repomix --stdin
# Using git to get tracked files
git ls-files "*.ts" | repomix --stdin
# Using grep to find files with specific content
grep -l "TODO" **/*.ts | repomix --stdin
Reduce token count while preserving structure:
repomix --compress
# Include git logs (last 50 commits by default)
repomix --include-logs
# Include git logs with specific commit count
repomix --include-logs --include-logs-count 10
# Include git diffs (working tree and staged changes)
repomix --include-diffs
# Show token distribution across your codebase
repomix --token-count-tree
# Only show files/directories with 1000+ tokens
repomix --token-count-tree 1000
# XML format (default)
repomix --style xml
# Markdown format
repomix --style markdown
# Plain text format
repomix --style plain
Create a configuration file:
repomix --init
This generates a repomix.config.json
file with customizable options:
{
"input": {
"maxFileSize": 50000000
},
"output": {
"filePath": "repomix-output.xml",
"style": "xml",
"compress": false,
"removeComments": false,
"removeEmptyLines": false
},
"include": ["**/*"],
"ignore": {
"useGitignore": true,
"useDefaultPatterns": true,
"customPatterns": []
}
}
Repomix can run as a Model Context Protocol server, allowing AI assistants to directly interact with your codebase:
repomix --mcp
To configure as an MCP server in VS Code:
code --add-mcp '{"name":"repomix","command":"npx","args":["-y","repomix","--mcp"]}'
For Claude Code:
claude mcp add repomix -- npx -y repomix --mcp
After generating your packed file, send it to an AI assistant with a prompt like:
This file contains all the files in the repository combined into one.
I want to refactor the code, so please review it first.
Example prompts for different tasks:
Based on the codebase in this file, please identify any code smells,
potential bugs, or areas for improvement. Focus on maintainability
and performance issues.
Generate comprehensive documentation for this codebase, including
high-level architecture, key components, and usage examples.
Analyze this codebase and suggest test cases for the main functions,
covering edge cases and error scenarios.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "repomix" '{"command":"npx","args":["-y","repomix","--mcp"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"repomix": {
"command": "npx",
"args": [
"-y",
"repomix",
"--mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"repomix": {
"command": "npx",
"args": [
"-y",
"repomix",
"--mcp"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect