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

  1. Read the target Python file or module.
  2. Identify refactoring opportunities:
  3. Apply Pythonic improvements:
  4. Improve code structure:
  5. Improve error handling:
  6. Run the tests to verify behavior is unchanged.
  7. 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.