py-refactor

Characterize legacy Python code with tests and refactor FastAPI services with mypy strictness.

3|Updated Mar 22, 2026
One-click install
npx skills add https://github.com/vndee/engineering-skills --skill py-refactor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: py-refactor
Source: https://github.com/vndee/engineering-skills/tree/main/.claude/skills/py-refactor
Command: npx skills add https://github.com/vndee/engineering-skills --skill py-refactor

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps engineers refactor Python code safely and efficiently, maintaining behavior while improving performance, type safety, and clean architecture in FastAPI backends.

Core Features & Use Cases

  • Characterize legacy code with tests to lock current behavior before changes.
  • Enforce typing discipline with mypy and gradual typing to reduce regressions.
  • Refactor incrementally by extracting boundaries and applying clean architecture principles to FastAPI services.
  • Architect for maintainability: ensure domain boundaries, clear interfaces, and test-driven improvements.

Quick Start

Characterize legacy behavior with tests, then refactor incrementally using typing discipline and architecture guidelines.

Frequently Asked Questions about py-refactor

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

FAQPage Schema
How do I safely refactor legacy Python code in a FastAPI backend?

Refactor legacy Python code safely by first writing characterization tests to lock current behavior, then applying incremental refactoring with strict mypy typing and clean architecture principles to prevent regressions in FastAPI services.

What is characterization testing and when do I need it for Python refactoring?

Characterization testing locks current behavior of legacy Python code before changes. You need it during Python refactoring to capture existing functionality, ensuring safe incremental updates and preventing regressions.

Can I enforce strict typing with mypy while updating existing FastAPI services?

Yes, you can enforce strict typing with mypy while updating existing FastAPI services. The refactoring process integrates mypy strictness and gradual typing to improve type safety and reduce regressions during incremental code updates.

What is the best way to apply clean architecture principles to legacy Python code?

The best way to apply clean architecture to legacy Python code is refactoring incrementally to extract domain boundaries, define clear interfaces, and enforce typing discipline, ensuring maintainability without altering existing behavior.

Does incremental refactoring prevent regressions in FastAPI applications?

Incremental refactoring prevents regressions in FastAPI applications by combining characterization tests with mypy strictness. This approach locks current behavior and enforces typing discipline while extracting boundaries and applying architecture improvements.