Skip to content
Back to skills

Clean Architecture

ASecurity

Evaluates dependency direction and module boundaries in .NET systems using Clean Architecture, Onion, or ports-and-adapters only when those boundaries fit the project. Use for layer placement or coupling; do not impose an architecture on a small application (use csharp-best-practices).

  • 7 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 4, 2026
ai-agentstestingcode-review

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned December 4, 2026

npx -y skills add k4ndev/claude-code-dotnet --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/k4ndev-clean-architecture/badge)](https://www.skillsdirectory.com/skills/k4ndev-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: Evaluates dependency direction and module boundaries in .NET systems using Clean Architecture, Onion, or ports-and-adapters only when those boundaries fit the project. Use for layer placement or coupling; do not impose an architecture on a small application (use csharp-best-practices).
---

# Clean Architecture

## Purpose
Make domain and application policy independent of volatile delivery and infrastructure details where the actual change pressure justifies that boundary.

## Scope
Project references, module boundaries, dependency direction, composition roots, application/domain ownership, and architectural migration choices.

## When to use
- A user asks where code belongs, how projects should depend on each other, or how to reduce proven cross-module coupling.
- A solution has named architecture boundaries to validate or evolve.

## Do not use for
- A small feature needing no architectural change: use the domain implementation skill.
- Class responsibility/interface granularity only: use `solid-principles`.
- Naming a pattern without a concrete pressure: use `design-patterns` only if a pattern is under consideration.

## Required context
Inspect solution/project references, namespaces, domain model, DI composition, runtime/deployment boundaries, tests, and current team architecture constraints. Ask what changes frequently and which consumers depend on the boundary.

## Workflow
1. Draw the actual dependency direction from project references and runtime wiring; do not infer layers from folder names.
2. Locate policy ownership and volatile details (EF Core, HTTP, broker, filesystem, vendor SDK).
3. Identify the concrete coupling cost: forbidden reference, testing barrier, cross-module change amplification, or circular dependency.
4. Propose the smallest boundary that removes that cost; keep composition at the executable entry point.
5. Place an abstraction beside the policy/consumer that needs it when inversion is useful; do not add interfaces for every class.
6. Plan an incremental migration and test the behavior at module contracts, not only mocks.

## Decision rules
- Respect existing architecture unless the task or evidence supports changing it.
- Inner policy should not reference outer infrastructure in a deliberate ports-and-adapters design; Infrastructure implements owned ports and the composition root wires implementations.
- Avoid generic repositories mirroring an ORM, service locators, circular project references, and layers added solely for diagram compliance.

## Expected output format
Show current vs proposed dependency direction, the specific coupling being reduced, affected projects/contracts, migration steps, and tests. State trade-offs and what should remain unchanged.

## Common mistakes
- Treating every app as Clean Architecture, moving code into a new project without a real boundary, or abstracting EF Core without a use-case need.
- Claiming compile-time independence when runtime configuration still couples modules.

## Edge cases
- Modular monoliths can share deployment while retaining explicit module contracts.
- An abstraction may increase complexity when there is one stable implementation and no meaningful test/replace boundary.
- Shared domain concepts do not automatically justify a common project; verify ownership and versioning.

## Examples
See [architecture examples](examples.md) for a dependency inversion case and an over-layered anti-pattern.

## Test scenarios
- Positive: “Our Application project references EF Core and a broker SDK; trace the dependency violation and a minimal migration.”
- Negative: “Explain how `Dictionary<TKey,TValue>` works” routes to `csharp-best-practices`.
- Boundary: “Split this class with multiple responsibilities” routes to `solid-principles` unless project-level dependencies are the concern.

## Related skills
`solid-principles`, `design-patterns`, `dotnet-code-review`, `messaging-patterns`, `testing-quality`.

Files in this skill

  • SKILL.md3.9 KB
  • examples.md1.5 KB

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 ai-agents →

Comments

Loading comments…

Newsletter

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