From ai-skills
Domain-layer rules for Clean Architecture backend services. Use when modeling entities, value objects, invariants, and pure business behavior.
How this skill is triggered — by the user, by Claude, or both
Slash command
/ai-skills:clean-architecture-domainThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
This skill converts `backend-engineer/clean-architecture/domain-rule.md` into Claude Code plugin skill guidance while preserving the source rules for production fintech development.
This skill converts backend-engineer/clean-architecture/domain-rule.md into Claude Code plugin skill guidance while preserving the source rules for production fintech development.
Domain layer is the heart of the system.
It contains core business knowledge and rules independent from frameworks.
Goals:
Rule:
If framework changes, domain should remain almost unchanged.
Domain layer should contain:
Examples:
Domain must NOT contain:
Bad Example:
@Autowired
Repository repo;
Entity has identity + behavior.
Examples:
Behavior inside entity:
wallet.debit(amount)
wallet.
credit(amount)
payment.
refund()
Do not create anemic domains with only getters/setters.
Immutable objects without identity.
Examples:
Example:
public record Money(BigDecimal amount, String currency) {
}
Use value objects to increase safety.
Domain must protect impossible states.
Examples:
Example:
if(balance.compareTo(amount) < 0)
throw new
InsufficientBalanceException();
Use when logic does not belong to one entity.
Examples:
Example:
fee =feeService.
calculate(sender, amount);
Represent meaningful business events.
Examples:
Used for:
public class Wallet {
private BigDecimal balance;
public void debit(BigDecimal amount) {
validatePositive(amount);
if (balance.compareTo(amount) < 0) {
throw new InsufficientBalanceException();
}
balance = balance.subtract(amount);
}
public void credit(BigDecimal amount) {
validatePositive(amount);
balance = balance.add(amount);
}
}
Common Domain Models:
Value Objects:
Domain tests should be pure unit tests.
No Spring context. No database. No mocks unless needed for service collaborators.
Test:
Avoid:
When generating domain layer:
npx claudepluginhub silverpham08091998/ai-skills --plugin ai-skillsCreates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.