python-architecture-patterns

Identify coupling, leaky abstractions, and untestable designs in Python architecture.

Updated Apr 19, 2026
One-click install
npx skills add https://github.com/hoesler/agent-stuff --skill python-architecture-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-architecture-patterns
Source: https://github.com/hoesler/agent-stuff/tree/main/skills/python-architecture-patterns
Command: npx skills add https://github.com/hoesler/agent-stuff --skill python-architecture-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you design, implement, and review Python code that stays testable, decoupled, and easy to change by avoiding common architecture mistakes like god objects, leaky abstractions, and hardcoded dependencies.

Core Features & Use Cases

  • Architecture Guidance: Plan modules, services, class hierarchies, and boundaries using proven principles such as SOLID, separation of concerns, and composition over inheritance.
  • Code Review Support: Spot red flags like deep mock chains, Law of Demeter violations, missing type hints, and side effects hidden in constructors.
  • Refactoring Direction: Turn mixed-concern code into cleaner designs with dependency injection, repositories, adapters, and focused service layers.
  • Practical Python Conventions: Use dataclasses for data objects, Protocols or ABCs for abstractions, and functions for stateless behavior.
  • Use Case: If a Python service directly opens databases, reaches through multiple object layers, or becomes impossible to test without real infrastructure, this Skill shows how to restructure it.

Quick Start

Ask the python-architecture-patterns skill to review your Python codebase and recommend a cleaner, more testable architecture for the specific module or pull request you are working on.

Frequently Asked Questions about python-architecture-patterns

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

FAQPage Schema
How do I refactor a Python service with hardcoded dependencies for better testability?

To improve Python testability, refactor hardcoded dependencies by applying dependency injection, separating concerns with adapter and repository patterns, and enforcing boundary-focused mocks to isolate modules during testing.

What causes leaky abstractions and untestable designs in Python modules?

Leaky abstractions and untestable designs in Python modules are caused by tight coupling, god objects, hidden side effects in constructors, and Law of Demeter violations where services reach through multiple object layers.

How do I structure Python class hierarchies using composition over inheritance?

Structure Python class hierarchies using composition over inheritance by defining abstractions with Protocols or ABCs, utilizing dataclasses for data objects, and implementing stateless behavior as functions rather than deep class trees.

What are common architecture red flags to look for during Python code review?

Common architecture red flags during Python code review include missing type hints, deep mock chains, side effects hidden in constructors, and direct infrastructure access like opening databases inside service layers.

When should I use boundary-focused fakes or mocks in Python testing?

Use boundary-focused fakes or mocks in Python testing when validating service layers and adapters, ensuring tests do not require real infrastructure by isolating dependencies through dependency injection and strict module boundaries.