clean-architecture

Enforce inward dependencies across entities, use cases, adapters, and frameworks.

Updated Apr 15, 2025
One-click install
npx skills add https://github.com/khrore/nix-config --skill clean-architecture-khrore
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clean-architecture
Source: https://github.com/khrore/nix-config/tree/main/dotfiles/common/.config/opencode/skills/clean-architecture
Command: npx skills add https://github.com/khrore/nix-config --skill clean-architecture-khrore

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

The Clean Architecture approach helps prevent diffusion of concerns by keeping business rules inside inner circles and treating frameworks as interchangeable plugins, enabling resilient, testable systems.

Core Features & Use Cases

  • Dependency Rule, concentric circles, and the Interactor pattern to separate business logic from delivery mechanisms.
  • Boundary anatomy (Input/Output ports, Controllers, Presenters, Gateways) to enable plug-and-play adapters and framework isolation.
  • Main composition root as a plugin that wires concrete implementations without altering core rules.
  • Frameworks and databases treated as details to reduce coupling and enable easy swaps.

Quick Start

Apply Clean Architecture boundaries to an existing module by extracting business rules into inner circles and wrapping infrastructure as plugins.

Frequently Asked Questions about clean-architecture

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

FAQPage Schema
How do I separate business logic from frameworks in my application architecture?

Separating business logic from frameworks is achieved by applying Clean Architecture boundaries. You extract business rules into inner circles and wrap infrastructure as plugins, treating databases and frameworks as details to reduce coupling and enable easy swaps.

What is the dependency rule in Clean Architecture and how does it work?

The dependency rule in Clean Architecture mandates that dependencies must point inward toward the core entities. Inner circles define interfaces and outer adapters implement them, ensuring that outer-layer changes to delivery mechanisms or databases never alter or break core business rules.

How do I structure input and output boundaries for plug-and-play adapters?

Structuring input and output boundaries involves defining Input/Output ports, Controllers, Presenters, and Gateways. This boundary anatomy isolates delivery mechanisms and enables plug-and-play adapters, allowing you to swap infrastructure without modifying the core use cases.

Where do I wire concrete implementations in a Clean Architecture project?

Concrete implementations are wired at the Main composition root. Functioning as a plugin layer, the Main composition root connects concrete adapters and infrastructure to the inner circles without altering the core business rules or use cases.

Can I apply Clean Architecture boundaries to an existing module without rewriting everything?

Yes, you can apply Clean Architecture boundaries to an existing module incrementally. You do this by extracting business rules into inner circles and wrapping existing infrastructure as plugins, enabling framework isolation and testable systems without a full rewrite.

When should I not use Clean Architecture for my software project?

You should avoid Clean Architecture when the overhead of strict boundaries, Interactor patterns, and multiple port interfaces outweighs the need for swap-friendly architecture. For small prototypes or modules where framework swaps are unlikely, this strict separation may introduce unnecessary complexity.