Repomix is a powerful tool that packages your codebase into AI-friendly formats, making it easier to analyze your code with large language models like ChatGPT, Claude, or other AI assistants.
You can use Repomix without installation using npx:
npx repomix
For global installation:
# Using npm
npm install -g repomix
# Using yarn
yarn global add repomix
# Using Homebrew (macOS/Linux)
brew install repomix
Run in your project directory:
repomix
This generates a repomix-output.xml
file containing your entire repository in an AI-friendly format.
To process a specific directory:
repomix path/to/directory
To include specific files using glob patterns:
repomix --include "src/**/*.ts,**/*.md"
To exclude specific files:
repomix --ignore "**/*.log,tmp/"
Analyze any GitHub repository without cloning it:
# Full URL
repomix --remote https://github.com/yamadashy/repomix
# GitHub shorthand
repomix --remote yamadashy/repomix
# Specific branch
repomix --remote yamadashy/repomix --remote-branch main
# Specific commit
repomix --remote yamadashy/repomix --remote-branch 935b695
# Branch URL
repomix --remote https://github.com/yamadashy/repomix/tree/main
# Commit URL
repomix --remote https://github.com/yamadashy/repomix/commit/836abcd7335137228ad77feb28655d85712680f1
To reduce token count while preserving code structure:
repomix --compress
This extracts essential function and class signatures while removing implementation details.
Repomix supports multiple output formats:
# XML format (default)
repomix --style xml
# Markdown format
repomix --style markdown
# Plain text format
repomix --style plain
Run Repomix in an isolated container:
# Current directory
docker run -v .:/app -it --rm ghcr.io/yamadashy/repomix
# Specific directory
docker run -v .:/app -it --rm ghcr.io/yamadashy/repomix path/to/directory
# Remote repository
docker run -v ./output:/app -it --rm ghcr.io/yamadashy/repomix --remote https://github.com/yamadashy/repomix
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": [
"additional-folder",
"**/*.log"
]
},
"security": {
"enableSecurityCheck": true
}
}
Some useful command-line options:
# Output to stdout instead of file
repomix --stdout
# Copy output to clipboard
repomix --copy
# Remove comments from code
repomix --remove-comments
# Remove empty lines
repomix --remove-empty-lines
# Show line numbers
repomix --output-show-line-numbers
# Disable security check
repomix --no-security-check
# Use custom configuration file
repomix --config path/to/config.json
Run Repomix as a Model Context Protocol (MCP) server to allow AI assistants to directly interact with your codebase:
repomix --mcp
This enables tools that let AI assistants package repositories for analysis without manual file preparation.
Once you've generated a packed file, upload it to your 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 specific tasks:
Automate repository packing with GitHub Actions:
- name: Pack repository with Repomix
uses: yamadashy/repomix/.github/actions/repomix@main
with:
output: repomix-output.xml
style: xml
compress: true
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 > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.