Repomix is a tool that packages your codebase into a single AI-friendly file for analysis by Large Language Models (LLMs) like ChatGPT, Claude, and others. It optimizes your code for AI consumption while providing useful features like token counting.
Install Repomix globally for repeated use:
# Using npm
npm install -g repomix
# Using yarn
yarn global add repomix
# Using Homebrew (macOS/Linux)
brew install repomix
Or use it without installation:
npx repomix
Run Repomix in your project directory:
repomix
This generates a repomix-output.xml
file containing your entire repository in an AI-friendly format.
Process a specific directory:
repomix path/to/directory
Include specific files using glob patterns:
repomix --include "src/**/*.ts,**/*.md"
Exclude specific files or directories:
repomix --ignore "**/*.log,tmp/"
Process a GitHub repository without cloning it:
repomix --remote https://github.com/yamadashy/repomix
# Using GitHub shorthand
repomix --remote yamadashy/repomix
# Specifying branch, tag, or commit
repomix --remote yamadashy/repomix --remote-branch main
Repomix supports multiple output formats:
# XML format (default)
repomix --style xml
# Markdown format
repomix --style markdown
# Plain text format
repomix --style plain
Reduce token count while preserving structure:
repomix --compress
This extracts key code elements like function signatures while removing implementation details.
Create a configuration file:
repomix --init
This generates a repomix.config.json
file that allows you to customize:
Create a global configuration:
repomix --init --global
Run Repomix as a Model Context Protocol server:
repomix --mcp
This allows AI assistants to directly interact with your codebase through tools like:
pack_codebase
: Package a local code directorypack_remote_repository
: Fetch and package a GitHub repositoryread_repomix_output
: Read contents of a Repomix output filefile_system_read_file
: Read a file with security validationfile_system_read_directory
: List contents of a directoryRun Repomix in a Docker container:
docker run -v .:/app -it --rm ghcr.io/yamadashy/repomix
Process a remote repository and output to a directory:
docker run -v ./output:/app -it --rm ghcr.io/yamadashy/repomix --remote https://github.com/yamadashy/repomix
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.
--output <file>
: Specify output filename--copy
: Copy output to system clipboard--no-security-check
: Disable security check--remove-comments
: Remove comments from supported file types--remove-empty-lines
: Remove empty lines--token-count-encoding <encoding>
: Specify token count encoding (e.g., o200k_base
for GPT-4o)For a complete list of options, run:
repomix --help
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.