go-clean-architecture

Organize Go projects into domain, application, and infrastructure layers.

28|10|Updated Jan 27, 2026
One-click install
npx skills add https://github.com/danvei233/xiaoheiFS --skill go-clean-architecture-danvei233
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-clean-architecture
Source: https://github.com/danvei233/xiaoheiFS/tree/main/backend
Command: npx skills add https://github.com/danvei233/xiaoheiFS --skill go-clean-architecture-danvei233

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Organize Go projects using clean architecture to separate domain, business rules, and interfaces.

Core Features & Use Cases

  • Domain Layer: define entities and domain interfaces in internal/domain; enforce no external dependencies in core business logic.
  • Application Layer: orchestrate use cases and services, depending only on domain interfaces and avoiding HTTP/DB code.
  • Infrastructure Layer: implement repositories and adapters; wired into the app via dependency injection for flexibility and testability.
  • Use Case Scenarios: build maintainable services (e.g., user/account management) by clearly separating concerns and enabling easy testing.

Quick Start

Create a new Go module and start by placing domain models in internal/domain, services in internal/application, and wire them together in main.go or cmd/server.

Frequently Asked Questions about go-clean-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a Go project using clean architecture to separate domain logic and infrastructure?

Structure Go projects with clean architecture by placing domain models in internal/domain, services in internal/application, and wiring infrastructure adapters in main.go via dependency injection to enforce layer boundaries and testability.

What is the best way to enforce dependency direction in a Go clean architecture project?

Enforce dependency direction in Go clean architecture by ensuring the domain layer has zero external dependencies, keeping application use cases free of HTTP or DB code, and wiring infrastructure implementations into the app through dependency injection.

How does dependency injection work with layered architecture in Go services?

Dependency injection in Go layered architecture works by wiring infrastructure layer implementations like repositories and adapters into the application layer at runtime, enabling lightweight testing and incremental evolution without coupling use cases to concrete database code.

Can I apply domain-driven design principles to organize an existing Go service for better testability?

Apply domain-driven design to Go services by defining entities and domain interfaces in a dedicated domain layer, orchestrating use cases in an application layer, and isolating external interfaces in an infrastructure layer to enable clear boundaries and scalable maintainability.

When should I use clean architecture for my Go application instead of a simpler package layout?

Use clean architecture for Go applications when services require clear boundaries, testability, and scalable maintainability across domain, use-case, and infrastructure layers, especially for complex domain logic like user or account management systems.

How do I test Go use cases without connecting to a real database in a clean architecture setup?

Test Go use cases without a database by defining repository contracts in the domain layer, injecting mock infrastructure adapters during dependency injection, and ensuring the application layer depends only on domain interfaces rather than concrete DB implementations.