Skip to content

Commit d416dac

Browse files
committed
feat: add clean-code skills category (SOLID, DDD, Hexagonal Architecture) to repository and website showcase
1 parent 651141a commit d416dac

4 files changed

Lines changed: 202 additions & 0 deletions

File tree

site/src/components/os/apps/ShowcaseApp.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,30 @@ const FEATURES: Feature[] = [
600600
install: "npx claudient add agent moe-router",
601601
steps: ["Classify request complexity and risk levels", "Generate execution blueprint JSON", "Dispatch reasoning-heavy parts to Opus", "Build and write boilerplate using Haiku"],
602602
related: ["claudient architect-mason", "claudient council"] },
603+
{ id: "solid-principles", icon: "💎", name: "SOLID Design Principles", tagline: "Clean code OOP standards",
604+
desc: "Enforces the five core SOLID rules during code review and refactoring for scalable, modular class design.",
605+
how: "Inspects code coupling and splits multi-purpose functions to comply with single responsibility bounds.",
606+
example: "Class UserManager -> split into UserRepo + UserAuthenticator",
607+
color: "#b62ad9", category: "enterprise",
608+
install: "npx claudient add skill solid-principles",
609+
steps: ["Verify single responsibility bounds (SRP)", "Refactor switch-cases using polymorphism (OCP)", "Ensure subclass substitution consistency (LSP)", "Split oversized interface parameters (ISP)", "Inject abstract dependencies instead of concretions (DIP)"],
610+
related: ["claudient architect", "claudient adr"] },
611+
{ id: "domain-driven-design", icon: "🏛️", name: "Domain-Driven Design", tagline: "Business-logic separation",
612+
desc: "Models complex logic around bounded contexts, defining aggregates, value objects, and repository boundaries.",
613+
how: "Filters database entities from leaking into core logic, ensuring boundaries are accessed only via aggregate roots.",
614+
example: "Aggregate Root: Order -> Item adds and validates pricing total invariants",
615+
color: "#b62ad9", category: "enterprise",
616+
install: "npx claudient add skill domain-driven-design",
617+
steps: ["Define core domain entities and value objects", "Establish aggregate root boundary invariants", "Abstract data access through Domain Repositories", "Decouple frameworks from business domain logic"],
618+
related: ["claudient architect", "claudient adr"] },
619+
{ id: "hexagonal-architecture", icon: "⬡", name: "Hexagonal Architecture", tagline: "Ports & Adapters isolation",
620+
desc: "Decouples core business logic (Inner Ring) from infrastructure (Outer Ring) using Inbound and Outbound Ports.",
621+
how: "Exposes interfaces (Ports) inside domain, implementing database/web handlers outside (Adapters).",
622+
example: "Inbound Port: UserUseCase -> Adapter: ExpressUserController",
623+
color: "#b62ad9", category: "enterprise",
624+
install: "npx claudient add skill hexagonal-architecture",
625+
steps: ["Construct domain logic without outside dependencies", "Create Inbound and Outbound Port interfaces", "Implement primary adapters for delivery hooks (REST/CLI)", "Implement secondary adapters for infrastructure hooks (DB/API)"],
626+
related: ["claudient architect", "claudient adr"] },
603627
];
604628

605629
export function ShowcaseApp() {
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
name: domain-driven-design
3+
description: "Implement Domain-Driven Design (DDD) patterns: distinguish between Entities, Value Objects, Aggregates, and Repositories"
4+
updated: 2026-06-23
5+
---
6+
7+
# Domain-Driven Design (DDD) Skill
8+
9+
## When to activate
10+
11+
- Modeling complex business logic or enterprise service patterns.
12+
- Decoupling core business rules from databases, frameworks, or delivery mechanisms.
13+
- Defining bounded contexts in microservice systems.
14+
15+
## When NOT to use
16+
17+
- Simple CRUD (Create, Read, Update, Delete) apps where data maps 1:1 to database tables.
18+
- Building stateless helper libraries or data processing scripts.
19+
20+
## Instructions
21+
22+
Structure domain logic around these core tactical patterns:
23+
24+
### 1. Entities
25+
- **Definition**: Objects defined by a unique identity that persists across state changes, rather than their attributes.
26+
- **Guideline**: Ensure they hold an ID, and bundle state mutations with business rules validation.
27+
28+
### 2. Value Objects
29+
- **Definition**: Objects defined strictly by their attributes, with no identity (e.g. Email address, Money value).
30+
- **Guideline**: Treat them as immutable. Any change should instantiate a new Value Object.
31+
32+
### 3. Aggregates
33+
- **Definition**: A cluster of associated objects (Entities and Value Objects) treated as a single unit for data changes.
34+
- **Guideline**: Access children only through the Aggregate Root. Enforce all boundary invariants inside the Root.
35+
36+
### 4. Repositories
37+
- **Definition**: Abstraction layer providing collection-like access to Aggregates (hiding database details).
38+
- **Guideline**: Map database entities to domain entities before returning them.
39+
40+
---
41+
42+
## Example
43+
44+
```typescript
45+
// Value Object (Immutable)
46+
class Money {
47+
constructor(public readonly amount: number, public readonly currency: string) {
48+
if (amount < 0) throw new Error("Amount cannot be negative");
49+
}
50+
}
51+
52+
// Aggregate Root
53+
class Order {
54+
private items: OrderItem[] = [];
55+
constructor(public readonly orderId: string, private total: Money) {}
56+
57+
// Enforce boundary invariants
58+
addItem(item: OrderItem) {
59+
this.items.push(item);
60+
this.total = new Money(this.total.amount + item.price.amount, this.total.currency);
61+
}
62+
}
63+
```
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
name: hexagonal-architecture
3+
description: "Isolate core domain logic using Hexagonal Architecture (Ports and Adapters) to separate business rules from infrastructure"
4+
updated: 2026-06-23
5+
---
6+
7+
# Hexagonal Architecture Skill
8+
9+
## When to activate
10+
11+
- Building enterprise services that must remain decoupled from specific databases (e.g. Postgres vs MongoDB) or web delivery harnesses (Express vs Fastify).
12+
- Designing easily testable systems (mocking infrastructure via Ports).
13+
14+
## When NOT to use
15+
16+
- Small utilities, serverless functions, or script automations.
17+
- Projects built strictly around an ORM's active-record pattern.
18+
19+
## Instructions
20+
21+
Maintain clear separation of concerns across three structural rings:
22+
23+
### 1. The Core Domain (Inner Ring)
24+
- Contains business rules, Entities, and Value Objects.
25+
- **Rule**: Must have **zero** dependencies on outside frameworks, libraries, databases, or transport layers.
26+
27+
### 2. Ports (Middle Ring)
28+
- Interfaces defining how the outside world communicates with the Domain (Inbound/Primary) and how the Domain talks to infrastructure (Outbound/Secondary).
29+
- **Rule**: Defined as abstract classes or interfaces inside the domain layer.
30+
31+
### 3. Adapters (Outer Ring)
32+
- Concrete implementations of Ports.
33+
- *Primary Adapters*: REST controllers, CLI controllers, Event consumers.
34+
- *Secondary Adapters*: Postgres DB repo, Stripe payment client, SMTP email adapter.
35+
36+
---
37+
38+
## Example Structure
39+
40+
```
41+
src/
42+
├── domain/ # Inner Ring (Domain Entities)
43+
│ └── User.ts
44+
├── ports/ # Middle Ring (Interfaces)
45+
│ ├── UserUseCase.ts # Inbound Port
46+
│ └── UserRepository.ts # Outbound Port
47+
└── adapters/ # Outer Ring (Implementations)
48+
├── express-user.ts # Primary Adapter (REST)
49+
└── postgres-user.ts # Secondary Adapter (DB)
50+
```
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
name: solid-principles
3+
description: "Apply SOLID design principles (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion) during refactoring"
4+
updated: 2026-06-23
5+
---
6+
7+
# SOLID Principles Skill
8+
9+
## When to activate
10+
11+
- Designing class hierarchies, modules, or services in object-oriented and functional systems.
12+
- Reviewing code for tight coupling, oversized classes, or hard-to-test components.
13+
- Refactoring legacy codebases to improve extensibility.
14+
15+
## When NOT to use
16+
17+
- Writing small utility scripts, configurations, or single-use shell automations.
18+
- Designing purely relational database schemas (use database-specific skills instead).
19+
20+
## Instructions
21+
22+
Analyze code structures against the five SOLID guidelines:
23+
24+
### 1. Single Responsibility Principle (SRP)
25+
- **Rule**: A class or module should have one, and only one, reason to change.
26+
- **Action**: Extract secondary responsibilities (e.g. logging, network calling, formatting) into separate services.
27+
28+
### 2. Open/Closed Principle (OCP)
29+
- **Rule**: Software entities should be open for extension, but closed for modification.
30+
- **Action**: Use polymorphism, interfaces, or dependency injection instead of hardcoded switch-cases.
31+
32+
### 3. Liskov Substitution Principle (LSP)
33+
- **Rule**: Subtypes must be substitutable for their base types without altering correctness.
34+
- **Action**: Do not throw `NotImplementedException` in subclass overrides. Keep interface contracts consistent.
35+
36+
### 4. Interface Segregation Principle (ISP)
37+
- **Rule**: Clients should not be forced to depend on methods they do not use.
38+
- **Action**: Split large, multi-purpose interfaces into smaller, cohesive contracts.
39+
40+
### 5. Dependency Inversion Principle (DIP)
41+
- **Rule**: Depend on abstractions, not concretions.
42+
- **Action**: Inject interfaces or abstract classes into components rather than instantiating dependencies directly (`new Class()`).
43+
44+
---
45+
46+
## Example (Refactoring tight coupling)
47+
48+
```typescript
49+
// BAD: Violates SRP & DIP
50+
class Invoice {
51+
saveToDB() { /* ... */ }
52+
printInvoice() { /* ... */ }
53+
}
54+
55+
// GOOD: Adheres to SRP & DIP
56+
interface InvoiceRepository {
57+
save(invoice: Invoice): void;
58+
}
59+
class DatabaseInvoiceRepository implements InvoiceRepository {
60+
save(invoice: Invoice) { /* ... */ }
61+
}
62+
class InvoicePrinter {
63+
print(invoice: Invoice) { /* ... */ }
64+
}
65+
```

0 commit comments

Comments
 (0)