mcpField
G
golang-ddd-cqrs

golang-ddd-cqrs

github.com/joeyaveDevelopment441 installsUpdated 29w ago
Repository

About golang-ddd-cqrs

golang-ddd-cqrs is a skill for organizing Go application logic around commands and queries when business behavior warrants CQRS. It guides developers toward business-named operations, focused handlers, and tests centered on orchestration.

Key features

  1. 01Separate state-changing commands from queries
  2. 02Name operations in business terms
  3. 03Use focused handlers and narrow interfaces
  4. 04Keep domain rules out of handlers
  5. 05Test application orchestration

Use cases

  1. 01Structuring a Go service with complex write behavior
  2. 02Separating read and write concerns
  3. 03Reducing oversized application services
  4. 04Testing handlers independently of domain rules

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/joeyave/golang-ddd-skills --skill golang-ddd-cqrs

After installing, type/golang-ddd-cqrsin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

agents/
openai.yaml
references/
application-tests-and-errors.md
cqrs-guidelines.md

Details

From the project README

Golang DDD CQRS

Use this skill to split application logic into clear commands and queries without turning Go code into ceremony-heavy enterprise scaffolding.

Start Here

  • Use CQRS when a service has meaningful write-side behavior, mixed read and write models, or application services that are hard to reason about.
  • Skip or minimize CQRS when the service is mostly simple CRUD or login-like flows with little business behavior.

Workflow

  1. Split the use cases into writes and reads.
  • Commands mutate state and may return errors.
  • Queries return data and should not perform business mutations.
  1. Name them in business language.
  • Prefer ScheduleTraining, CancelTraining, ApproveReschedule, AvailableHours.
  • Avoid default CRUD names unless the business really speaks that way.
  1. Introduce separate handlers when it improves clarity.
  • Use one command handler type per command when the logic or dependencies differ.
  • Use one query handler type per query when read concerns differ.
  • Keep interfaces narrow and owned by the handler that consumes them.
  1. Keep handlers orchestration-only.
  • Domain rules belong in the domain layer.
  • Transport mapping belongs in ports.
  • Database or external API details belong in adapters.
  1. Shape the ports around CQRS.
  • HTTP or gRPC ports may call commands directly.
  • If a create command needs a follow-up read, prefer 204 No Content plus content-location when practical, or execute an explicit query after the command.
  • Keep port-specific error translation at the edge.
  1. Test the application layer as orchestration.
  • Mock repositories and outbound services with tiny handwritten mocks.
  • Keep business-scenario assertions in domain tests unless the behavior truly belongs to application orchestration.

Guardrails

  • Do not create separate command and query packages if the service is still trivial.
  • Do not let commands return large read models by default.
  • Do not hide business logic in command handlers just because they are convenient.
  • Do not keep one giant application service if separate handlers would shrink interfaces and tests.

Use These References

Deliverables

  • command and query boundaries that match the use cases,
  • business-oriented names,
  • narrow handler-owned interfaces,
  • thin transport code,
  • handler tests focused on orchestration instead of domain internals.

Comments

Markdown supported