go-interfaceslisted
Install: claude install-skill CasLubbers/code-design-skills
# Go interfaces
Go interfaces are satisfied implicitly. The implementing type never names the interface, which flips where the interface belongs.
## The consumer declares the interface
Define it in the package that *uses* it, listing only what that package calls.
```go
// package notify — the consumer. It needs exactly one method.
type UserFinder interface {
FindUser(ctx context.Context, id string) (*User, error)
}
func Send(ctx context.Context, f UserFinder, id string) error { ... }
```
```go
// package store — the producer. Returns a concrete type, declares no interface.
func New(db *sql.DB) *Store { ... }
func (s *Store) FindUser(ctx context.Context, id string) (*User, error) { ... }
```
`*store.Store` satisfies `notify.UserFinder` with no import between them and no declaration linking them. Producer-side interfaces (`store.StoreInterface` next to `store.Store`) invert this: they force every consumer to depend on a surface far wider than it uses, and they change whenever any consumer needs something new.
## Keep them small
One or two methods. The standard library's most reused interfaces have one:
```go
type Reader interface { Read(p []byte) (n int, err error) }
type Writer interface { Write(p []byte) (n int, err error) }
type Stringer interface { String() string }
```
A large interface is not reusable, not implementable in a test without a pile of stubs, and usually a struct wearing a disguise. If yours has seven methods, you have described a type, not a ca