Skill

applying-pragmatic-layered

Install
1
Install the plugin
$
npx claudepluginhub allousas/claude-code-plugins --plugin kotlin-architecture

Want just this skill?

Add to a custom plugin, then install with one command.

Description

Apply when creating or moving, files or packages (also plan mode) and project is using layered architecture.

Tool Access

This skill uses the workspace's default tool permissions.

Skill Content

Purpose

Organise code with a modern layered architecture so business logic is clearly separated from infrastructure concerns. The following guidelines provide a pragmatic approach to layered architecture that keeps the simplicity of traditional 3-layer with a modern approach.

Principles

  1. Produce clean, modular, testable layered code.
  2. Separate business logic from infrastructure concerns through package boundaries, not abstractions.
  3. No port interfaces — business services depend on concrete infrastructure classes directly.
  4. Maintainability and simplicity should be preferred over architectural purity.
  5. Always place files in the correct layer and path according to the project structure.
  6. Take a look always at the layered shortcuts rules to understand which shortcuts are allowed in this project.

Dependency Rule

entrypoint → business → infrastructure
  • Business layer depends on infrastructure (traditional downward direction, no dependency inversion)
  • Entrypoint layer depends on business and infrastructure
  • Infrastructure has no dependencies on other layers

Package Structure

Standard style

src/main/kotlin/<company-package>/
├── business/           # Core business logic
│   ├── domain/         # Aggregates, entities, value objects, domain events, domain errors
│   └── services/       # Use cases — orchestration of infrastructure and domain
├── entrypoint/         # Inbound adapters — triggers that invoke business services (HTTP endpoints, Kafka consumers, etc...)
└── infrastructure/     # Outbound adapters — technical concerns
    ├── db/             # Repositories
    ├── clients/        # HTTP clients (internal and external)
    ├── observability/  # Logging, metrics via domain event listeners
    └── config/         # Spring configuration, framework wiring

Allow any other structure as long as it is consistent and logical to layered architecture.

Layered shortcuts

This approach intentionally simplifies classical layered architecture:

  • No port interfaces — business services depend on concrete infrastructure classes, no need for interfaces when there is a single implementation
  • Framework annotations in the business layer are acceptable when they reduce boilerplate without leaking framework logic (@Transactional, @Service)
  • Leak domain to entrypoints and infrastructure — domain model can be used directly in other layers, we don't need to create separate DTOs for translation if the domain model is already suitable for that purpose
  • Avoid multimodule projects - Multimodule projects create unnecessary complexity and boilerplate, prefer a single module with clear package structure instead of splitting into multiple modules

How It Differs from Hexagonal

AspectHexagonalModern Layered
Port interfacesDomain defines interfaces for all outbound dependenciesNo interfaces — services depend on concrete infrastructure classes
Dependency directionInfrastructure depends on domain (dependency inversion)Business depends on infrastructure (traditional downward)
Adapter registrationAdapters implement domain-defined portsInfrastructure classes are Spring beans injected directly
TestabilityTest domain with fake implementations of portsTests use mocking libraries to mock concrete infrastructure classes
ComplexityHigher ceremony (interface per dependency)Lower ceremony (no boilerplate interfaces)
Stats
Stars1
Forks0
Last CommitFeb 24, 2026
Actions

Similar Skills

cache-components

Expert guidance for Next.js Cache Components and Partial Prerendering (PPR). **PROACTIVE ACTIVATION**: Use this skill automatically when working in Next.js projects that have `cacheComponents: true` in their next.config.ts/next.config.js. When this config is detected, proactively apply Cache Components patterns and best practices to all React Server Component implementations. **DETECTION**: At the start of a session in a Next.js project, check for `cacheComponents: true` in next.config. If enabled, this skill's patterns should guide all component authoring, data fetching, and caching decisions. **USE CASES**: Implementing 'use cache' directive, configuring cache lifetimes with cacheLife(), tagging cached data with cacheTag(), invalidating caches with updateTag()/revalidateTag(), optimizing static vs dynamic content boundaries, debugging cache issues, and reviewing Cache Component implementations.

138.4k