← ClaudeAtlas

go-dependency-directionlisted

Applies dependency-direction rules when writing or reviewing Go code — consumer-defined minimal interfaces, no domain→infrastructure imports, one-way package arrows. Load whenever writing, refactoring, or reviewing Go packages, designing package layout, defining interfaces, or wiring repository/service/handler layers.
rgglez/rgglez-dev-skills · ★ 0 · Web & Frontend · score 70
Install: claude install-skill rgglez/rgglez-dev-skills
# Dependency direction in Go ## Persistence Active for the rest of the session once loaded. Off only when the user says "stop go-dd" / "normal mode" / "ignora las reglas de dependencias" — then write Go the ordinary way, and say so in one line. Back on when they say "go-dd" / "go-dd on" / "aplica las reglas de dependencias", or invoke the skill again. Confirm in one line and resume. The import graph **is** the architecture. Directory names (`domain/`, `usecase/`, `infrastructure/`) are decoration. A package called `domain` that imports the one holding your database pool is infrastructure code wearing a label. Every layout decision reduces to one question: *which package is permitted to know that another exists?* ## Interfaces are declared by the caller Put the interface in the package that **invokes** it, listing only the methods that package invokes. Declaring it beside the implementation forces every caller to import the provider, and any signature change there ripples outward to all of them. Avoid — the provider exports the abstraction: ```go // package mailer type Mailer interface { Send(ctx context.Context, to, subject, body string) error SendBatch(ctx context.Context, to []string, subject, body string) error Close() error } type SMTPMailer struct{ /* ... */ } func (m *SMTPMailer) Send(...) error { /* ... */ } ``` Prefer — the caller states the shape it depends on, and the implementation carries no project imports: ```go // package invoicing type sender in