跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
开发与测试

adapter

Creates or modifies infrastructure adapters in src/infrastructure/adapters/ and their corresponding port interfaces in src/domain/ports/. Use when adding a new I/O boundary (file system, HTTP, git, npm, OS), changing how an existing adapter translates errors, or wiring a new adapter into createDeps. Do NOT use for business orchestration — use `use-case` instead. Do NOT use for creating domain types — use `domain-model` instead.

ai-driven-dev · 已有 AI 审核记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add ai-driven-dev/framework --skill adapter

技能说明


name: adapter description: > Creates or modifies infrastructure adapters in src/infrastructure/adapters/ and their corresponding port interfaces in src/domain/ports/. Use when adding a new I/O boundary (file system, HTTP, git, npm, OS), changing how an existing adapter translates errors, or wiring a new adapter into createDeps. Do NOT use for business orchestration — use use-case instead. Do NOT use for creating domain types — use domain-model instead.

Adapter

Builds the I/O translation layer: port interfaces that describe what the application needs, and adapter classes that fulfill those contracts by talking to the real world (filesystem, git, HTTP, npm, OS). Adapters own all technical constants; domain errors never cross the port boundary raw.

Available actions

#ActionRoleInput
01define-portWrite the port interface in src/domain/ports/port name + method list
02implement-adapterWrite the *Adapter class implementing the portport interface from 01
03wire-depsRegister the adapter in createDeps / createMenuDepsadapter class from 02
04testWrite infrastructure integration testscompleted adapter from 02

Default flow

01 → 02 → 03 → 04

Skip 01 when the port already exists; start at 02.

Transversal rules

  • Adapter class name ends in Adapter, implements exactly one port interface.
  • Port: interface only, no classes, ≤5 methods, all I/O methods async, no null returns.
  • No business logic in adapters — I/O and format translation only.
  • Throw typed domain exceptions; never let raw third-party errors cross the port boundary.
  • Never instantiate adapters directly in commands or cli.ts — all wiring via createDeps.
  • Named export only.
  • File name is <concept>-adapter.ts.

References

  • references/adapter-rules.md — adapter class conventions and technical-constants ownership
  • references/port-design.md — port interface contract: ≤5 methods, async, no null, intent naming

Invariant rules

  • references/adapter-rules.md — authoritative adapter rules
  • references/port-design.md — authoritative port design rules