agentleFS
kinhluankinhluan/skills/skills/clean-architecture/SKILL.md

clean-architecture

Skill6 starsChanged 6 months agoMITView on GitHub

Design or refactor code boundaries so business policy does not depend on volatile frameworks, databases, UI, or infrastructure. Use for Clean/Hexagonal/Onion architecture, dependency-rule reviews, ports and adapters, use cases, component boundaries, or testability.

28 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use convention-learner, opentelemetry and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • codewithmukeshSkill

    convention-learner

    Detects and enforces project-specific coding conventions by analyzing existing codebase patterns. Learns naming conventions, folder structure, test organization, and coding style from the existing code. Load when: "conventions", "coding standards", "project patterns", "enforce style", "detect patterns", "learn conventions", "code consistency".

    Also in 3 projects that use this

  • codewithmukeshSkill

    opentelemetry

    OpenTelemetry observability for .NET 10 applications. Covers traces, metrics, and logs using the OpenTelemetry SDK with OTLP export. Includes custom ActivitySource, IMeterFactory metrics, resource configuration, and Aspire Dashboard integration. Load this skill when setting up distributed tracing, custom metrics, OTLP export, or when the user mentions "OpenTelemetry", "OTLP", "traces", "spans", "Activity", "ActivitySource", "metrics", "IMeterFactory", "Meter", "Counter", "Histogram", "Gauge", "telemetry", "observability", "distributed tracing", "OTEL", or "Aspire Dashboard".

    Also in 3 projects that use this

  • MovGP0Skill

    modern-csharp

    Modern C# style guidance for Bendex and MicroSea code changes, including primary constructors, expression-bodied members, var usage, target-typed new, lambdas, and pattern matching.

    Also in 3 projects that use this

  • MicrosoftSkill

    resilience

    Apply resilience patterns (retry, backoff, circuit breaking) when writing or reviewing code that makes outbound HTTP/REST calls, database operations, or any I/O that can experience transient failures. Use this skill when: (1) writing new code that calls external services or APIs, (2) reviewing code that uses fetch, HTTP clients, or service-to-service calls, (3) adding queue consumers or workers that interact with remote systems, (4) debugging intermittent failures in production.

    Also in 3 projects that use this

  • hongyuancSkill

    vertical-slice

    Build and evaluate a production-quality vertical slice before advancing from Pre-Production to Production.

    Also in 3 projects that use this

  • wpankSkill

    caching

    Caching strategies, invalidation, eviction policies, HTTP caching, distributed caching, and anti-patterns. Use when designing cache layers, choosing eviction policies, debugging stale data, or optimizing read-heavy workloads.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 26 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Test policy through ports and add adapter contract/integration tests.

    line 21
  2. Distinctive:

    use cases coordinate intent and transactions without becoming a grab bag.

    line 29
  3. Distinctive:

    keep transaction and consistency ownership explicit.

    line 33
  4. Distinctive:

    avoid global service locators and hidden dependencies.

    line 35
  5. Very specific:

    Read references/detailed-guide.md only for a relevant pattern or code example.

    line 55

“Common” is measured: kept by at least 6 in 10 of the 26 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Clean Architecture

Protect stable policy from volatile details. Apply the dependency rule at meaningful component/module boundaries; do not reproduce a fixed four-layer folder tree in every application.

Workflow

  1. Identify business policy, use cases, inputs/outputs, and volatile details.
  2. Inspect source-code dependencies, runtime calls, data shapes, and ownership.
  3. Choose boundaries where independent testing or replacement has real value.
  4. Define inward-owned ports using domain/use-case language.
  5. Implement outward adapters for web, database, messaging, UI, and vendors.
  6. Translate boundary DTOs rather than leaking framework or persistence types inward.
  7. Wire dependencies at a composition root.
  8. Test policy through ports and add adapter contract/integration tests.
  9. Measure whether the boundary reduces change cost; remove abstractions that only forward calls.

Runtime control may flow outward while source dependencies point inward.

Boundary Rules

  • domain policy must not import a web framework, ORM, queue client, or vendor SDK;
  • use cases coordinate intent and transactions without becoming a grab bag;
  • interfaces belong near the consumer/policy that needs them;
  • adapters handle protocol, serialization, retries, and infrastructure errors;
  • map errors into stable boundary semantics;
  • keep transaction and consistency ownership explicit;
  • prevent transport/database DTOs from becoming the domain model;
  • avoid global service locators and hidden dependencies.

Calibrate the Design

Simple CRUD may need fewer boundaries than a complex core domain. A modular monolith can follow the dependency rule; microservices are not required. “Repository,” “service,” and “use case” names do not prove clean architecture—inspect dependency direction and change coupling.

Review Questions

  • Can policy tests run without network, database, clock, or framework boot?
  • Which dependency changes force policy changes?
  • Are abstractions stable and behavior-oriented?
  • Does mapping preserve validation and error meaning?
  • Where do authorization, transactions, retries, and idempotency live?
  • Are packages organized around capabilities or only technical layers?
  • Is the abstraction cost lower than expected volatility?

Output

Return the current dependency map, proposed boundaries/ports/adapters, violations with evidence, migration slices, test strategy, tradeoffs, and what should deliberately remain simple.

Read references/detailed-guide.md only for a relevant pattern or code example. Use ddd-tactical when the main problem is domain invariants and c4-level3-component for component visualization.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.