Agent skill
microservice-patterns
Event-driven microservice architecture patterns guide. Use when the user requests implementing microservices, event bus, SAGA pattern, orchestration, compensating transactions, or distributed system coordination.
Install this agent skill to your Project
npx add-skill https://github.com/revfactory/claude-code-harness/tree/main/experiments/results/case-008/harness/.claude/skills/microservice-patterns
SKILL.md
Microservice Patterns Skill
이벤트 드리븐 마이크로서비스 아키텍처 패턴 가이드
서비스 아키텍처
EventBus (pub/sub)
/ | \ \
OrderService InventoryService PaymentService NotificationService
| | | |
orders[] inventory{} payments[] notifications[]
\ | /
SAGA Orchestrator
(주문 생성 플로우 조율)
핵심 규칙
- 서비스 간 직접 참조 금지 (이벤트로만 통신)
- 각 서비스는 자체 상태만 관리
- correlation ID로 이벤트 흐름 추적
- 타임아웃: SAGA 단계별 5초 제한
SAGA 플로우
정상: order.created → inventory.reserved → payment.completed → order.confirmed
재고실패: order.created → inventory.failed → order.cancelled
결제실패: order.created → inventory.reserved → payment.failed → inventory.released → order.cancelled
보상 트랜잭션은 실행된 단계의 역순으로 수행.
이벤트 네이밍 규칙
order.created,order.confirmed,order.cancelledinventory.reserved,inventory.released,inventory.failedpayment.completed,payment.failed,payment.refundednotification.sent
파일 구조
src/
event-bus.js - 이벤트 버스 (pub/sub, 와일드카드, 비동기)
saga-orchestrator.js - SAGA 패턴 오케스트레이터
services/
order-service.js - 주문 CRUD + 상태 관리
inventory-service.js - 재고 관리 (reserve/release/deduct, 낙관적 잠금)
payment-service.js - 결제 처리 (charge/refund, 멱등성)
notification-service.js - 알림 이력
utils/
correlation-id.js - 상관관계 ID 생성
logger.js - 이벤트 추적 로거
tests/
event-bus.test.js
saga.test.js
integration.test.js - 5개 시나리오 통합 테스트
테스트 시나리오 (5개 필수)
- 정상 플로우: 주문→재고예약→결제→확정, 모든 서비스 상태 검증
- 재고 부족: 주문→재고실패→취소, 주문 상태 CANCELLED
- 결제 실패: 주문→재고예약→결제실패→재고해제→취소, 재고 원복 확인
- 동시 주문: 2개 주문이 동시에 같은 상품 주문, 하나만 성공
- 타임아웃: SAGA 단계가 시간 초과 시 보상 트랜잭션
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
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.
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.
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.
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.
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.
reactive-spreadsheet-design
리액티브 스프레드시트 엔진 설계 가이드. 셀 수식 파싱, 의존성 그래프(DAG), 증분 재계산, 내장 함수 구현 시 사용한다.
Didn't find tool you were looking for?