Pack and analyze codebases into AI-friendly single files using Repomix. Use when the user wants to explore repositories, analyze code structure, find patterns, check token counts, or prepare codebase context for AI analysis. Supports both local directories and remote GitHub repositories.
Pack entire codebases into a single, AI-friendly file for analysis. Repomix intelligently collects repository files, respects .gitignore, runs security checks, and generates structured output optimized for LLM consumption.
npx repomix@latest --remote <owner/repo> --output /tmp/<repo-name>-analysis.xml
Always output to a temporary directory ( on Unix, on Windows) for remote repositories to avoid polluting the user's working directory.
/tmp%TEMP%npx repomix@latest [directory] --output /tmp/<name>-analysis.xml
| Option | Description |
|---|---|
--style <format> | Output format: xml (default, recommended), markdown, plain, json |
--compress | Tree-sitter compression (~70% token reduction) — use for large repos |
--include <patterns> | Include only matching patterns (e.g., "src/**/*.ts,**/*.md") |
--ignore <patterns> | Additional ignore patterns |
--output <path> | Custom output path (default: repomix-output.xml) |
--remote-branch <name> | Specific branch, tag, or commit (for remote repos) |
Choose the appropriate command based on the target:
# Remote repository (always output to /tmp)
npx repomix@latest --remote yamadashy/repomix --output /tmp/repomix-analysis.xml
# Large remote repo with compression
npx repomix@latest --remote facebook/react --compress --output /tmp/react-analysis.xml
# Local directory
npx repomix@latest ./src --output /tmp/src-analysis.xml
# Specific file types only
npx repomix@latest --include "**/*.{ts,tsx,js,jsx}" --output /tmp/filtered-analysis.xml
The command displays:
Note the output file location for subsequent analysis.
Structure overview:
Search for patterns (use the output file path from Step 2):
# Find exports and main entry points
grep -iE "export.*function|export.*class" <output-file>
# Search with context
grep -iE -A 5 -B 5 "authentication|auth" <output-file>
# Find API endpoints
grep -iE "router|route|endpoint|api" <output-file>
# Find database models
grep -iE "model|schema|database|query" <output-file>
Read specific sections using offset/limit for large outputs.
--compress for large repos (>100k lines) to reduce token usage by ~70%/tmp on Unix, %TEMP% on Windows) to keep the user's workspace clean--include to focus on specific parts of a codebase| Format | Best For |
|---|---|
| XML (default) | Structured analysis, clear file boundaries |
| Markdown | Human-readable documentation |
| Plain | Simple grep-friendly output |
| JSON | Programmatic/machine analysis |
--compress, narrow scope with --includeRepomix automatically excludes potentially sensitive files (API keys, credentials, .env files) through built-in security checks. Trust its security defaults unless the user explicitly requests otherwise.