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
| # | Action | Role | Input |
|---|---|---|---|
| 01 | define-types | Declare *Options and *Result interfaces | use-case name + field list |
| 02 | write-execute | Write the execute() method body (≤20 LOC) | types from 01 |
| 03 | extract-methods | Extract intent-named private helper methods | execute() body from 02 |
| 04 | wire-errors-and-pipeline | Add typed throws + delegate to PostInstallPipeline | methods from 03 |
| 05 | test | Write integration-tier unit tests | completed use-case from 04 |
Default flow
01 → 02 → 03 → 04 → 05
Transversal rules
- Class name ends in
UseCase; singleasync 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 toPostInstallPipelineUseCase. - Use constructor injection order: FileSystem → Repository → Loader → Hasher → Logger → Platform → Prompter.
- Use
import typefor type-only imports;.jsextensions on all relative imports. - Named export only.
References
references/use-case-rules.md— class shape, constructor order, Prompter restrictions, user-file protectionreferences/shared-use-cases.md— shared sub-use-case placement and contractreferences/capability-sub-use-cases.md— capability guard pattern, narrowed typesreferences/post-install-pipeline.md— pipeline delegation rules
Invariant rules
references/use-case-rules.md— authoritative use-case rules