clean-architecture

Enforce clean architecture layer boundaries in backend services.

9|4|Updated May 30, 2025
One-click install
npx skills add https://github.com/Kaikei-e/Alt --skill clean-architecture-kaikei-e
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clean-architecture
Source: https://github.com/Kaikei-e/Alt/tree/main/.claude/skills/clean-architecture
Command: npx skills add https://github.com/Kaikei-e/Alt --skill clean-architecture-kaikei-e

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide reduces architectural drift and tangled dependencies by prescribing clear, enforceable layer boundaries so teams can maintain separation of concerns and reduce coupling across services.

Core Features & Use Cases

  • Defines five layers and their responsibilities: Handler (entry points and validation), Usecase (business orchestration, no external deps), Port (interface contracts), Gateway (anti-corruption and mapping), and Driver (database and external integrations).
  • Provides file path patterns to identify layers and dependency rules to prevent direct imports that violate clean architecture, useful during development, code review, and refactoring.
  • Highlights common violations to detect and remediate, such as handlers importing drivers directly or usecases depending on external packages.

Quick Start

Organize your service into Handler, Usecase, Port, Gateway, and Driver folders, apply the file naming patterns, and update imports to ensure usecases only depend on ports.

Frequently Asked Questions about clean-architecture

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

FAQPage Schema
How do I enforce clean architecture boundaries in a backend service?

To enforce clean architecture boundaries, organize your service into Handler, Usecase, Port, Gateway, and Driver folders, apply file naming patterns, and update imports to ensure usecases only depend on ports.

What is the correct way to structure layered architecture file paths?

Layered architecture file paths are structured by separating code into five distinct layers: Handler for entry points, Usecase for business orchestration, Port for interface contracts, Gateway for mapping, and Driver for external integrations.

How do I prevent usecases from directly importing external packages?

To prevent usecases from directly importing external packages, define dependency rules that restrict usecases to only depend on ports, ensuring business orchestration remains decoupled from external integrations.

When do I need to separate Gateway and Driver layers during refactoring?

You need to separate Gateway and Driver layers during refactoring when external integrations and database logic must be isolated from business orchestration, using the Gateway as an anti-corruption layer and the Driver for external package interactions.

What are common clean architecture violations to detect during code reviews?

Common clean architecture violations to detect during code reviews include handlers importing drivers directly and usecases depending on external packages, which break layer boundaries and cause tangled dependencies.

Does this approach work for both backend services and libraries?

Yes, enforcing clean architecture boundaries applies to both backend services and libraries, prescribing clear layer responsibilities and import dependencies to maintain separation of concerns and reduce coupling.