python-design-patterns

Refactors Python code using design patterns to improve maintainability and testability.

1|1|Updated Apr 20, 2026
One-click install
npx skills add https://github.com/svssdeva/agentic-skills --skill python-design-patterns-svssdeva
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-design-patterns
Source: https://github.com/svssdeva/agentic-skills/tree/main/python/python-design-patterns
Command: npx skills add https://github.com/svssdeva/agentic-skills --skill python-design-patterns-svssdeva

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you fix overly complex or tightly coupled Python code so it becomes easier to test, maintain, and extend.

Core Features & Use Cases

  • KISS and SRP: Simplifies solutions and enforces single responsibility to reduce accidental complexity.
  • Composition and Separation of Concerns: Guides layering (API/handlers → services → repositories) and choosing composition over inheritance.
  • Refactoring Heuristics: Applies practical triggers like function size limits, the rule of three before abstraction, and dependency injection to improve testability.

Use cases: designing a new service from scratch; refactoring a God class or monolithic function; reviewing a pull request for tight coupling, leaked internal types, or entangled I/O and business logic; choosing inheritance vs composition for a class hierarchy.

Quick Start

Use the python-design-patterns skill to refactor this module by splitting responsibilities, removing layer violations, and replacing inheritance with composition where appropriate.

Frequently Asked Questions about python-design-patterns

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

FAQPage Schema
How do I refactor a God class in Python to improve maintainability?

To refactor a Python God class, you split responsibilities to enforce single responsibility and reduce accidental complexity. This Skill guides reducing monolithic functions into simpler, testable design patterns using separation of concerns and layering.

When should I use composition over inheritance in Python class design?

Choose composition over inheritance in Python to build flexible class hierarchies and improve testability. This Skill guides decisions between inheritance and composition to ensure separation of concerns and reduce tight coupling.

How do I apply dependency injection to decouple Python services?

Apply dependency injection in Python to decouple services by passing dependencies externally instead of instantiating them internally. This Skill guides using dependency injection to separate entangled I/O and business logic for improved testability.

What is the rule of three for Python refactoring and when should I apply it?

The rule of three in Python refactoring triggers abstraction only after code is duplicated three times, preventing premature generalization. This Skill applies this heuristic alongside function size discipline and KISS principles to reduce accidental complexity.

How do I review a Python pull request for tight coupling and leaked internal types?

Review a Python pull request for tight coupling by checking layering violations between API handlers, services, and repositories. This Skill helps identify leaked internal types and entangled I/O to enforce proper separation of concerns.