agentleFS
dagarre00dagarre00/claude-code-template/.claude/skills/clean-architecture/SKILL.md

clean-architecture

Skill1 starsChanged 28 days agoMITView on GitHub

Subagent-side, preloaded into the developer; also read by the conductor in /project:init. How to place and wire code under the boundaries architecture.md § Layers declares — the four shapes (layered, core/shell, slices, flat) and when each fits, which boundary a file belongs to, reaching the outside through a port, wiring adapters, and handling architecture check failures.

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

3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 26 edited versions we read keep these.

  • 2

    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. Very specific:

    Place files in the directories named in § Layers.

    line 38
  2. Distinctive:

    Never import framework types, ORM models, HTTP objects, or SDK types into an inner boundary.

    line 49
  3. Distinctive:

    Mocking owned domain/port types: instead of writing a simple fake.

    line 70

“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 — placing and wiring code

Read first

  • docs/wiki/architecture.md § Layers — the shape, its boundary table, composition root, and exceptions.
  • docs/wiki/commands.md § Architecture — the enforcement command (none for flat).

Shapes

/project:init picks one and records it as an ADR; the rest of this skill applies the one recorded.

ShapeFitsBoundaries
layeredbackend services, domain-rich appsdomain ← application ← adapters ← infrastructure, ports owned by application
core/shellCLIs, parsers, compilers, small SDKscore (pure logic, owns its ports) ← shell (I/O, entry points, adapters)
slicesfrontends, feature-heavy appsone slice per feature, importing only shared and other slices' public API
flatscripts, tiny librariesnone; no check, simplicity-ladder alone decides structure

Pick the smallest shape the project's I/O and domain justify: four layers on a CLI is indirection simplicity-ladder would reject, and flat on a service with a database lets I/O leak into every rule.

Place every new file

Choose the boundary before creating a file by what the code knows about, using the row for the declared shape:

If the code…layeredcore/shellslices
states a rule true with no database, UI, or networkdomaincoreits slice (or shared if two slices need it)
orchestrates one user-meaningful operation and declares external needs as portsapplicationcoreits slice
converts between external shapes and inner shapes (HTTP ↔ input, rows ↔ entities, SDK ↔ port)adaptersshellits slice
configures or wraps a framework, driver, client, or runtimeinfrastructureshellshared

Place files in the directories named in § Layers. A file spanning two boundaries must be split into two files. Under flat, put the file where the existing layout puts its neighbours.

Reach the outside through a port

layered and core/shell only. When an inner boundary (domain/application, or core) needs external I/O (persistence, time, randomness, network):

  1. Declare the port in the inner boundary using its own types (OrderRepository.save(order), Clock.now()), never driver/framework types.
  2. Test the inner code against an in-memory fake of the port (no database needed for its Red/Green).
  3. Implement the port in the outer boundary as its own Behavior case with an integration test against the real boundary.
  4. Wire concrete adapters in the composition root only. Inner code receives ports via injection.

Never import framework types, ORM models, HTTP objects, or SDK types into an inner boundary.

Cross a slice

slices only. A slice imports another slice only through the public API (index file or module root) that slice exports; code two slices need moves to shared in its own case. shared never imports a slice.

When the architecture check fails

  • Your change caused it → move the code to the right boundary, or invert the dependency via a port or public API, then re-run check + tests.
  • Requires more than a small port → stop and report which case, import, and port are needed.
  • The rule itself seems wrong → stop and report; the shape and rule files are protected and require human approval + an ADR (rule 23).
  • Never silence the check with ignore comments, dynamic imports, or widened allowlists.

Anti-patterns

  • Anemic use case: business rules in a controller while the use case merely forwards to a repo.
  • Leaky port: returning ORM rows, HTTP responses, or SDK objects across a port.
  • Service locator: pulling dependencies from a global container inside inner code.
  • Cross-boundary utils: shared helpers that quietly import framework/infrastructure packages.
  • Reaching into a slice: importing another slice's internals instead of its public API.
  • Ceremony past the shape: a port, factory, or layer the declared shape does not ask for.
  • Mocking owned domain/port types instead of writing a simple fake.

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.