clean-architecture/SKILL.md
Enforces Clean Architecture principles including the dependency rule, layer separation, and component design. Use when structuring application layers, defining boundaries between domain and infrastructure, reviewing code for dependency rule violations, applying Screaming Architecture, or evaluating component cohesion and coupling (REP, CCP, CRP, ADP, SDP, SAP).
npx skillsauth add kayaman/skills clean-architectureInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Reference: Clean Architecture (Martin), Get Your Hands Dirty on Clean Architecture (Hombergs), Fundamentals of Software Architecture (Richards & Ford)
The overriding rule: Source code dependencies MUST only point inward — from outer layers toward inner layers. Nothing in an inner circle can know anything about an outer circle: no names, no data formats, no function calls.
Dynamic polymorphism (DIP) creates source code dependencies that oppose the flow of control, allowing inner layers to define interfaces that outer layers implement.
From innermost (most stable) to outermost (most volatile):
Order, Money, ShippingPolicyPlaceOrder, CancelSubscription, TransferFunds| Direction | What Crosses | Example |
|-----------|-------------|---------|
| Inward (request) | Input DTO or command object | PlaceOrderCommand { customerId, items[] } |
| Outward (response) | Output DTO or result object | OrderConfirmation { orderId, estimatedDelivery } |
| Never | Entity, DB row, ORM model, framework object | Order entity, Hibernate proxy, Express Request |
The top-level directory structure SHOULD reveal the system's business purpose, not its framework.
Good — screams "health clinic":
src/
appointments/
patients/
billing/
prescriptions/
Bad — screams "Spring Boot":
src/
controllers/
services/
repositories/
models/
appointments/adapter/, appointments/domain/)Split behavior into two parts: a testable component with all the logic, and a humble component that is hard to test but contains minimal logic.
| Component | Testable? | Contains | |-----------|-----------|----------| | Presenter | Yes | Formats data, applies display logic, builds view model | | View | Humble (hard to test) | Renders the view model to screen — minimal logic | | Gateway | Yes (interface) | Defines data access contract | | Repository Impl | Humble | Executes SQL, calls ORM — tested via integration tests |
| Principle | Rule | Tension | |-----------|------|---------| | REP (Reuse/Release Equivalence) | The granule of reuse is the granule of release — group things released together | Too broad: components become bloated | | CCP (Common Closure) | Classes that change together belong together — SRP at component level | Too narrow: too many components | | CRP (Common Reuse) | Don't force users to depend on things they don't need — ISP at component level | Too strict: components fragment |
SHOULD balance these three forces: REP and CCP tend to make components larger; CRP makes them smaller. Early in development, favor CCP (group by change). As the system matures, shift toward CRP (minimize unnecessary dependencies).
| Principle | Rule | |-----------|------| | ADP (Acyclic Dependencies) | The component dependency graph MUST have no cycles | | SDP (Stable Dependencies) | Depend in the direction of stability — volatile components depend on stable ones | | SAP (Stable Abstractions) | Stable components SHOULD be abstract; unstable components SHOULD be concrete |
| Pitfall | Why It Happens | Remedy |
|---------|---------------|--------|
| Over-layering CRUD apps | Applying 4 layers to simple data entry | Skip use case layer for trivial operations; use adapters directly |
| Use cases as repository proxies | Use case does nothing but call repository.save() | If there's no business logic, the use case adds no value — simplify |
| Mapping everything | Identical DTOs at every boundary | Map only where formats genuinely differ; don't cargo-cult mapping |
| "Easy database swap" myth | Justifying layers by hypothetical DB migration | Layers exist for testability and independence, not DB swaps |
| Framework in the domain | Annotations, framework types leak into entities | Entities MUST be plain objects with zero framework dependencies |
| Designing components top-down | Trying to define all components before writing code | Component structure evolves as the codebase grows — don't over-plan |
When designing or reviewing architecture, verify:
| Book | Author(s) | Publisher | Year | |------|-----------|-----------|------| | Clean Architecture | Robert C. Martin | Pearson | 2017 | | Get Your Hands Dirty on Clean Architecture (2nd ed.) | Tom Hombergs | Packt | 2023 | | Fundamentals of Software Architecture | Mark Richards, Neal Ford | O'Reilly | 2020 | | Software Architecture: The Hard Parts | Ford, Richards, Sadalage, Dehghani | O'Reilly | 2021 | | Software Architecture in Practice (4th ed.) | Bass, Clements, Kazman | Addison-Wesley | 2024 | | A Philosophy of Software Design (2nd ed.) | John Ousterhout | Stanford | 2021 |
tools
Guidance for designing charts, graphs, plots, dashboards, and data visualizations that communicate clearly and persuade. Use when creating or reviewing a visualization, choosing a chart type, picking a color palette, decluttering a busy graphic, fixing misleading axes or proportions, building a dashboard, annotating a figure, or turning data into a presentation, report, or data-driven story. Grounded in the standard data-visualization literature (Knaflic, Tufte, Cleveland & McGill, Cairo, Wilke, Munzner, Few, Berinato). Covers chart selection, graphical perception and encoding, color and accessibility, decluttering, graphical integrity, dashboards, and narrative. Does NOT cover building data pipelines or ETL, statistical modeling or analysis methods, BI tool/vendor selection, or general UI/UX layout (see ux-design-principles). Tool-agnostic, with optional Python recipes.
development
Architect and implement production-grade microservices systems in TypeScript (NestJS) and Python (FastAPI), including resilience, observability, testing, deployment, and migration guidance.
development
--- name: databricks-genie-spaces-best-practices description: Design, configure, curate, govern, monitor, and integrate Databricks AI/BI Genie Spaces — the natural-language-to-SQL surface over Unity Catalog. Covers space scoping, general instructions, parameterized example SQL, SQL functions, trusted assets, JOIN configuration, knowledge store, certified queries, benchmarks, monitoring tab, feedback loops, the Genie Conversation API, governance via Unity Catalog (row filters, column masks, embed
tools
Implement OTP and passwordless authentication on AWS for TypeScript projects using Cognito CUSTOM_AUTH triggers (default) or a custom DynamoDB-backed flow, with SES (email) and SNS (SMS) delivery. Use when the user mentions OTP, one-time password, passwordless login, magic link, Cognito custom auth, DefineAuthChallenge, CreateAuthChallenge, VerifyAuthChallengeResponse, SES verification email, SNS SMS code, or MFA over email/SMS. Covers architecture decision (Cognito vs custom), Lambda trigger handlers, SES/SNS notifiers, DynamoDB schema with TTL, rate limiting, constant-time comparison, threat model (enumeration, replay, brute force), and aws-sdk-client-mock testing.