Automates mechanical Python refactors like renames, moves, and import updates using rope. Benefits developers by reducing manual refactoring tasks. Integrates with Claude agents via a CLI wrapper script.
git clone https://github.com/brian-yu/python-rope-refactor.gitpython-rope-refactor is a CLI skill that integrates the rope library with Claude agents to automate mechanical Python refactoring tasks. It handles module moves, symbol renames, function extraction, import organization, and batch operations through a safe dry-run-first workflow. The skill wraps rope's refactoring capabilities with a diff preview loop: run with --dry-run, review changes, apply with --apply, then verify with git diff and tests. This reduces manual boilerplate when restructuring Python codebases, moving modules between packages, renaming classes and functions across multiple files, and cleaning up imports. Developers benefit from letting AI agents handle repetitive refactoring while maintaining control through preview steps.
Install uv, then copy the skill files (SKILL.md and scripts/rope_refactor.py) into ~/.codex/skills/python-rope-refactor/. Codex will discover it at startup. Run refactoring commands with --dry-run first to preview changes, review the diff-like output, then re-run with --apply and verify with git diff and tests.
Rename a Python class or function across an entire codebase automatically
Move a module into a different package with all imports updated
Extract repeated code into a new function or method
Organize and clean up imports across multiple files
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/brian-yu/python-rope-refactorCopy 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.
I need to refactor some Python code. Here's the file structure: [FILE_STRUCTURE] And here's the code I want to refactor: [CODE] Please use python-rope-refactor to [REFACOTRING_TASK] and provide the updated code.
# Refactoring Report
## Renamed `calculate_total` to `compute_total`
```python
# Before
def calculate_total(items):
return sum(item.price for item in items)
# After
def compute_total(items):
return sum(item.price for item in items)
```
## Updated imports in `inventory.py`
```python
# Before
from .utils import calculate_total
# After
from .utils import compute_total
```
## Moved `compute_total` to `utils/math_operations.py`
```python
# New location: utils/math_operations.py
def compute_total(items):
return sum(item.price for item in items)
```Production-grade AI agent infrastructure
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