帮助开发者设计、实现并重构六边形架构系统,确保边界清晰且易于测试。
复制安装指令,让 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/
…
帮助开发者为代码代理配置性能优化、安全防护与研究优先工作流。
提供数据库迁移、回滚与零停机发布的最佳实践指导,适用于多种 ORM 与 SQL 数据库。
通过双评审智能体对结果进行对抗式校验,提升输出发布前的可靠性
帮助你掌握地道 Rust 模式、所有权与并发实践,编写安全高性能应用。
基于 C++ Core Guidelines 编写、审查并重构更安全现代的 C++ 代码。
为 Claude Code 会话提供系统化校验流程,帮助检查结果正确性与质量。
帮助开发者理解六边形架构,分离业务边界并管理外部依赖关系。
帮助用户设计系统、服务与技术架构,并梳理接口、数据模型和服务边界。
帮助设计或评估命令行工具与开发者 SDK 的架构、兼容性和使用体验
帮助你设计或评估Web服务架构、API模式、扩展性与可靠性问题。
帮助设计与评估企业系统集成方案,覆盖遗留改造、网关、事件与失效模式。
用领域驱动设计方法梳理复杂业务域、服务边界与系统架构决策。