[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M72Y3XW8SJFN9QPBVWSF6EH2":3,"skill-same:01M72Y3XW8SJFN9QPBVWSF6EH2":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M72Y3XW8SJFN9QPBVWSF6EH2","hexagonal-architecture",null,"设计、实现并重构端口与适配器系统，具有清晰的领域边界、依赖反转以及跨 TypeScript、Java、Kotlin 和 Go 服务的可测试用例编排。","SriramGandhiS\u002FSkills","SriramGandhiS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F211849986?v=4","01M72WQCW12BYX71C6WN584TTA","Sriram S","01M72WQCWTJ2RD0ET1X31AF1RC",1,"MIT","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Feverything-claude-code\u002Fdocs\u002Fzh-CN\u002Fskills\u002Fhexagonal-architecture\u002FSKILL.md",[],[],"2026-11-10 22:39:42",false,"---\nname: hexagonal-architecture\ndescription: 设计、实现并重构端口与适配器系统，具有清晰的领域边界、依赖反转以及跨 TypeScript、Java、Kotlin 和 Go 服务的可测试用例编排。\norigin: ECC\n---\n\n# 六边形架构\n\n六边形架构（端口与适配器）使业务逻辑独立于框架、传输层和持久化细节。核心应用依赖于抽象端口，而适配器在边缘实现这些端口。\n\n## 适用场景\n\n* 构建需要长期可维护性和可测试性的新功能。\n* 重构分层或框架密集型代码，其中领域逻辑与I\u002FO关注点混杂。\n* 为同一用例支持多种接口（HTTP、CLI、队列工作器、定时任务）。\n* 替换基础设施（数据库、外部API、消息总线）而无需重写业务规则。\n\n当需求涉及边界、领域驱动设计、重构紧耦合服务，或将应用逻辑与特定库解耦时，使用此技能。\n\n## 核心概念\n\n* **领域模型**：业务规则和实体\u002F值对象。无框架导入。\n* **用例（应用层）**：编排领域行为和工作流步骤。\n* **入站端口**：描述应用能力的契约（命令\u002F查询\u002F用例接口）。\n* **出站端口**：应用所需依赖的契约（仓库、网关、事件发布器、时钟、UUID等）。\n* **适配器**：端口的基础设施和交付实现（HTTP控制器、数据库仓库、队列消费者、SDK封装器）。\n* **组合根**：将具体适配器绑定到用例的单一连接位置。\n\n出站端口接口通常位于应用层（仅当抽象真正属于领域层时才位于领域层），而基础设施适配器实现它们。\n\n依赖方向始终向内：\n\n* 适配器 -> 应用\u002F领域\n* 应用 -> 端口接口（入站\u002F出站契约）\n* 领域 -> 仅领域抽象（无框架或基础设施依赖）\n* 领域 -> 无外部依赖\n\n## 工作原理\n\n### 步骤1：建模用例边界\n\n定义具有清晰输入和输出DTO的单个用例。将传输细节（Express `req`、GraphQL `context`、任务负载包装器）保持在此边界之外。\n\n### 步骤2：首先定义出站端口\n\n将每个副作用识别为端口：\n\n* 持久化（`UserRepositoryPort`）\n* 外部调用（`BillingGatewayPort`）\n* 横切关注点（`LoggerPort`、`ClockPort`）\n\n端口应建模能力，而非技术。\n\n### 步骤3：使用纯编排实现用例\n\n用例类\u002F函数通过构造函数\u002F参数接收端口。它验证应用层不变量，协调领域规则，并返回纯数据结构。\n\n### 步骤4：在边缘构建适配器\n\n* 入站适配器将协议输入转换为用例输入。\n* 出站适配器将应用契约映射到具体API\u002FORM\u002F查询构建器。\n* 映射保持在适配器中，而非用例内部。\n\n### 步骤5：在组合根中连接所有组件\n\n实例化适配器，然后将其注入用例。保持此连接集中化，以避免隐藏的服务定位器行为。\n\n### 步骤6：按边界测试\n\n* 使用伪造端口对用例进行单元测试。\n* 使用真实基础设施依赖对适配器进行集成测试。\n* 通过入站适配器对面向用户的流程进行端到端测试。\n\n## 架构图\n\n```mermaid\nflowchart LR\n  Client[\"Client (HTTP\u002FCLI\u002FWorker)\"] --> InboundAdapter[\"Inbound Adapter\"]\n  InboundAdapter -->|\"calls\"| UseCase[\"UseCase (Application Layer)\"]\n  UseCase -->|\"uses\"| OutboundPort[\"OutboundPort (Interface)\"]\n  OutboundAdapter[\"Outbound Adapter\"] -->|\"implements\"| OutboundPort\n  OutboundAdapter --> ExternalSystem[\"DB\u002FAPI\u002FQueue\"]\n  UseCase --> DomainModel[\"DomainModel\"]\n```\n\n## 建议的模块布局\n\n使用以功能为先的组织方式，并带有显式边界：\n\n```text\nsrc\u002F\n  features\u002F\n    orders\u002F\n      domain\u002F\n        Order.ts\n        OrderPolicy.ts\n      application\u002F\n        ports\u002F\n          inbound\u002F\n            CreateOrder.ts\n          outbound\u002F\n            OrderRepositoryPort.ts\n            PaymentGatewayPort.ts\n        use-cases\u002F\n          CreateOrderUseCase.ts\n      adapters\u002F\n        inbound\u002F\n          http\u002F\n            createOrderRoute.ts\n        outbound\u002F\n          postgres\u002F\n            PostgresOrderRepository.ts\n          stripe\u002F\n            StripePaymentGateway.ts\n      composition\u002F\n        ordersContainer.ts\n```\n\n## TypeScript 示例\n\n### 端口定义\n\n```typescript\nexport interface OrderRepositoryPort {\n  save(order: Order): Promise\u003Cvoid>;\n  findById(orderId: string): Promise\u003COrder | null>;\n}\n\nexport interface PaymentGatewayPort {\n  authorize(input: { orderId: string; amountCents: number }): Promise\u003C{ authorizationId: string }>;\n}\n```\n\n### 用例\n\n```typescript\ntype CreateOrderInput = {\n  orderId: string;\n  amountCents: number;\n};\n\ntype CreateOrderOutput = {\n  orderId: string;\n  authorizationId: string;\n};\n\nexport class CreateOrderUseCase {\n  constructor(\n    private readonly orderRepository: OrderRepositoryPort,\n    private readonly paymentGateway: PaymentGatewayPort\n  ) {}\n\n  async execute(input: CreateOrderInput): Promise\u003CCreateOrderOutput> {\n    const order = Order.create({ id: input.orderId, amountCents: input.amountCents });\n\n    const auth = await this.paymentGateway.authorize({\n      orderId: order.id,\n      amountCents: order.amountCents,\n    });\n\n    \u002F\u002F markAuthorized returns a new Order instance; it does not mutate in place.\n    const authorizedOrder = order.markAuthorized(auth.authorizationId);\n    await this.orderRepository.save(authorizedOrder);\n\n    return {\n      orderId: order.id,\n      authorizationId: auth.authorizationId,\n    };\n  }\n}\n```\n\n### 出站适配器\n\n```typescript\nexport class PostgresOrderRepository implements OrderRepositoryPort {\n  constructor(private readonly db: SqlClient) {}\n\n  async save(order: Order): Promise\u003Cvoid> {\n    await this.db.query(\n      \"insert into orders (id, amount_cents, status, authorization_id) values ($1, $2, $3, $4)\",\n      [order.id, order.amountCents, order.status, order.authorizationId]\n    );\n  }\n\n  async findById(orderId: string): Promise\u003COrder | null> {\n    const row = await this.db.oneOrNone(\"select * from orders where id = $1\", [orderId]);\n    return row ? Order.rehydrate(row) : null;\n  }\n}\n```\n\n### 组合根\n\n```typescript\nexport const buildCreateOrderUseCase = (deps: { db: SqlClient; stripe: StripeClient }) => {\n  const orderRepository = new PostgresOrderRepository(deps.db);\n  const paymentGateway = new StripePaymentGateway(deps.stripe);\n\n  return new CreateOrderUseCase(orderRepository, paymentGateway);\n};\n```\n\n## 多语言映射\n\n在不同生态系统中使用相同的边界规则；仅语法和连接方式发生变化。\n\n* **TypeScript\u002FJavaScript**\n  * 端口：`application\u002Fports\u002F*` 作为接口\u002F类型。\n  * 用例：带有构造函数\u002F参数注入的类\u002F函数。\n  * 适配器：`adapters\u002Finbound\u002F*`、`adapters\u002Foutbound\u002F*`。\n  * 组合：显式工厂\u002F容器模块（无隐藏全局变量）。\n* **Java**\n  * 包：`domain`、`application.port.in`、`application.port.out`、`application.usecase`、`adapter.in`、`adapter.out`。\n  * 端口：`application.port.*` 中的接口。\n  * 用例：普通类（Spring `@Service` 是可选的，非必需）。\n  * 组合：Spring配置或手动连接类；将连接逻辑保持在领域\u002F用例类之外。\n* **Kotlin**\n  * 模块\u002F包镜像Java的拆分（`domain`、`application.port`、`application.usecase`、`adapter`）。\n  * 端口：Kotlin接口。\n  * 用例：带有构造函数注入的类（Koin\u002FDagger\u002FSpring\u002F手动）。\n  * 组合：模块定义或专用组合函数；避免服务定位器模式。\n* **Go**\n  * 包：`internal\u002F\u003Cfeature>\u002Fdomain`、`application`、`ports`、`adapters\u002Finbound`、`adapters\u002Foutbound`。\n  * 端口：由消费应用包拥有的小型接口。\n  * 用例：带有接口字段和显式 `New...` 构造函数的结构体。\n  * 组合：在 `cmd\u002F\u003Capp>\u002Fmain.go` 中连接（或专用连接包），保持构造函数显式。\n\n## 应避免的反模式\n\n* 领域实体导入ORM模型、Web框架类型或SDK客户端。\n* 用例直接从 `req`、`res` 或队列元数据读取。\n* 从用例直接返回数据库行，未经领域\u002F应用映射。\n* 让适配器直接相互调用，而非通过用例端口流转。\n* 将依赖连接分散到多个文件中，使用隐藏的全局单例。\n\n## 迁移手册\n\n1. 选择一个垂直切片（单个端点\u002F任务），该切片频繁变更且带来痛苦。\n2. 提取具有显式输入\u002F输出类型的用例边界。\n3. 围绕现有基础设施调用引入出站端口。\n4. 将编排逻辑从控制器\u002F服务移动到用例中。\n5. 保留旧适配器，但使其委托给新用例。\n6. 围绕新边界添加测试（单元测试 + 适配器集成测试）。\n7. 逐个切片重复；避免完全重写。\n\n### 重构现有系统\n\n* **绞杀者模式**：保留当前端点，一次将一个用例路由到新的端口\u002F适配器。\n* **无大爆炸式重写**：按功能切片迁移，并通过特征化测试保持行为。\n* **先建外观**：在替换内部实现之前，将遗留服务包装在出站端口后面。\n* **组合冻结**：尽早集中连接，使新依赖不会泄漏到领域\u002F用例层。\n* **切片选择规则**：优先处理高变更频率、低影响范围的流程。\n* **回滚路径**：为每个迁移的切片保留可逆开关或路由切换，直到生产行为得到验证。\n\n## 测试指南（相同的六边形边界）\n\n* **领域测试**：将实体\u002F值对象作为纯业务规则进行测试（无模拟，无框架设置）。\n* **用例单元测试**：使用出站端口的伪造\u002F桩件测试编排；断言业务结果和端口交互。\n* **出站适配器契约测试**：在端口级别定义共享契约套件，并针对每个适配器实现运行。\n* **入站适配器测试**：验证协议映射（HTTP\u002FCLI\u002F队列负载到用例输入，以及输出\u002F错误映射回协议）。\n* **适配器集成测试**：针对真实基础设施（数据库\u002FAPI\u002F队列）运行，测试序列化、模式\u002F查询行为、重试和超时。\n* **端到端测试**：覆盖关键用户旅程，通过入站适配器 -> 用例 -> 出站适配器。\n* **重构安全性**：在提取之前添加特征化测试；保持它们直到新边界行为稳定且等价。\n\n## 最佳实践清单\n\n* 领域和应用层仅导入内部类型和端口。\n* 每个外部依赖都由一个出站端口表示。\n* 验证发生在边界处（入站适配器 + 用例不变量）。\n* 使用不可变转换（返回新值\u002F实体，而非修改共享状态）。\n* 错误在边界间进行转换（基础设施错误 -> 应用\u002F领域错误）。\n* 组合根是显式的且易于审计。\n* 用例可通过简单的内存伪造端口进行测试。\n* 重构从具有行为保持测试的一个垂直切片开始。\n* 语言\u002F框架特定内容保持在适配器中，绝不进入领域规则。\n","# 六边形架构\n\n六边形架构（端口与适配器）使业务逻辑独立于框架、传输层和持久化细节。核心应用依赖于抽象端口，而适配器在边缘实现这些端口。\n\n## 适用场景\n\n* 构建需要长期可维护性和可测试性的新功能。\n* 重构分层或框架密集型代码，其中领域逻辑与I\u002FO关注点混杂。\n* 为同一用例支持多种接口（HTTP、CLI、队列工作器、定时任务）。\n* 替换基础设施（数据库、外部API、消息总线）而无需重写业务规则。\n\n当需求涉及边界、领域驱动设计、重构紧耦合服务，或将应用逻辑与特定库解耦时，使用此技能。\n\n## 核心概念\n\n* **领域模型**：业务规则和实体\u002F值对象。无框架导入。\n* **用例（应用层）**：编排领域行为和工作流步骤。\n* **入站端口**：描述应用能力的契约（命令\u002F查询\u002F用例接口）。\n* **出站端口**：应用所需依赖的契约（仓库、网关、事件发布器、时钟、UUID等）。\n* **适配器**：端口的基础设施和交付实现（HTTP控制器、数据库仓库、队列消费者、SDK封装器）。\n* **组合根**：将具体适配器绑定到用例的单一连接位置。\n\n出站端口接口通常位于应用层（仅当抽象真正属于领域层时才位于领域层），而基础设施适配器实现它们。\n\n依赖方向始终向内：\n\n* 适配器 -> 应用\u002F领域\n* 应用 -> 端口接口（入站\u002F出站契约）\n* 领域 -> 仅领域抽象（无框架或基础设施依赖）\n* 领域 -> 无外部依赖\n\n## 工作原理\n\n### 步骤1：建模用例边界\n\n定义具有清晰输入和输出DTO的单个用例。将传输细节（Express `req`、GraphQL `context`、任务负载包装器）保持在此边界之外。\n\n### 步骤2：首先定义出站端口\n\n将每个副作用识别为端口：\n\n* 持久化（`UserRepositoryPort`）\n* 外部调用（`BillingGatewayPort`）\n* 横切关注点（`LoggerPort`、`ClockPort`）\n\n端口应建模能力，而非技术。\n\n### 步骤3：使用纯编排实现用例\n\n用例类\u002F函数通过构造函数\u002F参数接收端口。它验证应用层不变量，协调领域规则，并返回纯数据结构。\n\n### 步骤4：在边缘构建适配器\n\n* 入站适配器将协议输入转换为用例输入。\n* 出站适配器将应用契约映射到具体API\u002FORM\u002F查询构建器。\n* 映射保持在适配器中，而非用例内部。\n\n### 步骤5：在组合根中连接所有组件\n\n实例化适配器，然后将其注入用例。保持此连接集中化，以避免隐藏的服务定位器行为。\n\n### 步骤6：按边界测试\n\n* 使用伪造端口对用例进行单元测试。\n* 使用真实基础设施依赖对适配器进行集成测试。\n* 通过入站适配器对面向用户的流程进行端到端测试。\n\n## 架构图\n\n```mermaid\nflowchart LR\n  Client[\"Client (HTTP\u002FCLI\u002FWorker)\"] --> InboundAdapter[\"Inbound Adapter\"]\n  InboundAdapter -->|\"calls\"| UseCase[\"UseCase (Application Layer)\"]\n  UseCase -->|\"uses\"| OutboundPort[\"OutboundPort (Interface)\"]\n  OutboundAdapter[\"Outbound Adapter\"] -->|\"implements\"| OutboundPort\n  OutboundAdapter --> ExternalSystem[\"DB\u002FAPI\u002FQueue\"]\n  UseCase --> DomainModel[\"DomainModel\"]\n```\n\n## 建议的模块布局\n\n使用以功能为先的组织方式，并带有显式边界：\n\n```text\nsrc\u002F\n  features\u002F\n    orders\u002F\n      domain\u002F\n        Order.ts\n        OrderPolicy.ts\n      application\u002F\n        ports\u002F\n          inbound\u002F\n            CreateOrder.ts\n          outbound\u002F\n            OrderRepositoryPort.ts\n            PaymentGatewayPort.ts\n        use-cases\u002F\n          CreateOrderUseCase.ts\n      adapters\u002F\n        inbound\u002F\n          http\u002F\n            createOrderRoute.ts\n        outbound\u002F\n          postgres\u002F\n            PostgresOrderRepository.ts\n          stripe\u002F\n            StripePaymentGateway.ts\n      composition\u002F\n        ordersContainer.ts\n```\n\n## TypeScript 示例\n\n### 端口定义\n\n```typescript\nexport interface OrderRepositoryPort {\n  save(order: Order): Promise\u003Cvoid>;\n  findById(orderId: string): Promise\u003COrder | null>;\n}\n\nexport interface PaymentGatewayPort {\n  authorize(input: { orderId: string; amountCents: number }): Promise\u003C{ authorizationId: string }>;\n}\n```\n\n### 用例\n\n```typescript\ntype CreateOrderInput = {\n  orderId: string;\n  amountCents: number;\n};\n\ntype CreateOrderOutput = {\n  orderId: string;\n  authorizationId: string;\n};\n\nexport class CreateOrderUseCase {\n  constructor(\n    private readonly orderRepository: OrderRepositoryPort,\n    private readonly paymentGateway: PaymentGatewayPort\n  ) {}\n\n  async execute(input: CreateOrderInput): Promise\u003CCreateOrderOutput> {\n    const order = Order.create({ id: input.orderId, amountCents: input.amountCents });\n\n    const auth = await this.paymentGateway.authorize({\n      orderId: order.id,\n      amountCents: order.amountCents,\n    });\n\n    \u002F\u002F markAuthorized returns a new Order instance; it does not mutate in place.\n    const authorizedOrder = order.markAuthorized(auth.authorizationId);\n    await this.orderRepository.save(authorizedOrder);\n\n    return {\n      orderId: order.id,\n      authorizationId: auth.authorizationId,\n    };\n  }\n}\n```\n\n### 出站适配器\n\n```typescript\nexport class PostgresOrderRepository implements OrderRepositoryPort {\n  constructor(private readonly db: SqlClient) {}\n\n  async save(order: Order): Promise\u003Cvoid> {\n    await this.db.query(\n      \"insert into orders (id, amount_cents, status, authorization_id) values ($1, $2, $3, $4)\",\n      [order.id, order.amountCents, order.status, order.authorizationId]\n    );\n  }\n\n  async findById(orderId: string): Promise\u003COrder | null> {\n    const row = await this.db.oneOrNone(\"select * from orders where id = $1\", [orderId]);\n    return row ? Order.rehydrate(row) : null;\n  }\n}\n```\n\n### 组合根\n\n```typescript\nexport const buildCreateOrderUseCase = (deps: { db: SqlClient; stripe: StripeClient }) => {\n  const orderRepository = new PostgresOrderRepository(deps.db);\n  const paymentGateway = new StripePaymentGateway(deps.stripe);\n\n  return new CreateOrderUseCase(orderRepository, paymentGateway);\n};\n```\n\n## 多语言映射\n\n在不同生态系统中使用相同的边界规则；仅语法和连接方式发生变化。\n\n* **TypeScript\u002FJavaScript**\n  * 端口：`application\u002Fports\u002F*` 作为接口\u002F类型。\n  * 用例：带有构造函数\u002F参数注入的类\u002F函数。\n  * 适配器：`adapters\u002Finbound\u002F*`、`adapters\u002Foutbound\u002F*`。\n  * 组合：显式工厂\u002F容器模块（无隐藏全局变量）。\n* **Java**\n  * 包：`domain`、`application.port.in`、`application.port.out`、`application.usecase`、`adapter.in`、`adapter.out`。\n  * 端口：`application.port.*` 中的接口。\n  * 用例：普通类（Spring `@Service` 是可选的，非必需）。\n  * 组合：Spring配置或手动连接类；将连接逻辑保持在领域\u002F用例类之外。\n* **Kotlin**\n  * 模块\u002F包镜像Java的拆分（`domain`、`application.port`、`application.usecase`、`adapter`）。\n  * 端口：Kotlin接口。\n  * 用例：带有构造函数注入的类（Koin\u002FDagger\u002FSpring\u002F手动）。\n  * 组合：模块定义或专用组合函数；避免服务定位器模式。\n* **Go**\n  * 包：`internal\u002F\u003Cfeature>\u002Fdomain`、`application`、`ports`、`adapters\u002Finbound`、`adapters\u002Foutbound`。\n  * 端口：由消费应用包拥有的小型接口。\n  * 用例：带有接口字段和显式 `New...` 构造函数的结构体。\n  * 组合：在 `cmd\u002F\u003Capp>\u002Fmain.go` 中连接（或专用连接包），保持构造函数显式。\n\n## 应避免的反模式\n\n* 领域实体导入ORM模型、Web框架类型或SDK客户端。\n* 用例直接从 `req`、`res` 或队列元数据读取。\n* 从用例直接返回数据库行，未经领域\u002F应用映射。\n* 让适配器直接相互调用，而非通过用例端口流转。\n* 将依赖连接分散到多个文件中，使用隐藏的全局单例。\n\n## 迁移手册\n\n1. 选择一个垂直切片（单个端点\u002F任务），该切片频繁变更且带来痛苦。\n2. 提取具有显式输入\u002F输出类型的用例边界。\n3. 围绕现有基础设施调用引入出站端口。\n4. 将编排逻辑从控制器\u002F服务移动到用例中。\n5. 保留旧适配器，但使其委托给新用例。\n6. 围绕新边界添加测试（单元测试 + 适配器集成测试）。\n7. 逐个切片重复；避免完全重写。\n\n### 重构现有系统\n\n* **绞杀者模式**：保留当前端点，一次将一个用例路由到新的端口\u002F适配器。\n* **无大爆炸式重写**：按功能切片迁移，并通过特征化测试保持行为。\n* **先建外观**：在替换内部实现之前，将遗留服务包装在出站端口后面。\n* **组合冻结**：尽早集中连接，使新依赖不会泄漏到领域\u002F用例层。\n* **切片选择规则**：优先处理高变更频率、低影响范围的流程。\n* **回滚路径**：为每个迁移的切片保留可逆开关或路由切换，直到生产行为得到验证。\n\n## 测试指南（相同的六边形边界）\n\n* **领域测试**：将实体\u002F值对象作为纯业务规则进行测试（无模拟，无框架设置）。\n* **用例单元测试**：使用出站端口的伪造\u002F桩件测试编排；断言业务结果和端口交互。\n* **出站适配器契约测试**：在端口级别定义共享契约套件，并针对每个适配器实现运行。\n* **入站适配器测试**：验证协议映射（HTTP\u002FCLI\u002F队列负载到用例输入，以及输出\u002F错误映射回协议）。\n* **适配器集成测试**：针对真实基础设施（数据库\u002FAPI\u002F队列）运行，测试序列化、模式\u002F查询行为、重试和超时。\n* **端到端测试**：覆盖关键用户旅程，通过入站适配器 -> 用例 -> 出站适配器。\n* **重构安全性**：在提取之前添加特征化测试；保持它们直到新边界行为稳定且等价。\n\n## 最佳实践清单\n\n* 领域和应用层仅导入内部类型和端口。\n* 每个外部依赖都由一个出站端口表示。\n* 验证发生在边界处（入站适配器 + 用例不变量）。\n* 使用不可变转换（返回新值\u002F实体，而非修改共享状态）。\n* 错误在边界间进行转换（基础设施错误 -> 应用\u002F领域错误）。\n* 组合根是显式的且易于审计。\n* 用例可通过简单的内存伪造端口进行测试。\n* 重构从具有行为保持测试的一个垂直切片开始。\n* 语言\u002F框架特定内容保持在适配器中，绝不进入领域规则。\n",{"name":5,"origin":24,"description":7},"ECC","master","d6ca01da0f24a3b0e26e4a8b7b66cbd25d429f5d","everything-claude-code\u002Fdocs\u002Fzh-CN\u002Fskills\u002Fhexagonal-architecture",0,"https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills","https:\u002F\u002Fgithub.com\u002FSriramGandhiS","https:\u002F\u002Fsriram.website\u002F","Curious guy who keeps tinkering until something works","2026-05-20 16:21:34",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add SriramGandhiS\u002FSkills --skill hexagonal-architecture",{"tool":40,"command":41},"bunx","bunx skills add SriramGandhiS\u002FSkills --skill hexagonal-architecture",{"tool":43,"command":44},"pnpm","pnpm dlx skills add SriramGandhiS\u002FSkills --skill hexagonal-architecture","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Feverything-claude-code\u002Fdocs\u002Fzh-CN\u002Fskills\u002Fhexagonal-architecture\u002FSKILL.md",true,[],[49,57,62,68,75,82],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":56},"01M732609EPJWV13PVTX3GT4TM","webgpu-threejs-tsl","Comprehensive guide for developing WebGPU-enabled Three.js applications using TSL (Three.js Shading Language). Covers WebGPU renderer setup, TSL syntax and node materials, compute shaders, post-processing effects, and WGSL integration. Use this skill when working with Three.js WebGPU, TSL shaders, node materials, or GPU compute in Three.js.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fwebgpu-threejs-tsl\u002Fskills\u002Fwebgpu-threejs-tsl\u002FSKILL.md",[],[],"2026-11-11 15:11:14",{"skillNo":58,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":56},"01M7325XM47AGWB6K6C4VXKE6B","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fwebgpu-threejs-tsl\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":56},"01M7325WP6DES69JKC840VMFEP","verification-loop","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Fverification-loop\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":56},"01M7325TFQF1DZTQ6J3WGQQ1VR","tdd-workflow","Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development with 80%+ coverage including unit, integration, and E2E tests.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Ftdd-workflow\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":56},"01M7325RGV9AY9PK92D2V8KKPW","strategic-compact","Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Fstrategic-compact\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":56},"01M7325MZC28SE86E7NMCNEFS4","security-review","Use this skill when adding authentication, handling user input, working with secrets, creating API endpoints, or implementing payment\u002Fsensitive features. Provides comprehensive security checklist and patterns.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Fsecurity-review\u002FSKILL.md",[],[]]