ddd-cqrs-patterns
БесплатноБез исполняемых скриптовНе проверенDomain-Driven Design and CQRS patterns for .NET microservices including aggregates, value objects, domain events, repositories, and application layer design
от TheLobbi★ 22 звезды на GitHubОб этом скилле
Domain-Driven Design & CQRS Patterns
DDD Layered Architecture
┌──────────────────────────────────────────┐
│ Presentation Layer │
│ (Blazor Web App / API Controllers) │
├──────────────────────────────────────────┤
│ Application Layer │
│ (Commands, Queries, Handlers, DTOs) │
│ (MediatR, Validation, Mapping) │
├──────────────────────────────────────────┤
│ Domain Layer │
│ (Entities, Value Objects, Aggregates) │
│ (Domain Events, Domain Services) │
│ (Repository Interfaces, Specifications) │
├──────────────────────────────────────────┤
│ Infrastructure Layer │
│ (EF Core, Repositories, Event Bus) │
│ (External Services, Messaging) │
└──────────────────────────────────────────┘
Key rule: Dependencies point inward. Domain has zero external dependencies.
Entity Base Class
public abstract class Entity
{
private int? _requestedHashCode;
private int _id;
public virtual int Id
{
get => _id;
protected set => _id = value;
}
private readonly List<INotification> _domainEvents = [];
public IReadOnlyCollection<INotification> DomainEvents => _domainEvents.AsReadOnly();
public void AddDomainEvent(INotification eventItem) => _domainEvents.Add(eventItem);
public void RemoveDomainEvent(INotification eventItem) => _domainEvents.Remove(eventItem);
public void ClearDomainEvents() => _domainEvents.Clear();
public bool IsTransient() => Id == default;
public override bool Equals(object? obj)
{
if (obj is not Entity other) return false;
if (ReferenceEquals(this, other)) return true;
if (GetType() != other.GetType()) return false;
if (other.IsTransient() || IsTransient()) return false;
return Id == other.Id;
}
public override int GetHashCode()
{
if (!IsTransient())
{
_requestedHashCode ??= Id.GetHashCode() ^ 31;
return _requestedHashCode.Value;
}
return base.GetHashCode();
}
public static bool operator ==(Entity? left, Entity? right) => Equals(left, right);
public static bool operator !=(Entity? left, Entity? right) => !Equals(left, right);
}
Value Objects
public abstract class ValueObject
{
protected abstract IEnumerable<object?> GetEqualityComponents();
public override bool Equals(object? obj)
{
if (obj is null || obj.GetType() != GetType()) return false;
var other = (ValueObject)obj;
return GetEqualityComponents().SequenceEqual(other.GetEqualityComponents());
}
public override int GetHashCode() =>
GetEqualityComponents()
.Select(x => x?.GetHashCode() ?? 0)
.Aggregate((x, y) => x ^ y);
public static bool operator ==(ValueObject? left, ValueObject? right) =>
Equals(left, right);
public static bool operator !=(ValueObject? left, ValueObject? right) =>
!Equals(left, right);
}
// Example: Address value object
public sealed class Address : ValueObject
{
public string Street { get; }
public string City { get; }
public string State { get; }
public string Country { get; }
public string ZipCode { get; }
public Address(string street, string city, string state, string country, string zipCode)
{
Street = street;
City = city;
State = state;
Country = country;
ZipCode = zipCode;
}
protected override IEnumerable<object?> GetEqualityComponents()
{
yield return Street;
yield return City;
yield return State;
yield return Country;
yield return ZipCode;
}
}
// Example: Money value object
public sealed class Money : ValueObject
{
public decimal Amount { get; }
public string Currency { get; }
public Money(decimal amount, string currency)
{
if (amount < 0) throw new ArgumentException("Amount cannot be negative");
Amount = amount;
Currency = currency ?? throw new ArgumentNullException(nameof(currency));
}
public Money Add(Money other)
{
if (Currency != other.Currency) throw new InvalidOperationException("Cannot add different currencies");
return new Money(Amount + other.Amount, Currency);
}
protected override IEnumerable<object?> GetEqualityComponents()
{
yield return Amount;
yield return Currency;
}
}
Aggregate Root
public abstract class AggregateRoot : Entity, IAggregateRoot { }
// Example: Order aggregate
public sealed class Order : AggregateRoot
{
private readonly List<OrderItem> _orderItems = [];
public IReadOnlyCollection<OrderItem> OrderItems => _orderItems.AsReadOnly();
public DateTime OrderDate { get; private set; }
public Address ShippingAddress { get; private set; } = null!;
public
Установить ddd-cqrs-patterns в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadWriteEditGrepBashFAQ
Что делает скилл ddd-cqrs-patterns?
Domain-Driven Design and CQRS patterns for .NET microservices including aggregates, value objects, domain events, repositories, and application layer design
Как установить скилл ddd-cqrs-patterns?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ddd-cqrs-patterns запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic