Skip to content
Back to skills

Clean Architecture

ASecurity

Clean Architecture reference, reduced to this owner's positions and test-based enforcement. Use when scaffolding, reviewing layers, or designing a layered system.

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 7, 2026
developmentrustgonextjsdjangorailstesting

Works with

  • cli

Security analysis

A100/100

Scanned November 7, 2026

npx -y skills add samuel-stidham/smithy --skill clean-architecture --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Clean Architecture?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Clean Architecture
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/samuel-stidham-clean-architecture/badge)](https://www.skillsdirectory.com/skills/samuel-stidham-clean-architecture)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: clean-architecture
description: Clean Architecture reference, reduced to this owner's positions and test-based enforcement. Use when scaffolding, reviewing layers, or designing a layered system.
---

# Clean architecture

This skill assumes the textbook: four layers, dependencies point
inward, ports and adapters, composition at the entry point. It
records where this codebase's owner takes positions the textbook
leaves open, and how tests instead of prose enforce the rules.

## Positions

- **Ports are named for capability, never technology.**
  `UserRepository`, never `PostgresUserStore`. `Notifier`, never
  `SmtpClient`. The name must survive an implementation swap.
- **Use cases are verbs.** `PlaceOrder`, `DeactivateUser`. Never
  `UserService`. Generic CRUD names invite scope creep.
- **Entities never get interfaces "for flexibility."** A domain type
  with exactly one shape stays concrete. Wrapping it is indirection
  without payoff. Ports exist at the application boundary, for
  persistence, network, time, randomness, and I/O.
- **A domain test needing a mock is a design smell.** It proves the
  domain took on a dependency it should not have. Fix the dependency,
  never the test.
- **Web apps follow their framework.** Laravel, Rails, Django, and
  Next.js projects keep their own layout. Business logic still stays
  out of controllers and templates. Never force a four-layer tree onto
  a framework that fights it.

## Enforcement

Prose does not enforce the dependency rule. A fitness test does:
a test that fails when `domain/` or `application/` imports
infrastructure, presentation, or a framework package. Scaffolded
projects include one. In review, check imports first. An inner-layer
file importing outward is the violation, whatever the code does. When
the repo has a fitness test, trust it and spot-check. When it lacks
one, suggest adding it.

## Testing per layer

Domain: pure unit tests, no doubles. Application: unit tests with
fakes for ports. Infrastructure: integration tests against the real
dependency, because mocking the thing you integrate with defeats the
test. Presentation: request in, response out. A healthy suite is
mostly fast inner-layer tests with a thin ring of integration tests
at the seams.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.