Automate file and code refactoring with repren. Use regex to rename files, directories, and code elements. Integrates with Claude Code skill for advanced refactoring. Ideal for developers and operations teams.
git clone https://github.com/jlevy/repren.gitrepren is a command-line refactoring tool that performs search-and-replace operations and file renaming at scale using regular expressions. It handles simultaneous renames (like swapping foo and bar without intermediate steps), case-preserving variants across lowerCamel, UpperCamel, and underscore conventions, and recursive directory operations with atomic file safety. The tool includes dry-run mode, automatic backups, and undo capabilities to prevent data loss. It has zero runtime dependencies and works on Python 3.10-3.14, making it lightweight and secure for developers, operations teams, and AI agents automating bulk refactors.
[{"step":"Identify the refactoring target. Determine whether you need to rename files, directories, or code elements (e.g., variables, functions, classes).","action":"Use grep or IDE search to find all occurrences of the old pattern. Example: `grep -r \"old_function\" .` to locate all references."},{"step":"Draft the regex patterns for the old and new names. Test them with `repren --dry-run` to preview changes.","action":"Run: `repren --dry-run --pattern 'old_pattern' --replacement 'new_pattern' --target 'files'`. Review the output for accuracy."},{"step":"Apply the refactoring in batches. Start with files, then directories, and finally code elements to minimize risk.","action":"Execute: `repren --pattern 'old_pattern' --replacement 'new_pattern' --target 'files'` followed by `repren --pattern 'old_pattern' --replacement 'new_pattern' --target 'code'`.","tip":"Use `--backup-dir` to create a backup of the original files before refactoring. Example: `--backup-dir ./backups/`"},{"step":"Verify the changes. Check for broken imports, syntax errors, or unintended modifications.","action":"Run tests: `pytest` or `npm test`. Use `git diff` to review changes. Fix any issues manually if needed."},{"step":"Integrate with Claude Code for advanced refactoring. Use the `repren` skill in combination with `Claude Code` to automate complex code transformations.","action":"Example: 'Use repren to rename all instances of `User` to `Account` in the `src/models/` directory, then use Claude Code to update the corresponding tests and documentation.'"}]
Rename variables across multiple source files while ensuring case variations are preserved.
Perform bulk renaming of files and directories based on specific patterns in their names.
Execute complex search-and-replace operations using regular expressions to update documentation or code comments.
Run a dry run to preview changes before applying them to ensure accuracy and safety.
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/jlevy/reprenCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Use repren to refactor [FILES/PROJECT] by renaming [ELEMENT_TYPE] from [OLD_PATTERN] to [NEW_PATTERN]. Show me the changes before applying them. Example: 'Use repren to refactor the entire project by renaming all Python files from *.py to *.py.bak. Show me the changes before applying them.'
Here’s a preview of the refactoring changes for your `src/` directory using repren: **File Renames:** - `src/utils.py` → `src/helpers.py` - `src/models/user.py` → `src/entities/user_entity.py` - `src/tests/test_utils.py` → `src/tests/test_helpers.py` **Code Element Renames (Python):** - Function `calculate_total()` → `compute_total()` in `src/services/billing.py` - Class `UserManager` → `UserService` in `src/models/user.py` - Variable `user_id` → `account_id` in `src/controllers/api.py` (3 occurrences) **Directory Renames:** - `src/legacy/` → `src/deprecated/` All changes follow the regex pattern `^.*\.py$` → `*.py.bak` for files and `User.*` → `Account.*` for code elements. Would you like me to apply these changes? If so, I’ll use `repren` with the `--dry-run` flag first, then execute the refactor.
AI assistant built for thoughtful, nuanced conversation
Get more done every day with Microsoft Teams – powered by AI
Automate security compliance and monitor real-time security posture seamlessly.
Automate your spreadsheet tasks with AI power
Agentic AI Workflow platform
Connected workspace for docs, wikis, and projects
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan