xiaohongshu
xiaohongshu
kratos-biz-layer
Generates business logic layer components (use cases, repository interfaces, business models, validators) for go-kratos microservices following Clean Architecture. Use when implementing domain logic, creating entity CRUD operations, adding validation rules, or orchestrating data access in kratos ...
Full skill instructions
<essential_principles>
The business layer (biz) is the core of Clean Architecture in Kratos microservices:
Dependency Flow: Service → Biz → Data
The biz layer follows domain-driven design with these subdirectories:
1. Domain Layer (internal/biz/domain/)
models.go - Domain entities with validation tagsinterfaces.go - Repository, use case, and event publisher interfaceserrors.go - Domain errors (ErrSymbolNotFound) and data layer errors (ErrDataNotFound)2. Use Case Layer (internal/biz/{entity}/)
usecase.go - Use case implementationusecase_test.go - Use case tests with event assertionsvalidator.go - Validation logic factory3. Event Layer (internal/biz/event/) - Optional
mapper.go - Event payload transformationstopics.go - Event topic constants4. Provider (internal/biz/provider.go)
Data Layer Errors (returned by repositories):
domain.ErrDataNotFound - Record not founddomain.ErrDataDuplicateEntry - Unique constraint violationdomain.ErrDataDatabase - Generic database errorDomain Errors (returned by use cases):
domain.ErrSymbolNotFound - Symbol not found (business error)domain.ErrDuplicateSymbol - Duplicate symbol (business error)domain.ErrDatabaseOperation - Database operation failedPattern: Repositories return data errors, use cases map to domain errors via toDomainError() helper.
Use cases integrate event publishing for domain events:
domain.{Entity}EventPublisher interfaceExample:
err := uc.tm.InTx(ctx, func(ctx context.Context) error {
symbol, err = uc.repo.Create(ctx, s)
if err != nil {
return err
}
return uc.pub.PublishSymbolCreated(ctx, symbol)
})
All constructors must be added to ProviderSet in internal/biz/provider.go:
var ProviderSet = wire.NewSet(symbol.NewValidator, symbol.NewUseCase)
After changes, run make generate to regenerate Wire code.
</essential_principles>
Wait for response before proceeding. </intake>
<routing> | Response | Workflow | |----------|----------| | 1, "create", "new entity", "new" | `workflows/create-entity.md` | | 2, "add method", "add", "extend" | `workflows/add-methods.md` | | 3, "validator", "validation" | `workflows/create-validator.md` | | 4, "examples", "patterns", "help" | `workflows/view-examples.md` |After reading the workflow, follow it exactly. </routing>
<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:
Structure:
internal/biz/domain/models.gointernal/biz/domain/interfaces.gointernal/biz/domain/errors.gointernal/biz/{entity}/usecase.gointernal/biz/{entity}/validator.gointernal/biz/{entity}/usecase_test.goUse Case Implementation:
toDomainError()Domain Layer:
domain/interfaces.godomain/interfaces.go (if events)domain/models.go with validation tagsWire Integration:
internal/biz/provider.gomake generate
</success_criteria>xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience