python-clean-architecture

Structure Python services with clean architecture separating domain, infrastructure, and API layers.

6|Updated Feb 19, 2026
One-click install
npx skills add https://github.com/jerelvelarde/chalk-skills --skill python-clean-architecture-jerelvelarde
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-clean-architecture
Source: https://github.com/jerelvelarde/chalk-skills/tree/main/skills/python-clean-architecture
Command: npx skills add https://github.com/jerelvelarde/chalk-skills --skill python-clean-architecture-jerelvelarde

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Python services often become tangled when business logic is mixed with framework and infrastructure concerns. This Skill guides teams to structure projects with a clear clean-architecture boundary to improve testability and maintainability.

Core Features & Use Cases

  • Domain-driven design with explicit domain models and boundaries.
  • Clear separation between domain, infrastructure, and API layers to enable independent evolution.
  • Dependency-injection-friendly structure that makes unit testing and refactoring safer.

Quick Start

Create a Python project that follows a clean architecture layout (domain/, infrastructure/, api/) and wire dependencies via constructors, then implement a small use case (e.g., user registration) to validate the boundaries.

Frequently Asked Questions about python-clean-architecture

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

FAQPage Schema
How do I separate business logic from infrastructure in Python services?

To separate business logic from infrastructure in Python services, apply clean architecture boundaries using domain, infrastructure, and API layers. This structure isolates domain models and keeps framework-specific code independent, improving testability and maintainability.

What is the best way to structure Python projects for testable domain models?

The best way to structure Python projects for testable domain models is using a clean architecture layout with domain/, infrastructure/, and api/ directories. Wiring dependencies via constructors enforces clear boundaries and enables safe unit testing.

Why does mixing framework code with domain logic make Python services hard to test?

Mixing framework code with domain logic makes Python services hard to test because business rules become tightly coupled to infrastructure. Applying dependency injection and the repository pattern separates these concerns, allowing domain models to be tested independently.

Can I use dependency injection with the repository pattern in Python clean architecture?

Yes, you can use dependency injection with the repository pattern in Python clean architecture. Wiring dependencies via constructors creates a framework-agnostic service structure that enforces domain-driven design boundaries and makes refactoring safer.

Does clean architecture work for small Python projects or is it only for large services?

Clean architecture works for Python projects of any size, including small services. It applies domain-driven design concepts and dependency injection to maintain clear boundaries between layers, ensuring your project scales neatly without tangled infrastructure concerns.

When should I not use clean architecture for my Python application?

You should not use clean architecture for Python applications when minimal complexity does not justify the overhead of separating domain, infrastructure, and API layers. For simple scripts or rapid prototypes, enforcing the repository pattern and dependency injection may add unnecessary structural boilerplate.