golang-ddd-refactor
Golang DDD Refactor
Use this skill when the code already works but is becoming hard to trust, test, or extend because the business rules are scattered across transport and persistence code.
Refactor Loop
- Find the use case from the edge of the system.
- Start from HTTP handlers, gRPC methods, commands, repository callbacks, or transaction blocks.
- Write down the business operation in plain language before introducing any new types.
- Extract the rules hiding inside conditionals.
- Look for "walls of
if" that decide whether something may happen. - Turn those rules into invariants and behavior methods on a domain type.
- Create or tighten the domain type.
- Prefer constructors that reject invalid state.
- Prefer private fields when external mutation would bypass invariants.
- Replace setters with behavior methods named in business language.
More from joeyave/golang-ddd-skills
golang-ddd-architecture
Design and refactor Go service architecture for DDD-style systems. Use when a Go codebase needs explicit ports/app/domain/adapters boundaries, dependency rules, interface placement, composition-root dependency injection, separate transport and database models, or help deciding whether DDD, Clean Architecture, or CQRS are justified.
13golang-ddd
Entry-point router for Go architecture and refactoring tasks focused on DDD-style services. Use when working on a Go service and you want one skill to decide whether the task is primarily about architecture boundaries, domain-first refactoring, pragmatic CQRS, or delivery and test support. This skill should select one or more companion skills and apply them in the right order.
10golang-ddd-cqrs
Structure Go application logic with pragmatic CQRS. Use when command and query concerns are mixed, handlers are hard to test, one application service is becoming wide, or a Go service needs business-oriented command and query naming, separate handlers, thin ports, narrow consumer-owned interfaces, and guidance on when CQRS is or is not worth the cost.
10golang-ddd-infrastructure
Support Go services by keeping infrastructure, security boundaries, and automated tests aligned with the application architecture. Use when working on Terraform, Cloud Run, Cloud Build or CI, docker-compose environments, integration or component test setup, repository authorization boundaries, service-to-service authentication, or secure internal operations.
10