What problem does it solve?
This Skill helps you design Go constructors and factories that can accept many optional settings without turning the API into a brittle pile of positional arguments. It guides you toward a stable pattern that preserves backward compatibility as your package evolves.
Core Features & Use Cases
- Canonical functional options pattern: Use an unexported options bag, an Option interface with an unexported apply method, and With* constructors for each setting.
- API design guidance: Decide when to use functional options versus a config struct, especially for constructors with 3+ optional parameters or future growth.
- Production-oriented details: Set defaults before applying options, keep required parameters positional, and prefer interface-based options over closures for testability and introspection.
- Use case: You are reviewing a New* function with many toggles for cache, logging, timeouts, and metrics, and need to refactor it into a cleaner, extensible API.
Quick Start
Ask the AI to review your Go constructor and rewrite it using functional options with sensible defaults, unexported option state, and With* helpers.