xiaohongshu
xiaohongshu
golang-clean-architecture
Clean Architecture audit for Go services. Use when reviewing layered architecture, dependency rules, or gRPC/usecase/repository patterns. Ensures proper separation of concerns and dependency inversion.
Full skill instructions
Audit Go services for Clean Architecture compliance. Ensures proper layering, dependency rules, and separation of concerns in gRPC → Usecase → Repository → Domain architectures.
Use this skill when:
┌─────────────────────────────────────┐
│ Delivery (gRPC/HTTP/GraphQL) │ ← Thin, no business logic
├─────────────────────────────────────┤
│ Usecase (Business Logic) │ ← Orchestration
├─────────────────────────────────────┤
│ Repository (Data Access) │ ← CRUD only
├─────────────────────────────────────┤
│ Domain (Entities/Interfaces) │ ← Pure business logic
└─────────────────────────────────────┘
Dependency Rule: Dependencies point INWARD only (toward domain).
high-business-logic-handler - Keep delivery layer thinhigh-business-logic-repository - No business logic in data layerhigh-constructor-creates-deps - Inject dependencies, don't createhigh-transaction-in-repository - Transactions belong in usecasearch-domain-import-infra - Domain must not import infrastructurearch-concrete-dependency - Depend on interfaces, not concrete typesarch-repository-business-logic - Repositories do CRUD onlyarch-usecase-orchestration - Usecases orchestrate, entities decidearch-interface-segregation - Small, consumer-defined interfaces// gRPC handler doing calculations
func (h *Handler) CreateOrder(ctx context.Context, req *pb.Request) (*pb.Response, error) {
total := req.Price * req.Quantity // BAD: calculation in handler
discount := total * 0.1 // BAD: business rules in delivery layer
order := &domain.Order{
Total: total - discount,
}
return h.orderRepo.Save(ctx, order)
}
// Handler delegates to usecase
func (h *Handler) CreateOrder(ctx context.Context, req *pb.Request) (*pb.Response, error) {
order, err := h.orderUsecase.Create(ctx, req.Price, req.Quantity)
if err != nil {
return nil, err
}
return &pb.Response{OrderId: order.ID}, nil
}
// Usecase contains business logic
func (u *OrderUsecase) Create(ctx context.Context, price, quantity int) (*domain.Order, error) {
total := price * quantity // GOOD: calculation in usecase
discount := total * 0.1 // GOOD: business rules in usecase
order := &domain.Order{
Total: total - discount,
}
return u.orderRepo.Save(ctx, order)
}
// Repository doing validation and business rules
func (r *OrderRepo) Save(ctx context.Context, order *domain.Order) error {
if order.Total < 0 { // BAD: validation in repository
return errors.New("invalid total")
}
if order.Total > 1000000 { // BAD: business rule in repository
order.Status = "needs_approval" // BAD: state change in repository
}
return r.db.Create(order)
}
// Repository only handles data persistence
func (r *OrderRepo) Save(ctx context.Context, order *domain.Order) error {
return r.db.Create(order) // GOOD: simple CRUD
}
// Validation happens in usecase or domain entity
func (u *OrderUsecase) Create(ctx context.Context, price, quantity int) (*domain.Order, error) {
order := domain.NewOrder(price, quantity) // Entity validates itself
if err := order.Validate(); err != nil { // GOOD: validation in domain
return nil, err
}
if order.NeedsApproval() { // GOOD: business rule in domain
order.Status = "needs_approval"
}
return u.orderRepo.Save(ctx, order)
}
This skill activates when you say:
## Architecture Violations: X
### [Rule Name] (File: path/to/file.go)
**Layer**: Delivery / Usecase / Repository / Domain
**Issue**: Brief description of violation
**Impact**: Tight coupling / Untestable / Wrong responsibility
**Fix**: Suggested correction
**Example**:
```go
// Corrected code
Based on Uncle Bob's Clean Architecture:
Key Principle: The inner circles know nothing about the outer circles.
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