All skills
Skillintermediate
refactor py
Refactor Python code for clarity, performance, and Pythonic idioms.
Claude Code Knowledge Pack7/10/2026
Overview
Refactor Python code for clarity, performance, and Pythonic idioms.
Steps
- Read the target Python file or module.
- Identify refactoring opportunities:
- Apply Pythonic improvements:
- Improve code structure:
- Improve error handling:
- Run the tests to verify behavior is unchanged.
- Run linting tools (ruff, flake8) to verify style compliance.
Format
File: <path>
Refactorings Applied:
- <pattern replaced> ->
Lines Changed: <before> -> <after>
Rules
- Never change behavior during refactoring.
- Run tests after every refactoring step.
- Follow PEP 8 style guidelines.