3.7 KiB
3.7 KiB
Repomix Scripts
Utility scripts for batch processing repositories with Repomix.
repomix_batch.py
Batch process multiple repositories (local or remote) using the repomix CLI tool.
Features
- Process multiple repositories in one command
- Support local and remote repositories
- Configurable output formats (XML, Markdown, JSON, Plain)
- Environment variable loading from multiple .env file locations
- Comprehensive error handling
- Progress reporting
Installation
Requires Python 3.10+ and repomix CLI:
# Install repomix
npm install -g repomix
# Install Python dependencies (if needed)
pip install pytest pytest-cov pytest-mock # For running tests
Usage
Process single repository:
python repomix_batch.py /path/to/repo
Process multiple repositories:
python repomix_batch.py /repo1 /repo2 /repo3
Process remote repositories:
python repomix_batch.py owner/repo1 owner/repo2 --remote
From JSON file:
python repomix_batch.py -f repos.json
With options:
python repomix_batch.py /repo1 /repo2 \
--style markdown \
--output-dir output \
--remove-comments \
--include "src/**/*.ts" \
--ignore "tests/**" \
--verbose
Configuration File Format
Create repos.json with repository configurations:
[
{
"path": "/path/to/local/repo",
"output": "custom-output.xml"
},
{
"path": "owner/repo",
"remote": true
},
{
"path": "https://github.com/owner/repo",
"remote": true,
"output": "repo-output.md"
}
]
Environment Variables
Loads .env files in order of precedence:
- Process environment (highest priority)
./repomix/.env(skill-specific)./skills/.env(skills directory)./.claude/.env(lowest priority)
Command Line Options
positional arguments:
repos Repository paths or URLs to process
options:
-h, --help Show help message
-f, --file FILE JSON file containing repository configurations
--style {xml,markdown,json,plain}
Output format (default: xml)
-o, --output-dir DIR Output directory (default: repomix-output)
--remove-comments Remove comments from source files
--include PATTERN Include pattern (glob)
--ignore PATTERN Ignore pattern (glob)
--no-security-check Disable security checks
-v, --verbose Verbose output
--remote Treat all repos as remote URLs
Examples
Process local repositories:
python repomix_batch.py /path/to/repo1 /path/to/repo2 --style markdown
Process remote repositories:
python repomix_batch.py yamadashy/repomix facebook/react --remote
Mixed configuration:
python repomix_batch.py \
/local/repo \
--remote owner/remote-repo \
-f additional-repos.json \
--style json \
--remove-comments
TypeScript projects only:
python repomix_batch.py /repo1 /repo2 \
--include "**/*.ts,**/*.tsx" \
--ignore "**/*.test.ts,dist/" \
--remove-comments \
--style markdown
Testing
Run tests with coverage:
cd tests
pytest test_repomix_batch.py -v --cov=repomix_batch --cov-report=term-missing
Current coverage: 99%
Exit Codes
0- All repositories processed successfully1- One or more repositories failed or error occurred
Troubleshooting
repomix not found:
npm install -g repomix
Permission denied:
chmod +x repomix_batch.py
Timeout errors:
- Default timeout: 5 minutes per repository
- Reduce scope with
--includepatterns - Exclude large directories with
--ignore
No repositories specified:
- Provide repository paths as arguments
- Or use
-fflag with JSON config file