From gosdk
Use when implementing features or refactoring in Go projects that follow MVC layering (handler/service/repository/model), or when code violates layer boundaries (handler doing DB access, business logic in service, fat models). Keywords - layer rules, interface placement, constructor injection, error wrapping, context propagation. Distinct from golang-code-quality which focuses on SOLID and code-level patterns.
How this skill is triggered — by the user, by Claude, or both
Slash command
/gosdk:golang-mvcThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Go MVC implementation conventions for **feature work and refactoring**.
Go MVC implementation conventions for feature work and refactoring. This skill guides code generation and actively enforces layer boundaries — it modifies and refactors code that violates MVC conventions.
| Layer | Package | Responsibility | May import | Must NOT import |
|---|---|---|---|---|
| Handler | handler/ | HTTP entry point; orchestrate business rules; validate and map input/output | service/, model/, validation/ | config/, DB drivers, repository/ |
| Service | service/ | Thin adapter over external APIs, queues, caches | model/, config/ | handler/ |
| Repository | repository/ | DB access only; returns domain objects | model/, config/ | handler/, service/ |
| Model | model/ | Pure data: domain structs + conversion methods (ToDTO, FromRow) | nothing internal | handler/, service/, repository/ |
| Validation | validation/ | Named validators for domain rules | model/ | handler/, service/ |
| Config | config/ | Load env/files; construct and wire concrete types | all | — |
Build in this order. Do not skip steps.
model/)model/ (use model (singular) as the default package for domain models, unless there are more than 30 models, in which case they must be split into domain-specific packages).ToDTO(), FromRow()).repository/ package. One file per aggregate root.service/ package. Retry + timeout logic only; no business decisions.handler/)func NewUserHandler(getter UserGetter, notifier NotifySender, log Logger) *UserHandlerRegisterRoutes(r *gin.RouterGroup) method; never inline in main.go.validation/)Validate() error method.ValidateCreateOrderRequest, not validate.validation.Error{Field: "...", Reason: "..."} — never raw strings.main.go or bootstrap.go)main.go/bootstrap.go.config.Default() from github.com/bizshuk/gosdk, falling back to raw viper manual setup only if the SDK is not supported/available.Interfaces are defined where consumed, not where implemented.
// In handler/user.go — NOT in repository/user.go
type userGetter interface {
GetByID(ctx context.Context, id string) (*model.User, error)
}
This means handler tests can mock the interface without importing the repository package, breaking the import cycle and enabling true unit isolation.
| Dependency count | Pattern |
|---|---|
| ≤ 4 deps | Plain constructor params |
| 5+ deps | HandlerOptions struct |
| Many optional knobs | Functional options ...Option |
fmt.Errorf("handler.GetUser: %w", err)var ErrNotFound = errors.New("not found")SCREAMING_SNAKE_CASE (e.g. MAX_RETRIES, DEFAULT_TIMEOUT).ctx context.Context is always the first parameter of any function that does I/Octx in a structctx, cancel := context.WithTimeout(ctx, cfg.DBTimeout); defer cancel()| Layer | Test approach |
|---|---|
| Handler | Mock all interfaces; use httptest.NewRecorder(); assert status + response body |
| Repository | Use sqlmock or a real test DB via docker-compose; never mock the DB driver itself |
| Service | Mock external HTTP/gRPC clients with interface mocks |
| Validation | Table-driven tests required; cover valid, missing, and out-of-range inputs |
All test files: _test.go suffix, same package as the code under test (prefer white-box
tests for internal helpers, _test package suffix for public API contracts).
npx claudepluginhub bizshuk/gosdkProvides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.