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

use-case

Creates or modifies application use-cases in src/application/use-cases/. Use when implementing business orchestration for a new feature, extracting a reusable shared use-case, adding a capability sub-use-case, or wiring a PostInstallPipeline delegation. Do NOT use for creating a new CLI command surface — use `command` instead. Do NOT use for I/O translation — use `adapter` instead. Do NOT use for domain type definitions — use `domain-model` instead.

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

安装与使用

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

npx skills add ai-driven-dev/framework --skill use-case

技能说明


name: use-case description: > Creates or modifies application use-cases in src/application/use-cases/. Use when implementing business orchestration for a new feature, extracting a reusable shared use-case, adding a capability sub-use-case, or wiring a PostInstallPipeline delegation. Do NOT use for creating a new CLI command surface — use command instead. Do NOT use for I/O translation — use adapter instead. Do NOT use for domain type definitions — use domain-model instead.

Use Case

Builds the business orchestration layer: classes that receive typed options, coordinate ports and domain models, and return typed results. Each use-case has a single execute() method, never catches its own errors, and delegates all file-and-manifest writes to PostInstallPipelineUseCase.

Available actions

#ActionRoleInput
01define-typesDeclare *Options and *Result interfacesuse-case name + field list
02write-executeWrite the execute() method body (≤20 LOC)types from 01
03extract-methodsExtract intent-named private helper methodsexecute() body from 02
04wire-errors-and-pipelineAdd typed throws + delegate to PostInstallPipelinemethods from 03
05testWrite integration-tier unit testscompleted use-case from 04

Default flow

01 → 02 → 03 → 04 → 05

Transversal rules

  • Class name ends in UseCase; single async execute() method; never a plain function.
  • Every method (public or private) ≤ 20 lines; extract named private methods before reaching the limit.
  • Shared sub-use-cases live in src/application/use-cases/shared/ and are never called from commands.
  • Capability sub-use-cases live in subdirectories (install/, update/) and receive narrowed types.
  • Never call manifestRepo.save() in isolation; delegate to PostInstallPipelineUseCase.
  • Use constructor injection order: FileSystem → Repository → Loader → Hasher → Logger → Platform → Prompter.
  • Use import type for type-only imports; .js extensions on all relative imports.
  • Named export only.

References

  • references/use-case-rules.md — class shape, constructor order, Prompter restrictions, user-file protection
  • references/shared-use-cases.md — shared sub-use-case placement and contract
  • references/capability-sub-use-cases.md — capability guard pattern, narrowed types
  • references/post-install-pipeline.md — pipeline delegation rules

Invariant rules

  • references/use-case-rules.md — authoritative use-case rules