clean-architecture
Clean Architecture Best Practices
Comprehensive guide to Clean Architecture principles for designing maintainable, testable software systems. Based on Robert C. Martin's "Clean Architecture: A Craftsman's Guide to Software Structure and Design." Contains 42 rules across 8 categories, prioritized by architectural impact.
When to Apply
Reference these guidelines when:
- Designing new software systems or modules
- Structuring dependencies between layers
- Defining boundaries between business logic and infrastructure
- Reviewing code for architectural violations
- Refactoring coupled systems toward cleaner structure
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Dependency Direction | CRITICAL | dep- |
| 2 | Entity Design | CRITICAL | entity- |
| 3 | Use Case Isolation | HIGH | usecase- |
| 4 | Component Cohesion | HIGH | comp- |
| 5 | Boundary Definition | MEDIUM-HIGH | bound- |
| 6 | Interface Adapters | MEDIUM | adapt- |
| 7 | Framework Isolation | MEDIUM | frame- |
| 8 | Testing Architecture | LOW-MEDIUM | test- |
Quick Reference
1. Dependency Direction (CRITICAL)
dep-inward-only- Source dependencies point inward onlydep-interface-ownership- Interfaces belong to clients not implementersdep-no-framework-imports- Avoid framework imports in inner layersdep-data-crossing-boundaries- Use simple data structures across boundariesdep-acyclic-dependencies- Eliminate cyclic dependencies between componentsdep-stable-abstractions- Depend on stable abstractions not volatile concretions
2. Entity Design (CRITICAL)
entity-pure-business-rules- Entities contain only enterprise business rulesentity-no-persistence-awareness- Entities must not know how they are persistedentity-encapsulate-invariants- Encapsulate business invariants within entitiesentity-value-objects- Use value objects for domain conceptsentity-rich-not-anemic- Build rich domain models not anemic data structures
3. Use Case Isolation (HIGH)
usecase-single-responsibility- Each use case has one reason to changeusecase-input-output-ports- Define input and output ports for use casesusecase-orchestrates-not-implements- Use cases orchestrate entities not implement business rulesusecase-no-presentation-logic- Use cases must not contain presentation logicusecase-explicit-dependencies- Declare all dependencies explicitly in constructorusecase-transaction-boundary- Use case defines the transaction boundary
4. Component Cohesion (HIGH)
comp-screaming-architecture- Structure should scream the domain not the frameworkcomp-common-closure- Group classes that change togethercomp-common-reuse- Avoid forcing clients to depend on unused codecomp-reuse-release-equivalence- Release components as cohesive unitscomp-stable-dependencies- Depend in the direction of stability
5. Boundary Definition (MEDIUM-HIGH)
bound-humble-object- Use humble objects at architectural boundariesbound-partial-boundaries- Use partial boundaries when full separation is prematurebound-boundary-cost-awareness- Weigh boundary cost against ignorance costbound-main-component- Treat main as a plugin to the applicationbound-defer-decisions- Defer framework and database decisionsbound-service-internal-architecture- Services must have internal clean architecture
6. Interface Adapters (MEDIUM)
adapt-controller-thin- Keep controllers thinadapt-presenter-formats- Presenters format data for the viewadapt-gateway-abstraction- Gateways hide external system detailsadapt-mapper-translation- Use mappers to translate between layersadapt-anti-corruption-layer- Build anti-corruption layers for external systems
7. Framework Isolation (MEDIUM)
frame-domain-purity- Domain layer has zero framework dependenciesframe-orm-in-infrastructure- Keep ORM usage in infrastructure layerframe-web-in-infrastructure- Web framework concerns stay in interface layerframe-di-container-edge- Dependency injection containers live at the edgeframe-logging-abstraction- Abstract logging behind domain interfaces
8. Testing Architecture (LOW-MEDIUM)
test-tests-are-architecture- Tests are part of the system architecturetest-testable-design- Design for testability from the starttest-layer-isolation- Test each layer in isolationtest-boundary-verification- Verify architectural boundaries with tests
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
Reference Files
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |
More from jwa91/agentskills
interactive-learner
Personal AI tutoring skill that deeply researches any topic, then creates rich, interactive HTML courses with quizzes, simulators, debug challenges, explain-back exercises, real-world missions, and more. Tracks per-concept mastery across sessions with spaced repetition. Use when: (1) the user wants to learn a new topic, (2) the user says 'teach me X' or 'I want to learn X', (3) the user asks for an interactive lesson or course, (4) the user wants to study or review a subject. Works for any topic: technical, conceptual, creative, math, languages.
15mac-cleanup
Interactive macOS system cleanup for any dev machine. Frees disk space by pruning caches, package managers, unused apps, stale dev artifacts, and more. Discovers what's installed rather than assuming a specific setup. Always consults the user before deleting anything. Use when the user asks to: clean up their Mac, free disk space, remove unused apps, prune caches, clean developer artifacts, or any disk space maintenance task.
8spec
Interviews the user about a product idea or feature using structured questions, then generates a detailed spec document (SPEC.md). Use when the user wants to flesh out an idea, plan a feature, or create a buildable specification.
5personal-commit-review
Create a personal GitHub coding retrospective from a date range and turn it into a short Markdown review. Research commit activity across accessible public and private repositories through the authenticated gh CLI, understand what the relevant repositories and subsystems are for, and write a prose retrospective with stats and highlights. Use when the user asks for a commit review, coding recap, engineering retrospective, GitHub activity story, weekly/monthly/yearly highlights, or a written summary of what their commits achieved.
3env-inspector
Safely inspect .env files by showing key names and clearly non-sensitive values while redacting anything that looks like a secret. Best-effort heuristic redaction (keyword block + token-pattern blocklist + Shannon-entropy check + value allowlist) — not a cryptographic guarantee. Use when you need to understand a project's environment configuration without exposing credentials.
2vps-dependency-overview
Generate an offline-first dependency overview across services in a Docker-compose monorepo. Reports image tags & pinning quality, Dockerfile base images, runtime hints (Node/Python via .nvmrc, .python-version, package.json engines, pyproject.toml), and lockfile presence. Use when you want a single report of "what am I running and where are my update surfaces?" — no network calls, no pulls.
2