implement-go-interface

Generates Go interface test doubles including blank, memory, broken, and fake implementations.

5|Updated Sep 9, 2017
One-click install
npx skills add https://github.com/hpcsc/dotfiles --skill implement-go-interface-hpcsc
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: implement-go-interface
Source: https://github.com/hpcsc/dotfiles/tree/main/link/common/claude/.claude/skills/implement-go-interface
Command: npx skills add https://github.com/hpcsc/dotfiles --skill implement-go-interface-hpcsc

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing test doubles for Go interfaces by hand is repetitive boilerplate: every interface needs a stub, an in-memory version, an error-injecting version, and a call-recording fake. This Skill automates creating that full implementation package, or audits an existing package and fills in whichever doubles are missing. ## Core Features & Use Cases - Create new implementation packages: Given an interface like checkpoint.Store, it parses all method signatures and scaffolds blank.go, memory.go, broken.go, fake.go, and memory_test.go in the correct package path. - Review existing packages: Given a path to an implementation package, it detects which doubles exist and generates only the missing ones. - Consistent testing patterns: Every file includes a compile-time interface assertion (var _ Interface = (*Impl)(nil)), fluent error configuration for the broken double, empty and pre-populated factories for memory, and testify-based tests. - Use Case: While writing unit tests for a service that depends on a storage interface, invoke the Skill with the interface name to instantly get an in-memory implementation for happy-path tests and a broken implementation for error-path tests. ## Quick Start Ask the AI to run the implement-go-interface skill on the checkpoint.Store interface to generate the full set of test doubles.

Frequently Asked Questions about implement-go-interface

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate test doubles for a Go interface?▼

Pass the interface name, such as checkpoint.Store, and the Skill locates the interface definition, parses its method signatures, and creates blank, memory, broken, and fake implementations plus a memory test file in the corresponding package.

How to create a fake implementation for Go interface testing?▼

The fake.go file records every method call in fields like CalledMethodName and supports fluent setters for configurable behavior. It includes a compile-time interface assertion so it always satisfies the target interface.

Can it fill in missing implementations in an existing Go package?▼

Yes. Pass the package path instead of an interface name, and it reviews existing files, identifies which of blank, memory, broken, fake, and memory_test are missing, then generates only those files following the same patterns.

What testing libraries does the generated Go code use?▼

The generated memory_test.go uses testify's require package for assertions. All implementations rely only on the standard library and the target interface package, and output is verified with go build and formatted with go fmt.

When should I not use generated interface test doubles?▼

Skip the blank stub when the package already contains a real production implementation. For interfaces with complex external behavior like network protocols, hand-written mocks or integration tests against real services may be more appropriate.