clean-architecture
Clean Architecture principles for Modular Monolith with bounded contexts and minimal shared kernel. **ALWAYS use when working on backend code, ESPECIALLY when creating files, deciding file locations, or organizing contexts (auth, tax, bi, production).** Use proactively to ensure context isolation and prevent "Core Obesity Syndrome". Examples - "create entity", "add repository", "where should this file go", "modular monolith", "bounded context", "shared kernel", "context isolation", "file location", "layer organization".
What this skill does
You are an expert in Clean Architecture for Modular Monoliths. You guide developers to structure applications with isolated bounded contexts, minimal shared kernel ("anoréxico"), and clear boundaries following the principles: "Duplication Over Coupling", KISS, YAGNI, and "Start Ugly, Refactor Later".
## When to Engage
You should proactively assist when:
- Structuring a new module or bounded context
- Deciding where files belong (which context)
- Designing use cases within a context
- Creating domain entities and value objects
- Preventing shared kernel growth
- Implementing context communication patterns
- User asks about Modular Monolith, Clean Architecture or DDD
## Modular Monolith Principles (CRITICAL)
### 1. Bounded Contexts Over Shared Layers
**NEVER use flat Clean Architecture (domain/application/infrastructure shared by all).**
Instead, use isolated bounded contexts:
```
src/
├── contexts/ # Bounded contexts (NOT shared layers)
│ ├── auth/ # Complete vertical slice
│ │ ├── domain/
│ │ ├── application/
│ │ └── infrastructure/
│ │
│ ├── tax/ # Complete vertical slice
│ │ ├── domain/
│ │ ├── application/
│ │ └── infrastructure/
│ │
│ └── [other contexts]/
│
└── shared/ # Minimal shared kernel
└── domain/
└── value-objects/ # ONLY UUIDv7 and Timestamp!
```
### 2. "Anoréxico" Shared Kernel
**Rule: Shared kernel must be minimal (< 5 files)**
Before adding ANYTHING to shared/, it must pass ALL criteria:
- ✅ Used by ALL contexts (not 2, not 3, ALL)
- ✅ EXACTLY identical in all uses
- ✅ Will NEVER need context-specific variation
- ✅ Is truly infrastructure, not domain logic
**Only allowed in shared:**
- `uuidv7.value-object.ts` - Universal identifier
- `timestamp.value-object.ts` - Universal timestamp
- Infrastructure (DI container, HTTP server, database client)
### 3. Duplication Over Coupling
**PREFER code duplication over creating dependencies:**
```typescript
// ✅ GOOD: Each context has its own Money VO
// contexts/tax/domain/value-objects/tax-amount.ts
export class TaxAmount {
// Tax-specific implementation
}
// contexts/bi/domain/value-objects/revenue.ts
export class Revenue {
// BI-specific implementation
}
// ❌ BAD: Shared Money VO couples contexts
// shared/domain/value-objects/money.ts
export class Money {} // NO! Creates coupling
```
### 4. No Base Classes
**NEVER create base classes that couple contexts:**
```typescript
// ❌ BAD: Base class creates coupling
export abstract class BaseEntity {
id: string;
createdAt: Date;
// Forces all entities into same mold
}
// ✅ GOOD: Each entity is standalone
export class User {
// Only what User needs, no inheritance
}
```
### 5. Context Communication Rules
**Contexts communicate through Application Services, NEVER direct domain access:**
```typescript
// ✅ ALLOWED: Call through application service
import { AuthApplicationService } from "@auth/application/services/auth.service";
// ❌ FORBIDDEN: Direct domain import
import { User } from "@auth/domain/entities/user.entity"; // NEVER!
```
## Core Principles
### The Dependency Rule
**Rule**: Dependencies must point inward, toward the domain
```
┌─────────────────────────────────────────┐
│ Infrastructure Layer │ ← External concerns
│ (DB, HTTP, Queue, Cache, External APIs)│ (Frameworks, Tools)
└────────────────┬────────────────────────┘
│ depends on ↓
┌────────────────▼────────────────────────┐
│ Application Layer │ ← Use Cases
│ (Use Cases, DTOs, Application Services)│ (Business Rules)
└────────────────┬────────────────────────┘
│ depends on ↓
┌────────────────▼─────────────────────────┐
│ Domain Layer │ ← Core Business
│ (Entities, Value Objects, Domain Rules) │ (Pure, Framework-free)
└──────────────────────────────────────────┘
```
**Key Points:**
- Domain layer has NO dependencies (pure business logic)
- Application layer depends ONLY on Domain
- Infrastructure layer depends on Application and Domain
### Benefits
1. **Independence**: Business logic doesn't depend on frameworks
2. **Testability**: Core logic tested without databases or HTTP
3. **Flexibility**: Easy to swap implementations (Postgres → MongoDB)
4. **Maintainability**: Clear boundaries and responsibilities
## Layer Structure (Within Each Context)
**IMPORTANT: These layers exist WITHIN each bounded context, not as shared layers.**
### 1. Domain Layer (Per Context)
**Purpose**: Pure business logic for this specific context
**Location**: `contexts/[context-name]/domain/`
**Contains:**
- Entities (context-specific business objects)
- Value Objects (context-specific immutable objects)
- Ports (context interfaces - NO "I" prefix)
- Domain Events (context events)
- Domain Services (context-specific logic)
- Domain Exceptions (context errors)
**Rules:**
- ✅ NO dependencies on other layers
- ✅ NO dependencies on other contexts
- ✅ NO framework dependencies
- ✅ Pure TypeScript/JavaScript
- ✅ Duplication over shared abstractions
**Example Structure:**
```
contexts/auth/domain/
├── entities/
│ ├── user.entity.ts
│ └── order.entity.ts
├── value-objects/
│ ├── email.value-object.ts
│ ├── money.value-object.ts
│ └── uuidv7.value-object.ts
├── ports/
│ ├── repositories/
│ │ ├── user.repository.ts
│ │ └── order.repository.ts
│ ├── cache.service.ts
│ └── logger.service.ts
├── events/
│ ├── user-created.event.ts
│ └── order-placed.event.ts
├── services/
│ └── pricing.service.ts
└── exceptions/
├── user-not-found.exception.ts
└── invalid-order.exception.ts
```
**Key Concepts:**
- **Entities** have identity and lifecycle (User, Order)
- **Value Objects** are immutable and compared by value (Email, Money, UUIDv7)
- **Ports** are interface contracts (NO "I" prefix) that define boundaries
- **Domain behavior** lives in entities, not in services
#### Value Object Example: UUIDv7
**UUIDv7 is the recommended identifier for all entities.** It provides:
- Time-ordered IDs (monotonic, better database performance)
- Sequential writes (optimal for B-tree indexes)
- Sortable by creation time
- Uses `Bun.randomUUIDv7()` internally (available since Bun 1.3+)
```typescript
// domain/value-objects/uuidv7.value-object.ts
/**
* UUIDv7 Value Object (Generic)
*
* Generic UUID version 7 implementation that can be used by any entity.
*
* Responsibilities:
* - Generate time-ordered UUIDv7 identifiers
* - Validate UUID format
* - Provide type safety
* - Immutable by design
*
* Why UUIDv7?
* - Time-ordered: Monotonic, better database performance
* - Sequential writes: Optimal for B-tree indexes
* - Sortable: Natural ordering by creation time
* - Encodes: Timestamp + random value + counter
*
* Usage:
* Use as-is for entity identifiers:
* - UserId
* - OrderId
* - ProductId
* - etc.
*
* Available since Bun 1.3+
*/
export class UUIDv7 {
private readonly value: string;
private constructor(value: string) {
this.value = value;
}
/**
* Generates a new UUIDv7 identifier
*
* Uses Bun.randomUUIDv7() which generates time-ordered UUIDs.
*
* UUIDv7 features:
* - Time-ordered: Monotonic, suitable for databases
* - Better B-tree index performance (sequential insertion)
* - Sortable by creation time
* - Encodes timestamp + random value + counter
*
* Available since Bun 1.3+
*/
static generate(): UUIDv7 {
const uuid = Bun.randomUUIDv7();
return new UUIDv7(uuid);
}
/**
* Creates UUIDv7 from existing string
*
* Use when reconstituting from database or external source.
*
* @throws {Error} If UUID format is invalid
*/
static from(value: string): UUIDv7 {
if (!UUIDv7.isValid(value)) {
throw new Error(`Invalid UUID format: ${value}`);
}
return new UUIDv7(value);
}
/**
* ValiRelated in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.