architecture-patterns
實作後端架構模式
Également disponible depuis: Barnhardt-Enterprises-Inc,AdamManuel-dev
建構可維護的後端系統需要經過驗證的架構模式。此技能可幫助您實作 Clean Architecture、Hexagonal Architecture 和 Domain-Driven Design,以建立可測試、可擴展的應用程式,並具有適當的關注點分離。
Télécharger le ZIP du skill
Importer dans Claude
Allez dans Paramètres → Capacités → Skills → Importer un skill
Activez et commencez à utiliser
Tester
Utilisation de "architecture-patterns". Create a Clean Architecture structure for a user management system
Résultat attendu:
The skill generates a complete directory structure with domain/entities containing User entity, domain/interfaces with IUserRepository port, use_cases containing CreateUserUseCase and UpdateUserUseCase, adapters/repositories with PostgresUserRepository implementation, and adapters/controllers with UserController for HTTP handling. Each component demonstrates proper dependency flow and separation of concerns.
Utilisation de "architecture-patterns". Implement a payment gateway adapter using hexagonal architecture
Résultat attendu:
The skill creates a PaymentGatewayPort interface defining the charge method contract, then implements both StripePaymentAdapter for production and MockPaymentAdapter for testing. Both adapters implement the same port interface, allowing easy swapping without changing business logic. The example includes error handling and proper async/await patterns.
Utilisation de "architecture-patterns". Design an Order aggregate with DDD patterns
Résultat attendu:
The skill designs an Order entity as aggregate root with add_item, calculate_total, and submit methods encapsulating business rules. It includes OrderItem entity, Money value object for currency handling, OrderStatus enum for state management, and domain events like OrderSubmittedEvent. The aggregate enforces invariants and maintains consistency boundaries.
Audit de sécurité
SûrAll 43 static analysis findings are false positives from educational code examples in documentation. The skill teaches software architecture patterns through Python examples showing Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. No executable code, network access, or security vulnerabilities present.
Score de qualité
Ce que vous pouvez construire
設計新的後端服務架構
使用 Clean Architecture 原則規劃和實作新的微服務,具有適當的分層結構,依賴注入和可測試的業務邏輯。
重構單體應用程式
將緊密耦合的單體應用程式轉換為結構良好的 Hexagonal Architecture,透過埠口和轉接器實現更輕鬆的測試和維護。
實作 Domain-Driven Design 模式
使用 DDD 戰術模式建立複雜業務領域的模型,包括聚合、實體、值物件和領域事件,以實現更好的領域對齊。
Essayez ces prompts
為電子商務訂單管理系統建立 Clean Architecture 資料夾結構,包含領域實體、用例和轉接器。
根據 Hexagonal Architecture 原則,使用非同步資料庫存取實作使用者儲存庫埠口介面和 PostgreSQL 轉接器。
使用領域實體、值物件和業務規則設計 Order 聚合,包括新增項目、計算總額和狀態轉換。
將業務邏輯位於控制器中的 FastAPI 端點重構為適當的用例,使用依賴注入和關注點分離。
Bonnes pratiques
- 始終讓依賴從外層指向內層,絕不要讓領域層依賴基礎設施
- 使用介面和埠口在領域層中定義合約,在外層實作轉接器以實現可測試性
- 將業務邏輯保留在領域實體和用例中,控制器應該只處理 HTTP 關注點並委託給用例
Éviter
- 將業務邏輯放在控制器或 API 處理程式而不是用例和領域實體中
- 建立只有資料屬性而沒有行為的貧血領域模型,將所有邏輯放在服務中
- 將領域層緊密耦合到特定框架、資料庫或外部 API 而沒有抽象介面