Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Domain Driven Design

ASecurity

Apply Domain-Driven Design patterns. Use when modeling complex business domains, defining bounded contexts, or designing aggregates. Covers entities, value objects, and repositories.

34 stars
0 votes
0 copies
0 views
Added 9/22/2026
designjavaspringdocumentation

Security Analysis

A100/100

Scanned 9/22/2026

Install to Claude Code

$npx -y skills add nguyenhuuca/assessment --skill domain-driven-design --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Domain Driven Design?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Domain Driven Design
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nguyenhuuca-domain-driven-design/badge)](https://www.skillsdirectory.com/skills/nguyenhuuca-domain-driven-design)

More formats (shields.io, HTML) on the badges page.

Download with Pro
Files
SKILL.md
---
name: domain-driven-design
description: Apply Domain-Driven Design patterns. Use when modeling complex business domains, defining bounded contexts, or designing aggregates. Covers entities, value objects, and repositories.
allowed-tools: Read, Write, Glob, Grep
---

# Domain-Driven Design

## Core Concepts

### Ubiquitous Language
Use the same terminology as domain experts. Code should read like business documentation.

### Bounded Context
A boundary within which a particular domain model is defined and applicable.

### Context Map
Shows how bounded contexts relate to each other.

## Building Blocks

### Entity
Has identity that persists over time. Equality based on ID.

```java
@Entity
@Data
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @EqualsAndHashCode.Include
    private Long id;

    @Embedded
    private Email email;

    private String name;

    @Builder.Default
    private Instant createdAt = Instant.now();
}
```

### Value Object
Immutable, equality based on attributes.

```java
@Embeddable
@Value
public class Email {
    private String value;

    private Email(String value) {
        this.value = value;
    }

    public static Email of(String value) {
        if (value == null || !value.contains("@")) {
            throw new IllegalArgumentException("Invalid email");
        }
        return new Email(value);
    }

    // Lombok @Value makes it immutable and generates equals/hashCode
}
```

### Aggregate
Cluster of entities and value objects with a root entity.

```java
@Entity
@Data
public class Order { // Aggregate Root
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
    @JoinColumn(name = "order_id")
    private List<OrderItem> items = new ArrayList<>();

    private Long userId;

    @Enumerated(EnumType.STRING)
    private OrderStatus status;

    // Business logic in domain model
    public void addItem(Long productId, int quantity) {
        // Business rules enforced here
        if (this.status != OrderStatus.DRAFT) {
            throw new IllegalStateException("Cannot add items to submitted order");
        }
        OrderItem item = OrderItem.builder()
            .productId(productId)
            .quantity(quantity)
            .build();
        this.items.add(item);
    }

    public Money getTotal() {
        return items.stream()
            .map(OrderItem::getSubtotal)
            .reduce(Money.zero(), Money::add);
    }

    public void submit() {
        if (items.isEmpty()) {
            throw new IllegalStateException("Cannot submit empty order");
        }
        this.status = OrderStatus.SUBMITTED;
    }
}
```

### Repository
Abstracts data access for aggregates.

```java
@Repository
public interface OrderRepository extends JpaRepository<Order, Long> {
    Optional<Order> findById(Long id);

    @Query("SELECT o FROM Order o LEFT JOIN FETCH o.items WHERE o.id = :id")
    Optional<Order> findByIdWithItems(@Param("id") Long id);

    List<Order> findByUserIdAndStatus(Long userId, OrderStatus status);
}
```

### Domain Event
Something that happened in the domain.

```java
@Value
@Builder
public class OrderPlaced {
    Long orderId;
    Long userId;
    Instant occurredAt;
}

// Publishing domain events with Spring
@Service
@Transactional
public class OrderService {
    private final OrderRepository orderRepository;
    private final ApplicationEventPublisher eventPublisher;

    public void placeOrder(Long orderId) {
        Order order = orderRepository.findById(orderId)
            .orElseThrow(() -> new OrderNotFoundException(orderId));

        order.submit();
        orderRepository.save(order);

        // Publish domain event
        OrderPlaced event = OrderPlaced.builder()
            .orderId(order.getId())
            .userId(order.getUserId())
            .occurredAt(Instant.now())
            .build();
        eventPublisher.publishEvent(event);
    }
}

// Event listener
@Component
public class OrderEventHandler {
    @EventListener
    @Async
    public void handleOrderPlaced(OrderPlaced event) {
        // Send confirmation email, update inventory, etc.
    }
}
```

## Strategic Patterns

### Anti-Corruption Layer
Translate between your model and external systems.

### Shared Kernel
Shared subset of domain model between contexts.

### Customer-Supplier
Upstream provides what downstream needs.

Attribution

nguyenhuucanguyenhuuca
View sourceMore from nguyenhuuca →
SSkills DirectorySkills Directory

Know which skills are safe — weekly.

Best new skills + every skill we flagged as malicious. From the team that scanned 103,619.

Join free

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Know which skills are safe — weekly.

Best new skills + every skill we flagged as malicious. From the team that scanned 103,619.

Join free

Related Skills

Responsive Design

Implement modern responsive layouts using container queries, fluid typography, CSS Grid, and mobile-first breakpoint strategies. Use when building adaptive interfaces, implementing fluid layouts, or creating component-level responsive behavior.

397922 votes

Mermaid Diagrams

Creating and refining Mermaid diagrams with live reload. Use when users want flowcharts, sequence diagrams, class diagrams, ER diagrams, state diagrams, or any other Mermaid visualization. Provides best practices for syntax, styling, and the iterative workflow using mermaid_preview and mermaid_save tools.

2062 votes

sleek-design-mobile-apps

Use when the user wants to design a mobile app, create screens, build UI, or interact with their Sleek projects. Covers high-level requests ("design an app that does X") and specific ones ("list my projects", "create a new project", "screenshot that screen").

5711 votes

swiftui-design-skill

SwiftUI frontend visual design skill. Creates beautiful, distinctive iOS/macOS interfaces that avoid generic AI slop patterns. Covers design direction, layout systems, typography, color, spacing, brand integration, and design review. Use when designing new SwiftUI views, reviewing UI quality, creating iOS prototypes, choosing visual styles, improving app aesthetics, or when the UI looks generic or AI-generated.

1801 votes

Ios Hig

Use when designing iOS interfaces, implementing accessibility (VoiceOver, Dynamic Type), handling dark mode, ensuring adequate touch targets, providing animation/haptic feedback, or requesting user permissions. Apple Human Interface Guidelines for iOS compliance.

761 votes
View all in design →