帮助开发者设计、实现并重构六边形架构系统,确保边界清晰且易于测试。
复制安装指令,让 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/
…
为 Quarkus 3.x 项目提供测试驱动开发方案,支持功能开发、修复与重构。
帮助用户检索 PubMed 生物医学文献、MeSH 主题词与 PMID 引文信息。
帮助你用 dmux 编排多智能体并行协作,加速开发与复杂任务执行。
帮助用户调查质量不符合、分析根因并制定CAPA与供应商改进措施。
帮助你设计并实现 F# 单元、属性与集成测试的最佳实践
基于 C++ Core Guidelines 提供现代、安全、惯用的 C++ 编码规范建议
帮助用户设计系统、服务与技术架构,并梳理接口、数据模型和服务边界。
帮助设计或评估命令行工具与开发者 SDK 的架构、兼容性和使用体验
帮助你设计或评估Web服务架构、API模式、扩展性与可靠性问题。
帮助设计与评估企业系统集成方案,覆盖遗留改造、网关、事件与失效模式。
用领域驱动设计方法梳理复杂业务域、服务边界与系统架构决策。
帮助你选择合适的架构原语,并判断某种设计模式是否真正适用。