en un clic
add-use-case
Add a use case to an existing context
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Menu
Add a use case to an existing context
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Basé sur la classification professionnelle SOC
| name | add-use-case |
| description | Add a use case to an existing context |
Guide for adding a new use case following clean architecture patterns.
Ask the user for:
Contexts/{Context}/Sources/{Context}Application/UseCases/{UseCaseName}/
{UseCaseName}UseCase.swift - Protocol definition:
public protocol {UseCaseName}UseCase: Sendable {
func execute(...) async throws({UseCaseName}Error) -> ResultType
}
Default{UseCaseName}UseCase.swift - Implementation:
final class Default{UseCaseName}UseCase: {UseCaseName}UseCase {
private let repository: any SomeRepository
init(repository: some SomeRepository) {
self.repository = repository
}
func execute(...) async throws({UseCaseName}Error) -> ResultType {
// Implementation
}
}
{UseCaseName}Error.swift - Error type:
public enum {UseCaseName}Error: Error, Equatable, Sendable {
case notFound
case unknown(Error? = nil)
}
In {Context}Application/{Context}ApplicationFactory.swift:
func make{UseCaseName}UseCase() -> some {UseCaseName}UseCase {
Default{UseCaseName}UseCase(repository: repository)
}
In {Context}Composition/Popcorn{Context}Factory.swift:
public func make{UseCaseName}UseCase() -> some {UseCaseName}UseCase {
applicationFactory.make{UseCaseName}UseCase()
}
This is all the wiring the use case needs: the context factory is already exposed
on AppServices (e.g. services.{context}Factory), so any feature can reach the
new use case through it.
There is no per-use-case dependency registration. A feature reaches the use case
in its {Feature}Dependencies.live(services:) builder via the context factory on
AppServices, mapping the domain result to a view model:
public extension {Feature}Dependencies {
static func live(services: AppServices) -> {Feature}Dependencies {
let useCase = services.{context}Factory.make{UseCaseName}UseCase()
return {Feature}Dependencies(
fetch: { id in
let result = try await useCase.execute(id: id)
return {Feature}Mapper().map(result)
}
)
}
}
Create tests in Contexts/{Context}/Tests/{Context}ApplicationTests/UseCases/{UseCaseName}/:
$ARGUMENTS
Build the project for testing
Build the project
Take the current plan all the way to a ready-to-merge pull request — review the plan (scaled to risk), implement it test-first, code-review and fix, security-review, verify the acceptance criteria, open the PR, and watch it green. Use after you have an approved plan (e.g. from plan mode) and want the rest of the feature pipeline run end-to-end. Invoking it is itself plan approval — it then runs autonomously to a single hard stop: ready-to-merge.
Run a specific test target or test class
Run all unit tests
Run snapshot tests