golang-mvc

Enforce MVC layer boundaries in Go projects with import rules and dependency patterns.

Updated Aug 9, 2022
One-click install
npx skills add https://github.com/BizShuk/gosdk --skill golang-mvc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-mvc
Source: https://github.com/BizShuk/gosdk/tree/main/skills/golang-mvc
Command: npx skills add https://github.com/BizShuk/gosdk --skill golang-mvc

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Go projects often suffer from messy, tightly coupled code where MVC layer boundaries are violated—such as handlers directly accessing databases or business logic being placed in the wrong layer—making code hard to test, refactor, and maintain.

Core Features & Use Cases

  • Strict Layer Boundary Enforcement: Clear import rules for each MVC layer (handler, service, repository, model, validation) to prevent cross-layer dependencies.
  • End-to-End Implementation Guidance: Step-by-step checklist for building new features following MVC conventions, from model definition to final wiring.
  • Refactoring Support: Rules and patterns to fix existing code that violates layer boundaries, including interface placement, constructor injection, and standardized error handling. Use Case: If your Go service has handlers that directly query the database, use this skill to refactor the code to move DB access to the repository layer, define testable interfaces in the handler, and follow standardized wiring and test patterns.

Quick Start

Use the golang-mvc skill to refactor your existing Go service to enforce proper MVC layer boundaries and eliminate cross-layer dependency violations.

Frequently Asked Questions about golang-mvc

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

FAQPage Schema
How do I fix Go code where handlers directly access the database?

To fix Go code where handlers directly access the database, refactor by moving database access to the repository layer and defining consumer-side interfaces in the handler. This enforces strict MVC layer boundaries, reducing tight coupling and improving testability.

What are the MVC layer boundaries in a clean Go architecture?

MVC layer boundaries in clean Go architecture define strict cross-layer import rules separating handler, service, repository, model, and validation layers. They prevent business logic from being placed in the wrong layer, making the codebase easier to maintain and test.

How do I enforce constructor injection and context propagation in Go MVC?

To enforce constructor injection and context propagation in Go MVC, apply standardized wiring patterns that define testable interfaces on the consumer side. This ensures dependencies are injected correctly and context flows cleanly across layer boundaries.

Does this Go MVC refactoring approach work with existing tightly coupled services?

Yes, this Go MVC refactoring approach works with existing tightly coupled services by applying specific rules to fix code that violates layer boundaries. It supports moving misplaced business logic and standardizing error handling to eliminate unmaintainable code.

What is the best way to structure Go feature development using MVC conventions?

The best way to structure Go feature development using MVC conventions is following an end-to-end implementation checklist. This step-by-step process guides you from model definition to final wiring, ensuring layer-specific test patterns are applied correctly.