Agent skill
kratos-biz-layer
Generates business logic layer components for go-kratos microservices following Clean Architecture. Creates use cases, repository interfaces, business models, and validators. Use when adding business logic to kratos services.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/design/kratos-biz-layer-alecszaharia-brizy-microservices-
SKILL.md
<essential_principles>
How Kratos Business Layer Works
Clean Architecture Dependency Rule
The business layer (biz) is the core of Clean Architecture in Kratos microservices:
Dependency Flow: Service → Biz → Data
- Biz defines interfaces that data layer implements
- Biz contains business logic independent of frameworks
- Biz uses domain models not ORM entities
Three Key Components
1. Business Models (internal/biz/models.go)
- Domain entities with validation tags
- Independent of database structure
- Use
validatorstruct tags for validation
2. Repository Interfaces (internal/biz/interfaces.go)
- Define data access contracts
- Implemented by data layer
- Accept/return business models, not ORM entities
3. Use Cases (internal/biz/{entity}.go)
- Orchestrate business logic
- Depend on repository interfaces
- Handle validation, logging, error mapping
Wire Dependency Injection
All constructors must be added to ProviderSet in internal/biz/biz.go:
var ProviderSet = wire.NewSet(NewSymbolValidator, NewSymbolUseCase)
After changes, run make generate to regenerate Wire code.
</essential_principles>
- Create a new entity (use case + interface + model + validator)
- Add methods to existing use case
- Create standalone validator
- View examples and patterns
Wait for response before proceeding.
After reading the workflow, follow it exactly.
<reference_index>
All domain knowledge in references/:
Core Patterns: use-case-pattern.md, interface-pattern.md, model-pattern.md Code Style: naming-conventions.md
Additional patterns (error handling, logging, transactions, testing) are covered within use-case-pattern.md. </reference_index>
<workflows_index>
| Workflow | Purpose |
|---|---|
| create-entity.md | Generate complete biz layer for new entity |
| add-methods.md | Add CRUD methods to existing use case |
| create-validator.md | Create standalone validator |
| view-examples.md | Show patterns and examples |
| </workflows_index> |
<success_criteria> Business layer code is correct when:
- Use case struct has repo, log, validator, tm fields
- Constructor function returns interface type (not struct)
- Methods accept context.Context as first parameter
- Validation happens before repository calls
- Errors are properly wrapped and logged
- Repository interface added to interfaces.go
- Business model added to models.go with validation tags
- Constructor added to ProviderSet in biz.go
- User reminded to run
make generate</success_criteria>
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?