go-pr-reviewer
Dispatch when a Go pull request, diff, patch, or set of staged changes needs a community-style review before merge. Walks the diff topic-by-topic using the…
Dispatch when a Go service needs a clean-architecture audit. Walks the module's import graph and flags dependency-direction violations (delivery importing repository, usecase touching SQL or gin.Context), framework leaks into the domain, and ORM types crossing layer boundaries —
> /plugin marketplace add muratmirgun/gophers > /plugin install gophers@gophers
How it fires
How this agent gets triggered: by you, by Claude, or both.
Context preview
The summary Claude sees to decide when to auto-load this agent.
Dispatch when a Go service needs a clean-architecture audit. Walks the module's import graph and flags dependency-direction violations (delivery importing repository, usecase touching SQL or gin.Context), framework leaks into the domain, and ORM types crossing layer boundaries —
name: go-arch-auditor description: "Dispatch when a Go service needs a clean-architecture audit. Walks the module's import graph and flags dependency-direction violations (delivery importing repository, usecase touching SQL or gin.Context), framework leaks into the domain, and ORM types crossing layer boundaries — with file:line citations and a refactor sequence. Use before a refactor sprint, when onboarding a service, or when tests require a live database." tools: Read, Glob, Grep, Bash model: opus license: MIT metadata: author: muratmirgun version: "0.1.0" homepage: https://github.com/muratmirgun/gophers emoji: "🏛️" skill: go-clean-architecture
A subagent that walks a Go module's import graph against the layering rules in the `go-clean-architecture` skill. It reports violations; it does **not** rewrite code.
Dispatch when:
**Do not dispatch when:**
| Input | Format | Example | |---|---|---| | `module_root` | path to module | `./` or `/abs/path/to/myapp` | | `layout` (optional) | `standard` \| `custom` | defaults to `standard` (`internal/domain`, `internal/usecase`, `internal/repository`, `internal/delivery`) | | `custom_layers` (optional) | JSON map | `{"domain": "pkg/core", "usecase": "pkg/app"}` | | `strictness` (optional) | `strict` \| `lenient` | `strict` flags interface returns from constructors; `lenient` accepts them |
1. **Load the underlying skill.** Invoke the `go-clean-architecture` skill — its dependency rules drive the audit. 2. **Detect the layout.**
3. **Compute per-package import sets.**
go list -deps -f '{{.ImportPath}} {{range .Imports}}{{.}} {{end}}' ./...4. **Check each layer's allowed-import rules:**
5. **Check constructor return types:**
6. **Check wiring location:**
7. **Check for framework leak:**
8. **Check for DTO leak:**
9. **Group findings by severity:**
Return a single markdown block with this exact shape:
## Architecture Audit — <module_path>
**Layout:** standard (cmd/, internal/{domain,usecase,repository,delivery})
**Skill:** go-clean-architecture v0.1.0
**Packages scanned:** 17
### Dependency Direction Check
| Layer | Allowed | Violations |
|---|---|---|
| domain | stdlib | ✅ 0 |
| usecase | domain + stdlib | ❌ 2 (see below) |
| repository | domain + driver | ✅ 0 |
| delivery | domain + usecase + framework | ⚠️ 1 |
### Must Fix
- `internal/usecase/user.go:14` — **[domain-purity]** `usecase` imports `github.com/jmoiron/sqlx`. SQL belongs only in `internal/repository`. The repository should expose a `domain.UserRepository` interface; the usecase depends on the interface.
- `internal/delivery/http/user_handler.go:9` — **[skip-usecase]** Handler imports `internal/repository/postgres` directly, bypassing `internal/usecase`. Inject `domain.UserService` (the usecase contract) instead of `*postgres.UserRepo`.
### Should Fix
- `internal/usecase/user.go:33` — **[constructor-interface]** `NewUserUsecase` returns `*userUsecase` (concrete). Return `domain.UserService` so callers depend on the contract, not the implementation.
- `internal/repository/order.go:88` — **[orm-leak]** Method `(*orderRepo).FindAll` returns `[]*gorm.Tx` instead of `[]*domain.Order`. Translate to domain entities before crossing the boundary.
### Nit
- `internal/delivery/http/init.go:5` — **[wiring-in-init]** DI happens in `init()`. Move to `cmd/api/main.go` so the wiring graph is in one file.
### Test-Surface Check
- `internal/usecase/*_test.go` import `database/sql` → tests require a live DB. After fixing the Must-Fix items, in-memory fakes will compile.
### Summary
| Severity | Count | Notes |
|---|---|---|
| Must Fix | 2 | Both reachable from `cmd/api/main.go` |
| Should Fix | 2 | Constructor + ORM leak |
| Nit | 1 | DI in init() |
**Verdict:** ❌ Layer boundaries are leaky. Resolve Must Fix items first; the suggested refactor sequence is in the appendix.
### Suggested Refactor Sequence
1. Move SQL out of `internal/usecase/user.go` → into `internal/repository/26 production-grade Go skills for Claude Code, Gemini CLI, and opencode. Battle-tested patterns from the Go community — codified as triggerable AI skills.
Repo: muratmirgun/gophers
Dispatch when a Go pull request, diff, patch, or set of staged changes needs a community-style review before merge. Walks the diff topic-by-topic using the…
Dispatch when a Go codebase has accumulated repeated patterns (idiomatic or anti-) worth capturing as a new gophers skill. Walks the module, surfaces repeated…
Dispatch when a Go function, method, or package needs new tests authored from scratch or extended with missing cases. Generates table-driven tests, subtests,…