帮助开发者设计、实现并重构六边形架构系统,确保边界清晰且易于测试。
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "hexagonal-architecture" 技能: 1. 下载 https://raw.githubusercontent.com/affaan-m/ECC/main/skills/hexagonal-architecture/SKILL.md 2. 保存为 ~/.claude/skills/hexagonal-architecture/SKILL.md 3. 装好后重载技能,告诉我可以用了
请为一个电商订单服务设计六边形架构,使用 TypeScript,列出领域模型、用例、端口、适配器和目录结构,并说明依赖方向。
得到完整的六边形架构设计方案,包括核心领域边界、接口定义和项目结构建议。
下面是一段耦合数据库与业务逻辑的 Java 控制器代码。请将其重构为六边形架构,拆分为用例、仓储端口和适配器,并给出重构后的代码示例与测试策略。
得到按端口与适配器分层的重构代码,以及可执行的单元测试与集成测试建议。
请用 Kotlin 为支付流程实现一个可测试的用例编排示例,要求体现依赖反转、输入输出模型、端口接口、失败处理,并附上单元测试示例。
得到清晰的用例编排实现示例,包含端口接口、错误处理方式和配套测试代码。
Hexagonal architecture (Ports and Adapters) keeps business logic independent from frameworks, transport, and persistence details. The core app depends on abstract ports, and adapters implement those ports at the edges.
Use this skill when the request involves boundaries, domain-centric design, refactoring tightly coupled services, or decoupling application logic from specific libraries.
Outbound port interfaces usually live in the application layer (or in domain only when the abstraction is truly domain-level), while infrastructure adapters implement them.
Dependency direction is always inward:
Define a single use case with a clear input and output DTO. Keep transport details (Express req, GraphQL context, job payload wrappers) outside this boundary.
Identify every side effect as a port:
UserRepositoryPort)BillingGatewayPort)LoggerPort, ClockPort)Ports should model capabilities, not technologies.
Use case class/function receives ports via constructor/arguments. It validates application-level invariants, coordinates domain rules, and returns plain data structures.
Instantiate adapters, then inject them into use cases. Keep this wiring centralized to avoid hidden service-locator behavior.
flowchart LR
Client["Client (HTTP/CLI/Worker)"] --> InboundAdapter["Inbound Adapter"]
InboundAdapter -->|"calls"| UseCase["UseCase (Application Layer)"]
UseCase -->|"uses"| OutboundPort["OutboundPort (Interface)"]
OutboundAdapter["Outbound Adapter"] -->|"implements"| OutboundPort
OutboundAdapter --> ExternalSystem["DB/API/Queue"]
UseCase --> DomainModel["DomainModel"]
Use feature-first organization with explicit boundaries:
src/
features/
orders/
domain/
Order.ts
OrderPolicy.ts
application/
ports/
inbound/
CreateOrder.ts
outbound/
OrderRepositoryPort.ts
PaymentGatewayPort.ts
use-cases/
…
端到端编排新功能开发流程,覆盖调研、规划、测试驱动实现、评审与提交把关。
基于RFC编排多智能体开发流程,统一质量门禁与合并队列管理。
通过逐步细化检索上下文,提升子代理任务理解与结果质量。
帮助你设计 Quarkus 3 后端架构模式,覆盖消息、REST、数据访问与异步处理。
提供地道 Go 语言模式与最佳实践,帮助构建健壮高效且易维护的应用
帮助团队建立以 AI 代码生成为核心的工程流程、架构与评审标准。
帮助用户设计系统、服务与技术架构,并梳理接口、数据模型和服务边界。
帮助设计或评估命令行工具与开发者 SDK 的架构、兼容性和使用体验
帮助你设计或评估Web服务架构、API模式、扩展性与可靠性问题。
帮助设计与评估企业系统集成方案,覆盖遗留改造、网关、事件与失效模式。
用领域驱动设计方法梳理复杂业务域、服务边界与系统架构决策。
帮助你选择合适的架构原语,并判断某种设计模式是否真正适用。