golang-design-patterns
Idiomatic Golang design patterns — functional options, constructors, error flow and cascading, resource management and lifecycle, graceful shutdown, resilience, architecture, dependency injection, data handling, streaming, and more. Apply when explicitly choosing between architectural patterns, implementing functional options, designing constructor APIs, setting up graceful shutdown, applying resilience patterns, or asking which idiomatic Go pattern fits a specific problem.
Security Assessment
About golang-design-patterns
The `golang-design-patterns` skill provides developers with a comprehensive guide to idiomatic design patterns and best practices in Go (Golang). It addresses common challenges in constructing robust, maintainable, and production-ready Go applications, such as managing resource lifecycles, implementing functional options, handling errors effectively, and ensuring graceful shutdowns. By codifying these patterns, the skill helps prevent common pitfalls like implicit globals, unbounded resources, and improper error handling, promoting explicit and simple design choices that scale well with project complexity.
The skill offers a variety of features for both design and review contexts. In design mode, it assists developers in creating APIs, packages, and application structures, emphasizing minimal patterns that satisfy requirements without overcomplication. In review mode, it audits existing code for issues like misuse of `init()`, unbounded resources, missing timeouts, and implicit global state. The skill also provides practical guidance on constructors with functional options, early error returns, proper use of `defer` and runtime cleanup, streaming large data transfers, secure random generation, and efficient string and byte handling. It integrates with other related skills for error handling, context propagation, struct/interface design, and security.
This skill is primarily targeted at Go developers, software architects, and AI coding agents working on Golang projects who seek guidance on idiomatic patterns and architectural best practices. It's suitable for teams aiming to implement resilient, maintainable systems or developers looking for advice on which Go design pattern fits a specific problem. Common use cases include choosing the right architectural pattern, designing constructor APIs with functional options, implementing graceful shutdown routines, applying resilience strategies, and reviewing existing code for design improvements.
FAQ
How do I invoke the `golang-design-patterns` skill?
The skill is user-invocable and can be accessed by AI coding agents like Claude Code or similar systems. It guides developers through design and review processes for Go code.
Which Go versions and environments is this skill compatible with?
It is designed for projects using Golang and requires the Go binary to be available. It is intended for use with AI coding agents that can interact with Go code.
Are there any prerequisites or tools needed?
Yes, the skill requires Go to be installed and supports tools such as Bash commands for Go, golangci-lint, and Git. It also allows using tools for reading, editing, writing, and searching code.
Does the skill handle error management and context propagation?
While it provides guidance on error handling patterns, it references other specialized skills for detailed error management (`golang-error-handling`) and context propagation (`golang-context`).
Can it review and refactor existing code?
Yes, in review mode the skill audits code for design issues, including improper use of `init()`, unbounded resources, missing timeouts, and implicit global state, before suggesting refactors.
Install golang-design-patterns
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
samber/cc-skills-golang