david-li0406/meta-skill-evloving/accept-interfaces-return-structs

Claude Code and agent skill by david-li0406/meta-skill-evloving

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Core pattern for flexible, testable Go APIs

Install

npx vskill@latest install david-li0406/meta-skill-evloving/accept-interfaces-return-structs

SKILL.md

The same SKILL.md was published earlier as majiayu000/claude-skill-registry-data/accept-interfaces-return-structs.

Accept Interfaces, Return Structs

The fundamental Go interface design principle: functions should accept interfaces but return concrete types.

The Pattern

CORRECT - Accept interface, return concrete

go
type Storage interface {
Save(data []byte) error
}
func NewProcessor(s Storage) *Processor {
return &Processor{storage: s}
}
func (p *Processor) Process(input string) (*Result, error) {
// Returns concrete *Result, accepts Storage interface
return &Result{Value: input}, nil
}

WRONG - Return interface unnecessarily

go
func NewProcessor(s *FileStorage) Storage {
// Locks caller into interface, prevents direct method access
return &Processor{storage: s}
}

Why This Works

Accepting interfaces:

  • Caller controls abstraction
  • Easy to mock/test
  • Flexible composition

Returning concrete types:

  • No hidden behaviors
  • All methods visible
  • Can add methods without breaking compatibility

When to Deviate

Return interface when:

go
func NewLogger(env string) io.Writer {
// Valid: stdlib interface, multiple implementations
if env == "prod" {
return &fileLogger{}
}
return &consoleLogger{}
}

Return interfaces only when:

  • Using stdlib interfaces (io.Writer, io.Reader)
  • Multiple implementations chosen at runtime
  • Interface already well-established in ecosystem

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
2
Repository forks
1
7-day trend score
10

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/david-li0406/meta-skill-evloving/accept-interfaces-return-structs/badge)](https://verified-skill.com/skills/david-li0406/meta-skill-evloving/accept-interfaces-return-structs)

Something wrong with this skill or its page? Tell us.