From ai-skills
Application-layer and use case rules for Clean Architecture backend services. Use when orchestrating business flows, ports, and transactions.
How this skill is triggered — by the user, by Claude, or both
Slash command
/ai-skills:clean-architecture-applicationThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
This skill converts `backend-engineer/clean-architecture/application-rule.md` into Claude Code plugin skill guidance while preserving the source rules for production fintech development.
This skill converts backend-engineer/clean-architecture/application-rule.md into Claude Code plugin skill guidance while preserving the source rules for production fintech development.
Application layer orchestrates use cases and business flows.
It sits between Controller and Domain/Infrastructure.
Goals:
Rule:
Application layer controls the flow, not the business essence.
Application layer is allowed to:
Application layer must NOT contain:
Bad Example:
return ResponseEntity.ok(...)
Controller
-> Command
-> UseCase.execute(command)
-> Load domain objects via ports
-> Execute business rules
-> Persist changes via ports
-> Publish events
-> Return Result
Use dedicated models:
Examples:
Command contains input required by use case only.
Use one class per use case.
Examples:
Prefer single public method:
execute(...)
handle(...)
run(...)
Preferred:
PaymentResult execute(CreatePaymentCommand cmd)
Transaction boundary usually belongs here.
Example:
@Transactional
public TransferResult execute(...) {
}
Use transaction for:
Avoid giant transaction with remote API calls.
Depend on interfaces only.
Examples:
WalletRepositoryPort
PaymentGatewayPort
LedgerPostingPort
NotificationPort
Application uses ports, infra implements them.
Return dedicated result objects.
Examples:
Do not return entity directly.
@RequiredArgsConstructor
public class TransferUseCase {
private final WalletRepositoryPort walletRepo;
private final LedgerPort ledgerPort;
@Transactional
public TransferResult execute(TransferCommand cmd) {
Wallet from = walletRepo.load(cmd.fromWalletId());
Wallet to = walletRepo.load(cmd.toWalletId());
from.debit(cmd.amount());
to.credit(cmd.amount());
walletRepo.save(from);
walletRepo.save(to);
ledgerPort.postTransfer(cmd);
return new TransferResult("SUCCESS");
}
}
Application layer handles:
Examples:
Throw meaningful exceptions:
Do not return null.
Use unit tests with mocked ports.
Test:
Example:
@Mock
WalletRepositoryPort repo;
@InjectMocks
TransferUseCase useCase;
Avoid:
When generating application layer:
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub silverpham08091998/ai-skills --plugin ai-skills