s-python-refactor

Refactor Python code with SRP, type hints, and robust error handling.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/gyarra/cine_medallo_2 --skill s-python-refactor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: s-python-refactor
Source: https://github.com/gyarra/cine_medallo_2/tree/main/.claude/skills/s-python-refactor
Command: npx skills add https://github.com/gyarra/cine_medallo_2 --skill s-python-refactor

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Refactor Python code to improve readability, maintainability, and correctness by enforcing Single Responsibility, Pythonic idioms, explicit type hints, robust error handling, consistent naming, and test-friendly structure. It guides developers to perform deliberate, staged refactors rather than ad-hoc rewrites.

Core Features & Use Cases

  • SRP-first: Break large modules into focused functions and classes with clear responsibilities.
  • Type hints & idioms: Introduce modern Python typings, idiomatic constructs, and safer patterns.
  • Testing-friendly: Preserve behavior while improving testability; provide rationale for changes.
  • Use Case: You have a legacy module with tangled logic; refactor into smaller, well-named components with explicit interfaces ready for unit tests.

Quick Start

Refactor the provided Python function to follow SRP and typing guidelines, producing a clean, well-structured version suitable for testing.

Frequently Asked Questions about s-python-refactor

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor Python code to improve readability and testability?

Refactor Python code by enforcing Single Responsibility, explicit type hints, and robust error handling to break large modules into focused, well-named functions ready for unit tests.

What is the best way to apply SRP when refactoring a legacy Python module?

Applying SRP involves breaking tangled legacy logic into smaller, focused classes and functions with clear responsibilities, producing a clean, well-structured version suitable for testing.

How do I add type hints and idioms to existing Python functions during a refactor?

Introduce modern Python typings and idiomatic constructs while preserving behavior, ensuring safer patterns and well-typed interfaces with explicit rationales for each change.

Can I refactor Python service handlers without breaking existing behavior?

Yes, refactoring service handlers preserves behavior while improving testability, applying staged refactors rather than ad-hoc rewrites to ensure safe, well-typed interfaces.

When should I refactor Python code using staged refactors instead of a full rewrite?

Use staged refactors when dealing with legacy modules of varying complexity where readability and testability are priorities, guiding deliberate changes instead of risky ad-hoc rewrites.