.claude/skills/add-use-case/SKILL.md
Add a use case to an existing context
npx skillsauth add adamayoung/popcorn add-use-caseInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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()
}
Create AppDependencies/{Context}/{UseCaseName}UseCase+TCA.swift:
enum {UseCaseName}UseCaseKey: DependencyKey {
static var liveValue: any {UseCaseName}UseCase {
@Dependency(\.{context}Factory) var factory
return factory.make{UseCaseName}UseCase()
}
}
public extension DependencyValues {
var {useCaseName}: any {UseCaseName}UseCase {
get { self[{UseCaseName}UseCaseKey.self] }
set { self[{UseCaseName}UseCaseKey.self] = newValue }
}
}
Create tests in Contexts/{Context}/Tests/{Context}ApplicationTests/UseCases/{UseCaseName}/:
$ARGUMENTS
data-ai
Add properties to an existing domain model from TMDb
testing
Run all unit tests
testing
Run UI tests
testing
Run snapshot tests