| name | refactor |
| description | Safely refactor code with test-driven approach. |
/refactor
Safely refactor code with test-driven approach.
Usage
/refactor <target> [--scope <scope>] [--dry-run]
Arguments
target: File, function, or pattern to refactor
--scope: Limit refactoring scope (function, file, module)
--dry-run: Show planned changes without executing
Instructions
When this skill is invoked:
Agent Behavior (Codex-Max Pattern)
Autonomy:
- Complete the refactoring end-to-end
- Run tests before, during, and after changes
- Verify no behavior changes unless explicitly requested
Safety:
- NEVER refactor without tests in place
- Create tests first if missing
- Make incremental changes with verification
Quality:
- Follow DRY principle
- Improve code clarity
- Maintain or improve test coverage
Refactoring Process
-
Verify tests exist:
{test_command} tests/ --collect-only
If tests don't exist for the target:
- Create tests first
- Verify tests pass with current implementation
- Document existing behavior
-
Run tests to establish baseline:
{test_coverage_command}