帮助开发者设计、实现并重构六边形架构系统,确保边界清晰且易于测试。
复制安装指令,让 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/
…
帮助开发者落实 Django 安全最佳实践,构建更安全的认证、授权与部署方案。
扫描多项技能并提炼通用规则,自动追加、修订或新建规则文件。
提供面向生产后端的 MySQL 与 MariaDB 设计、查询与运维模式建议。
帮助你判断解析结构化文本时何时用正则、何时引入大模型兜底。
用于 Laravel 项目的环境检查、测试、安全扫描与发布验收
提供地道 Kotlin 模式与最佳实践,帮助构建健壮高效且易维护的应用。
帮助用户设计系统、服务与技术架构,并梳理接口、数据模型和服务边界。
帮助设计或评估命令行工具与开发者 SDK 的架构、兼容性和使用体验
帮助你设计或评估Web服务架构、API模式、扩展性与可靠性问题。
帮助设计与评估企业系统集成方案,覆盖遗留改造、网关、事件与失效模式。
用领域驱动设计方法梳理复杂业务域、服务边界与系统架构决策。
帮助你选择合适的架构原语,并判断某种设计模式是否真正适用。