Back to list
JamesPrial

interface-pollution

by JamesPrial

WIP - collection of various Claude stuff i make/use/have_Claude_hallucinate

2🍴 0📅 Jan 23, 2026

SKILL.md


name: interface-pollution description: Detect and avoid unnecessary interface abstractions

Interface Pollution Detection

Interface pollution occurs when interfaces are created before they're needed. Define interfaces at consumption point, not production.

Pollution Patterns

WRONG - Producer defines interface prematurely

// In package "storage"
type UserRepository interface {
    GetUser(id int) (*User, error)
    SaveUser(u *User) error
}

type PostgresRepo struct{}

func (p *PostgresRepo) GetUser(id int) (*User, error) { ... }
func (p *PostgresRepo) SaveUser(u *User) error { ... }

CORRECT - Consumer defines minimal interface

// In package "handler"
type UserGetter interface {
    GetUser(id int) (*User, error)
}

func HandleRequest(repo UserGetter) http.Handler {
    // Only needs GetUser, not entire repository
    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        user, _ := repo.GetUser(123)
        // ...
    })
}

// Concrete type lives in storage package
// Handler depends on small interface, not full implementation

Detection Checklist

You have interface pollution if:

  • Interface defined in same package as implementation
  • Only one implementation exists
  • Interface has >5 methods
  • Name ends in "Interface" or "Impl"

Refactoring Strategy

Before:

type DataService interface {
    Read() error
    Write() error
    Validate() error
    Transform() error
}

After:

// Split by actual usage
type Reader interface { Read() error }
type Writer interface { Write() error }

// Compose where needed
type ReadWriter interface {
    Reader
    Writer
}

Score

Total Score

65/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

1ヶ月以内に更新

+10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

Reviews

💬

Reviews coming soon