golang-ddd-refactor

Installation
SKILL.md

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

  1. 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.
  1. 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.
  1. 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.
Related skills

More from joeyave/golang-ddd-skills

Installs
12
GitHub Stars
2
First Seen
Apr 12, 2026