← スキル一覧に戻る

entity-creator
by ademceper
⭐ 1🍴 0📅 2026年1月23日
SKILL.md
name: entity-creator description: Creates complete DDD entity with factory method, domain events, value objects, and EF configuration
Entity Creator Skill
Bu skill, Merge E-Commerce Backend projesi için DDD uyumlu entity oluşturur.
Ne Zaman Kullan
- "Entity oluştur", "aggregate root ekle" dendiğinde
- Yeni bir domain modeli eklenirken
- "Product entity'si yaz" gibi isteklerde
Oluşturulacak Dosyalar
Merge.Domain/{Module}/
├── Entities/
│ └── {Entity}.cs
├── Events/
│ ├── {Entity}CreatedEvent.cs
│ └── {Entity}UpdatedEvent.cs
└── Specifications/
└── {Entity}ByIdSpec.cs
Merge.Infrastructure/Data/Configurations/
└── {Entity}Configuration.cs
Entity Template
public class {Entity} : BaseAggregateRoot
{
// ============================================
// PRIVATE SETTERS (encapsulation)
// ============================================
public string Name { get; private set; } = null!;
public bool IsActive { get; private set; }
// ============================================
// COLLECTIONS (private backing field)
// ============================================
private readonly List<{Related}> _{related}s = [];
public IReadOnlyCollection<{Related}> {Related}s => _{related}s.AsReadOnly();
// ============================================
// PRIVATE CONSTRUCTOR (EF Core)
// ============================================
private {Entity}() { }
// ============================================
// FACTORY METHOD (ONLY way to create)
// ============================================
public static {Entity} Create(string name, /* other params */)
{
Guard.AgainstNullOrEmpty(name, nameof(name));
var entity = new {Entity}
{
Id = Guid.NewGuid(),
Name = name,
IsActive = true,
CreatedAt = DateTime.UtcNow
};
entity.AddDomainEvent(new {Entity}CreatedEvent(entity.Id, entity.Name));
return entity;
}
// ============================================
// DOMAIN METHODS (business behavior)
// ============================================
public void UpdateName(string newName)
{
Guard.AgainstNullOrEmpty(newName, nameof(newName));
if (Name == newName) return;
var oldName = Name;
Name = newName;
MarkAsUpdated();
AddDomainEvent(new {Entity}NameChangedEvent(Id, oldName, newName));
}
public void Deactivate()
{
if (!IsActive) return;
IsActive = false;
MarkAsUpdated();
AddDomainEvent(new {Entity}DeactivatedEvent(Id));
}
}
Domain Event Template
public record {Entity}CreatedEvent(Guid {Entity}Id, string Name) : DomainEvent;
public record {Entity}UpdatedEvent(Guid {Entity}Id) : DomainEvent;
public record {Entity}DeactivatedEvent(Guid {Entity}Id) : DomainEvent;
EF Configuration Template
public class {Entity}Configuration : IEntityTypeConfiguration<{Entity}>
{
public void Configure(EntityTypeBuilder<{Entity}> builder)
{
builder.ToTable("{entities}"); // plural, snake_case
builder.HasKey(x => x.Id);
builder.Property(x => x.Name)
.HasMaxLength(200)
.IsRequired();
builder.Property(x => x.IsActive)
.HasDefaultValue(true);
// Soft delete filter
builder.HasQueryFilter(x => !x.IsDeleted);
// Indexes
builder.HasIndex(x => x.Name);
builder.HasIndex(x => new { x.IsActive, x.CreatedAt });
// Ignore domain events
builder.Ignore(x => x.DomainEvents);
}
}
Kurallar
- ASLA public setter kullanma
- Factory method zorunlu (Create)
- Her state değişikliğinde domain event
- Private constructor EF Core için
- Guard clauses ile validation
- Collection'lar readonly expose edilmeli
スコア
総合スコア
40/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です