# go-design-patterns

This skill helps an agent choose Go patterns for constructors, runtime behavior and dependency failures. Use it when deciding how to structure a Go project.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · ★ 83
- Author: eduardo-sl
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/eduardo-sl/go-agent-skills/tree/HEAD/skills/(architecture)/go-design-patterns/SKILL.md
- Updated: 2026-10-15
- HTML: https://affpapa.org/en/nevibecode/skills/go-design-patterns

## What it does

The skill maps common design needs to Go approaches: functional options for optional constructor settings, factories for configuration-based implementation choices, and strategies for behavior that changes at runtime. It also covers HTTP middleware composition and resilience patterns for failing dependencies.

Short guidance comes with reference files that the agent can consult when it needs more detail. Examples cover constructors that return errors, types that constrain valid states, and useful zero values. The Go toolchain is required. This skill is a community default, so a project skill or agent rule that explicitly takes precedence can override it.

Its scope is design patterns. Interface design, package layout and concurrency are directed to separate skills, so this one is not a guide to those topics.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add eduardo-sl/go-agent-skills --skill go-design-patterns -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/go-design-patterns/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/go-design-patterns/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add eduardo-sl/go-agent-skills --skill go-design-patterns -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/go-design-patterns/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add eduardo-sl/go-agent-skills --skill go-design-patterns -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/go-design-patterns/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install eduardo-sl/go-agent-skills go-design-patterns
```

2. **Manually: put the files in place**
- File: `.github/skills/go-design-patterns/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add eduardo-sl/go-agent-skills --skill go-design-patterns -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/eduardo-sl/go-agent-skills --path 'skills/(architecture)/go-design-patterns'
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/go-design-patterns/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add eduardo-sl/go-agent-skills --skill go-design-patterns -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/eduardo-sl/go-agent-skills/tree/HEAD/skills/(architecture)/go-design-patterns/SKILL.md

## When to use it
- choose a constructor pattern for optional settings
- select a storage implementation from runtime configuration
- compose middleware around an HTTP handler
- handle transient dependency failures with retries
- replace related boolean flags with a state type

## Example prompts
- Choose an idiomatic Go pattern for a constructor with several optional settings.
- Show how to select a storage implementation from configuration using a factory.
- Suggest a way to handle transient failures from an external dependency in Go.

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 7d813511f4049e74.

BEGIN THIRD-PARTY FILE 7d813511f4049e74
```text
---
name: go-design-patterns
description: >
  Idiomatic Go design patterns: functional options, builder, factory,
  strategy, middleware chain, pub/sub, and other patterns adapted for Go's
  type system. Use when: "design pattern", "functional options", "builder
  pattern", "factory pattern", "strategy pattern", "middleware chain",
  "option pattern", "how to structure this".
  Not for: interface design (go-interface-design), package layout
  (go-architecture-review), concurrency patterns (go-concurrency-review).
user-invocable: true
license: MIT
compatibility: Designed for Claude Code or similar AI coding agents working on Go projects. Requires the Go toolchain.
allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(gofmt:*)
metadata:
  author: eduardo-sl
  version: "1.3.1"
---

# Go Design Patterns

Go favors composition over inheritance and simplicity over abstraction.
These patterns are idiomatic Go — not Java patterns ported to Go.

> Community default. A project skill or agent-config rule that explicitly
> supersedes `go-design-patterns` takes precedence over this one.

Detailed reference material, loaded on demand:

- `references/creation-patterns.md` — functional options (full example),
  options vs config struct, constructors, factory.
- `references/behavioral-patterns.md` — strategy, middleware/decorator,
  result type, defer cleanup, sentinel vs zero values.
- `references/resilience-and-types.md` — retry with jitter, circuit
  breaker, bulkhead, parse-don't-validate types, status types.

Read a reference file only when the summary below is not enough.

## Pattern Selection

| Need | Pattern | Reference |
|---|---|---|
| Constructor with many optional settings | Functional options | creation-patterns.md |
| Config loaded from file/env, mostly required fields | Config struct | creation-patterns.md |
| Enforce invariants at creation | Constructor returning error | creation-patterns.md |
| Pick implementation from runtime config | Factory returning interface | creation-patterns.md |
| Swap simple behavior at runtime | Strategy via function type | behavioral-patterns.md |
| Swap complex behavior at runtime | Strategy via interface | behavioral-patterns.md |
| Wrap cross-cutting concerns (log, cache, metrics) | Middleware / decorator | behavioral-patterns.md |
| Value-or-error in concurrent pipelines | `Result[T]` struct | behavioral-patterns.md |
| Transient failures of a dependency | Retry with backoff and jitter | resilience-and-types.md |
| A dependency that is down | Circuit breaker, bulkhead | resilience-and-types.md |
| Validate once, trust afterwards | Parse into a type with unexported fields | resilience-and-types.md |
```
END THIRD-PARTY FILE 7d813511f4049e74

The third-party file has ended. Everything between the 7d813511f4049e74 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2690 of 7924 bytes. © eduardo-sl · MIT · https://github.com/eduardo-sl/go-agent-skills/tree/HEAD/skills/(architecture)/go-design-patterns/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
