Agent skill

event-sourcing-design

이벤트 소싱 + CQRS 패턴 설계 가이드. EventStore, Aggregate, Projection, Saga, Snapshot 구현 시 사용한다.

Stars 88
Forks 14

Install this agent skill to your Project

npx add-skill https://github.com/revfactory/claude-code-harness/tree/main/experiments/results/case-014/harness/.claude/skills/event-sourcing-design

SKILL.md

Event Sourcing CQRS Design Skill

이벤트 소싱 핵심 원칙

  1. 이벤트 = 사실(fact): 과거에 발생한 것, 불변
  2. 상태 = fold(events): 이벤트를 순서대로 적용한 결과
  3. 추가 전용(append-only): 이벤트 스트림에 추가만 가능
  4. 시간 여행: 과거 시점의 상태를 재구성 가능

Aggregate 패턴

javascript
class BankAccount extends AggregateRoot {
  constructor(id) {
    super(id);
    this.balance = 0;
    this.status = 'active';
  }

  // 커맨드 메서드: 비즈니스 규칙 검증 → 이벤트 생성
  deposit(amount) {
    if (amount <= 0) throw new Error('Amount must be positive');
    if (this.status === 'frozen') throw new Error('Account is frozen');
    this.apply(new MoneyDeposited(this.id, amount, this.balance + amount));
  }

  // 이벤트 핸들러: 상태 변경만 (부수효과 없음)
  onMoneyDeposited(event) {
    this.balance = event.balance;
  }
}

CQRS 분리

Write Side (Command)          Read Side (Query)
─────────────────            ─────────────────
CommandHandler               Projection
  → Aggregate.method()         → 이벤트 구독
  → EventStore.append()        → ReadModel 갱신
                               → Query API 제공

Saga 상태 머신

TransferSaga:
  INITIATED → DEBITED → COMPLETED
                ↓ (실패)
            COMPENSATING → FAILED

구현 순서

  1. EventStore (핵심 인프라)
  2. AggregateRoot (기반 클래스)
  3. EventBus (이벤트 전파)
  4. CommandBus (커맨드 디스패치)
  5. Repository (Aggregate 로딩/저장)
  6. BankAccount Aggregate (도메인)
  7. Projection (읽기 모델)
  8. Saga (이체 프로세스)
  9. SnapshotStore (최적화)
  10. 통합 테스트

Expand your agent's capabilities with these related and highly-rated skills.

revfactory/claude-code-harness

interpreter-design

Programming language interpreter design and implementation guide. Use when the user requests building an interpreter, parser, lexer, or language implementation — including Pratt parsing, AST evaluation, scope chains, and closures.

88 14
Explore
revfactory/claude-code-harness

express-api-design

Express.js REST API design and implementation guide. Use when implementing REST API endpoints, creating Express routes, or setting up API project structure with MVC pattern.

88 14
Explore
revfactory/claude-code-harness

query-engine-design

SQL query engine design and implementation guide. Use when the user requests building a SQL engine, query parser, query planner, or query executor — including in-memory storage, SQL parsing, and query optimization.

88 14
Explore
revfactory/claude-code-harness

api-documentation

Write accurate and complete library API documentation. Use when creating API docs, README files, or function reference documentation. Ensures all signatures, parameters, return types, and examples are precise.

88 14
Explore
revfactory/claude-code-harness

async-debugging

Analyze and fix race conditions and concurrency bugs in async code. Use when debugging async bugs, fixing race conditions, resolving concurrency issues, or when shared state is accessed by multiple async operations.

88 14
Explore
revfactory/claude-code-harness

reactive-spreadsheet-design

리액티브 스프레드시트 엔진 설계 가이드. 셀 수식 파싱, 의존성 그래프(DAG), 증분 재계산, 내장 함수 구현 시 사용한다.

88 14
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results