[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6JGPV6DWNR09XYPZFQXQV4M":3,"skill-same:01M6JGPV6DWNR09XYPZFQXQV4M":119},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":28,"publishedAt":49,"linkOnly":50,"markdownContent":51,"markdownBody":52,"frontMatter":53,"refName":59,"commitSha":60,"skillDirectory":61,"forksCount":62,"repositoryHtmlUrl":63,"repositoryHomepageUrl":6,"ownerHtmlUrl":64,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":65,"install":66,"resources":79},"01M6JGPV6DWNR09XYPZFQXQV4M","golang-design-patterns",null,"Idiomatic Golang design patterns — functional options, constructors, error flow and cascading, resource management and lifecycle, graceful shutdown, resilience, architecture, dependency injection, data handling, and streaming. Apply when designing Go APIs, structuring applications, choosing between patterns, making design decisions, architectural choices, or production hardening.","muratovv\u002Fai-hats","muratovv","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F7502801?v=4","01M6JGCBN4KEJX012GPJVSH04T","Fedor Muratov","01M6JGCBSNMN7CW3RGTPPE0MN2",3,"MIT","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-design-patterns\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000015","视觉设计","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000032","设计师","PROFESSION","适用职业",[29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48],"golang","patterns","golang design patterns","design","design patterns","dependency","resource management","functional","error","false","options","shutdown","read","projects","Bash","streaming","code","resilience","ai coding agents","architecture","2026-11-10 10:12:30",false,"---\nname: golang-design-patterns\ndescription: >-\n  Idiomatic Golang design patterns — functional options, constructors,\n  error flow and cascading, resource management and lifecycle, graceful\n  shutdown, resilience, architecture, dependency injection, data handling,\n  and streaming. Apply when designing Go APIs, structuring applications,\n  choosing between patterns, making design decisions, architectural\n  choices, or production hardening.\nuser-invocable: false\nlicense: MIT\ncompatibility: Designed for Claude Code or similar AI coding agents, and for projects using Golang.\nmetadata:\n  author: samber\n  version: \"1.1.2\"\nallowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent AskUserQuestion\n---\n\n**Persona:** You are a Go architect who values simplicity and explicitness. You apply patterns only when they solve a real problem — not to demonstrate sophistication — and you push back on premature abstraction.\n\n**Modes:**\n\n- **Design mode** — creating new APIs, packages, or application structure: ask the developer about their architecture preference before proposing patterns; favor the smallest pattern that satisfies the requirement.\n- **Review mode** — auditing existing code for design issues: scan for `init()` abuse, unbounded resources, missing timeouts, and implicit global state; report findings before suggesting refactors.\n\n> **Community default.** A company skill that explicitly supersedes `samber\u002Fcc-skills-golang@golang-design-patterns` skill takes precedence.\n\n# Go Design Patterns & Idioms\n\nIdiomatic Go patterns for production-ready code. For error handling details see the `samber\u002Fcc-skills-golang@golang-error-handling` skill; for context propagation see `samber\u002Fcc-skills-golang@golang-context` skill; for struct\u002Finterface design see `samber\u002Fcc-skills-golang@golang-structs-interfaces` skill.\n\n## Best Practices Summary\n\n1. Constructors SHOULD use **functional options** — they scale better as APIs evolve (one function per option, no breaking changes)\n2. Functional options MUST **return an error** if validation can fail — catch bad config at construction, not at runtime\n3. **Avoid `init()`** — runs implicitly, cannot return errors, makes testing unpredictable. Use explicit constructors\n4. Enums SHOULD **start at 1** (or Unknown sentinel at 0) — Go's zero value silently passes as the first enum member\n5. Error cases MUST be **handled first** with early return — keep happy path flat\n6. **Panic is for bugs, not expected errors** — callers can handle returned errors; panics crash the process\n7. **`defer Close()` immediately after opening** — later code changes can accidentally skip cleanup\n8. **`runtime.AddCleanup`** over `runtime.SetFinalizer` — finalizers are unpredictable and can resurrect objects\n9. Every external call SHOULD **have a timeout** — a slow upstream hangs your goroutine indefinitely\n10. **Limit everything** (pool sizes, queue depths, buffers) — unbounded resources grow until they crash\n11. Retry logic MUST **check context cancellation** between attempts\n12. **Use `strings.Builder`** for concatenation in loops → see `samber\u002Fcc-skills-golang@golang-code-style`\n13. string vs []byte: **use `[]byte` for mutation and I\u002FO**, `string` for display and keys — conversions allocate\n14. Iterators (Go 1.23+): **use for lazy evaluation** — avoid loading everything into memory\n15. **Stream large transfers** — loading millions of rows causes OOM; stream keeps memory constant\n16. `\u002F\u002Fgo:embed` for **static assets** — embeds at compile time, eliminates runtime file I\u002FO errors\n17. **Use `crypto\u002Frand`** for keys\u002Ftokens — `math\u002Frand` is predictable → see `samber\u002Fcc-skills-golang@golang-security`\n18. Regexp MUST be **compiled once at package level** — compilation is O(n) and allocates\n19. Compile-time interface checks: **`var _ Interface = (*Type)(nil)`**\n20. **A little recode > a big dependency** — each dep adds attack surface and maintenance burden\n21. **Design for testability** — accept interfaces, inject dependencies\n\n## Constructor Patterns: Functional Options vs Builder\n\n### Functional Options (Preferred)\n\n```go\ntype Server struct {\n    addr         string\n    readTimeout  time.Duration\n    writeTimeout time.Duration\n    maxConns     int\n}\n\ntype Option func(*Server)\n\nfunc WithReadTimeout(d time.Duration) Option {\n    return func(s *Server) { s.readTimeout = d }\n}\n\nfunc WithWriteTimeout(d time.Duration) Option {\n    return func(s *Server) { s.writeTimeout = d }\n}\n\nfunc WithMaxConns(n int) Option {\n    return func(s *Server) { s.maxConns = n }\n}\n\nfunc NewServer(addr string, opts ...Option) *Server {\n    \u002F\u002F Default options\n    s := &Server{\n        addr:         addr,\n        readTimeout:  5 * time.Second,\n        writeTimeout: 10 * time.Second,\n        maxConns:     100,\n    }\n    for _, opt := range opts {\n        opt(s)\n    }\n    return s\n}\n\n\u002F\u002F Usage\nsrv := NewServer(\":8080\",\n    WithReadTimeout(30*time.Second),\n    WithMaxConns(500),\n)\n```\n\nConstructors SHOULD use **functional options** — they scale better with API evolution and require less code. Use builder pattern only if you need complex validation between configuration steps.\n\n## Constructors & Initialization\n\n### Avoid `init()` and Mutable Globals\n\n`init()` runs implicitly, makes testing harder, and creates hidden dependencies:\n\n- Multiple `init()` functions run in declaration order, across files in **filename alphabetical order** — fragile\n- Cannot return errors — failures must panic or `log.Fatal`\n- Runs before `main()` and tests — side effects make tests unpredictable\n\n```go\n\u002F\u002F Bad — hidden global state\nvar db *sql.DB\n\nfunc init() {\n    var err error\n    db, err = sql.Open(\"postgres\", os.Getenv(\"DATABASE_URL\"))\n    if err != nil {\n        log.Fatal(err)\n    }\n}\n\n\u002F\u002F Good — explicit initialization, injectable\nfunc NewUserRepository(db *sql.DB) *UserRepository {\n    return &UserRepository{db: db}\n}\n```\n\n### Enums: Start at 1\n\nZero values should represent invalid\u002Funset state:\n\n```go\ntype Status int\n\nconst (\n    StatusUnknown Status = iota \u002F\u002F 0 = invalid\u002Funset\n    StatusActive                \u002F\u002F 1\n    StatusInactive              \u002F\u002F 2\n    StatusSuspended             \u002F\u002F 3\n)\n```\n\n### Compile Regexp Once\n\n```go\n\u002F\u002F Good — compiled once at package level\nvar emailRegex = regexp.MustCompile(`^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$`)\n\nfunc ValidateEmail(email string) bool {\n    return emailRegex.MatchString(email)\n}\n```\n\n### Use `\u002F\u002Fgo:embed` for Static Assets\n\n```go\nimport \"embed\"\n\n\u002F\u002Fgo:embed templates\u002F*\nvar templateFS embed.FS\n\n\u002F\u002Fgo:embed version.txt\nvar version string\n```\n\n### Compile-Time Interface Checks\n\n→ See `samber\u002Fcc-skills-golang@golang-structs-interfaces` for the `var _ Interface = (*Type)(nil)` pattern.\n\n## Error Flow Patterns\n\nError cases MUST be handled first with early return — keep the happy path at minimal indentation. → See `samber\u002Fcc-skills-golang@golang-code-style` for the full pattern and examples.\n\n### When to Panic vs Return Error\n\n- **Return error**: network failures, file not found, invalid input — anything a caller can handle\n- **Panic**: nil pointer in a place that should be impossible, violated invariant, `Must*` constructors used at init time\n- **`.Close()` errors**: acceptable to not check — `defer f.Close()` is fine without error handling\n\n## Data Handling\n\n### string vs []byte vs []rune\n\n| Type     | Default for | Use when                                            |\n| -------- | ----------- | --------------------------------------------------- |\n| `string` | Everything  | Immutable, safe, UTF-8                              |\n| `[]byte` | I\u002FO         | Writing to `io.Writer`, building strings, mutations |\n| `[]rune` | Unicode ops | `len()` must mean characters, not bytes             |\n\nAvoid repeated conversions — each one allocates. Stay in one type until you need the other.\n\n### Iterators & Streaming for Large Data\n\nUse iterators (Go 1.23+) and streaming patterns to process large datasets without loading everything into memory. For large transfers between services (e.g., 1M rows DB to HTTP), stream to prevent OOM.\n\nFor code examples, see [Data Handling Patterns](references\u002Fdata-handling.md).\n\n## Resource Management\n\n`defer Close()` immediately after opening — don't wait, don't forget:\n\n```go\nf, err := os.Open(path)\nif err != nil {\n    return err\n}\ndefer f.Close() \u002F\u002F right here, not 50 lines later\n\nrows, err := db.QueryContext(ctx, query)\nif err != nil {\n    return err\n}\ndefer rows.Close()\n```\n\nFor graceful shutdown, resource pools, and `runtime.AddCleanup`, see [Resource Management](references\u002Fresource-management.md).\n\n## Resilience & Limits\n\n### Timeout Every External Call\n\n```go\nctx, cancel := context.WithTimeout(ctx, 5*time.Second)\ndefer cancel()\n\nresp, err := httpClient.Do(req.WithContext(ctx))\n```\n\n### Retry & Context Checks\n\nRetry logic MUST check `ctx.Err()` between attempts and use exponential\u002Flinear backoff via `select` on `ctx.Done()`. Long loops MUST check `ctx.Err()` periodically. → See `samber\u002Fcc-skills-golang@golang-context` skill.\n\n## Database Patterns\n\n→ See `samber\u002Fcc-skills-golang@golang-database` skill for sqlx\u002Fpgx, transactions, nullable columns, connection pools, repository interfaces, testing.\n\n## Architecture\n\nAsk the developer which architecture they prefer: clean architecture, hexagonal, DDD, or flat layout. Don't impose complex architecture on a small project.\n\nCore principles regardless of architecture:\n\n- **Keep domain pure** — no framework dependencies in the domain layer\n- **Fail fast** — validate at boundaries, trust internal code\n- **Make illegal states unrepresentable** — use types to enforce invariants\n- **Respect 12-factor app** principles — → see `samber\u002Fcc-skills-golang@golang-project-layout`\n\n## Detailed Guides\n\n| Guide | Scope |\n| --- | --- |\n| [Architecture Patterns](references\u002Farchitecture.md) | High-level principles, when each architecture fits |\n| [Clean Architecture](references\u002Fclean-architecture.md) | Use cases, dependency rule, layered adapters |\n| [Hexagonal Architecture](references\u002Fhexagonal-architecture.md) | Ports and adapters, domain core isolation |\n| [Domain-Driven Design](references\u002Fddd.md) | Aggregates, value objects, bounded contexts |\n\n## Code Philosophy\n\n- **Avoid repetitive code** — but don't abstract prematurely\n- **Minimize dependencies** — a little recode > a big dependency\n- **Design for testability** — accept interfaces, inject dependencies, keep functions pure\n\n## Cross-References\n\n- → See `samber\u002Fcc-skills-golang@golang-data-structures` skill for data structure selection, internals, and container\u002F packages\n- → See `samber\u002Fcc-skills-golang@golang-error-handling` skill for error wrapping, sentinel errors, and the single handling rule\n- → See `samber\u002Fcc-skills-golang@golang-structs-interfaces` skill for interface design and composition\n- → See `samber\u002Fcc-skills-golang@golang-concurrency` skill for goroutine lifecycle and graceful shutdown\n- → See `samber\u002Fcc-skills-golang@golang-context` skill for timeout and cancellation patterns\n- → See `samber\u002Fcc-skills-golang@golang-project-layout` skill for architecture and directory structure\n","**Persona:** You are a Go architect who values simplicity and explicitness. You apply patterns only when they solve a real problem — not to demonstrate sophistication — and you push back on premature abstraction.\n\n**Modes:**\n\n- **Design mode** — creating new APIs, packages, or application structure: ask the developer about their architecture preference before proposing patterns; favor the smallest pattern that satisfies the requirement.\n- **Review mode** — auditing existing code for design issues: scan for `init()` abuse, unbounded resources, missing timeouts, and implicit global state; report findings before suggesting refactors.\n\n> **Community default.** A company skill that explicitly supersedes `samber\u002Fcc-skills-golang@golang-design-patterns` skill takes precedence.\n\n# Go Design Patterns & Idioms\n\nIdiomatic Go patterns for production-ready code. For error handling details see the `samber\u002Fcc-skills-golang@golang-error-handling` skill; for context propagation see `samber\u002Fcc-skills-golang@golang-context` skill; for struct\u002Finterface design see `samber\u002Fcc-skills-golang@golang-structs-interfaces` skill.\n\n## Best Practices Summary\n\n1. Constructors SHOULD use **functional options** — they scale better as APIs evolve (one function per option, no breaking changes)\n2. Functional options MUST **return an error** if validation can fail — catch bad config at construction, not at runtime\n3. **Avoid `init()`** — runs implicitly, cannot return errors, makes testing unpredictable. Use explicit constructors\n4. Enums SHOULD **start at 1** (or Unknown sentinel at 0) — Go's zero value silently passes as the first enum member\n5. Error cases MUST be **handled first** with early return — keep happy path flat\n6. **Panic is for bugs, not expected errors** — callers can handle returned errors; panics crash the process\n7. **`defer Close()` immediately after opening** — later code changes can accidentally skip cleanup\n8. **`runtime.AddCleanup`** over `runtime.SetFinalizer` — finalizers are unpredictable and can resurrect objects\n9. Every external call SHOULD **have a timeout** — a slow upstream hangs your goroutine indefinitely\n10. **Limit everything** (pool sizes, queue depths, buffers) — unbounded resources grow until they crash\n11. Retry logic MUST **check context cancellation** between attempts\n12. **Use `strings.Builder`** for concatenation in loops → see `samber\u002Fcc-skills-golang@golang-code-style`\n13. string vs []byte: **use `[]byte` for mutation and I\u002FO**, `string` for display and keys — conversions allocate\n14. Iterators (Go 1.23+): **use for lazy evaluation** — avoid loading everything into memory\n15. **Stream large transfers** — loading millions of rows causes OOM; stream keeps memory constant\n16. `\u002F\u002Fgo:embed` for **static assets** — embeds at compile time, eliminates runtime file I\u002FO errors\n17. **Use `crypto\u002Frand`** for keys\u002Ftokens — `math\u002Frand` is predictable → see `samber\u002Fcc-skills-golang@golang-security`\n18. Regexp MUST be **compiled once at package level** — compilation is O(n) and allocates\n19. Compile-time interface checks: **`var _ Interface = (*Type)(nil)`**\n20. **A little recode > a big dependency** — each dep adds attack surface and maintenance burden\n21. **Design for testability** — accept interfaces, inject dependencies\n\n## Constructor Patterns: Functional Options vs Builder\n\n### Functional Options (Preferred)\n\n```go\ntype Server struct {\n    addr         string\n    readTimeout  time.Duration\n    writeTimeout time.Duration\n    maxConns     int\n}\n\ntype Option func(*Server)\n\nfunc WithReadTimeout(d time.Duration) Option {\n    return func(s *Server) { s.readTimeout = d }\n}\n\nfunc WithWriteTimeout(d time.Duration) Option {\n    return func(s *Server) { s.writeTimeout = d }\n}\n\nfunc WithMaxConns(n int) Option {\n    return func(s *Server) { s.maxConns = n }\n}\n\nfunc NewServer(addr string, opts ...Option) *Server {\n    \u002F\u002F Default options\n    s := &Server{\n        addr:         addr,\n        readTimeout:  5 * time.Second,\n        writeTimeout: 10 * time.Second,\n        maxConns:     100,\n    }\n    for _, opt := range opts {\n        opt(s)\n    }\n    return s\n}\n\n\u002F\u002F Usage\nsrv := NewServer(\":8080\",\n    WithReadTimeout(30*time.Second),\n    WithMaxConns(500),\n)\n```\n\nConstructors SHOULD use **functional options** — they scale better with API evolution and require less code. Use builder pattern only if you need complex validation between configuration steps.\n\n## Constructors & Initialization\n\n### Avoid `init()` and Mutable Globals\n\n`init()` runs implicitly, makes testing harder, and creates hidden dependencies:\n\n- Multiple `init()` functions run in declaration order, across files in **filename alphabetical order** — fragile\n- Cannot return errors — failures must panic or `log.Fatal`\n- Runs before `main()` and tests — side effects make tests unpredictable\n\n```go\n\u002F\u002F Bad — hidden global state\nvar db *sql.DB\n\nfunc init() {\n    var err error\n    db, err = sql.Open(\"postgres\", os.Getenv(\"DATABASE_URL\"))\n    if err != nil {\n        log.Fatal(err)\n    }\n}\n\n\u002F\u002F Good — explicit initialization, injectable\nfunc NewUserRepository(db *sql.DB) *UserRepository {\n    return &UserRepository{db: db}\n}\n```\n\n### Enums: Start at 1\n\nZero values should represent invalid\u002Funset state:\n\n```go\ntype Status int\n\nconst (\n    StatusUnknown Status = iota \u002F\u002F 0 = invalid\u002Funset\n    StatusActive                \u002F\u002F 1\n    StatusInactive              \u002F\u002F 2\n    StatusSuspended             \u002F\u002F 3\n)\n```\n\n### Compile Regexp Once\n\n```go\n\u002F\u002F Good — compiled once at package level\nvar emailRegex = regexp.MustCompile(`^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$`)\n\nfunc ValidateEmail(email string) bool {\n    return emailRegex.MatchString(email)\n}\n```\n\n### Use `\u002F\u002Fgo:embed` for Static Assets\n\n```go\nimport \"embed\"\n\n\u002F\u002Fgo:embed templates\u002F*\nvar templateFS embed.FS\n\n\u002F\u002Fgo:embed version.txt\nvar version string\n```\n\n### Compile-Time Interface Checks\n\n→ See `samber\u002Fcc-skills-golang@golang-structs-interfaces` for the `var _ Interface = (*Type)(nil)` pattern.\n\n## Error Flow Patterns\n\nError cases MUST be handled first with early return — keep the happy path at minimal indentation. → See `samber\u002Fcc-skills-golang@golang-code-style` for the full pattern and examples.\n\n### When to Panic vs Return Error\n\n- **Return error**: network failures, file not found, invalid input — anything a caller can handle\n- **Panic**: nil pointer in a place that should be impossible, violated invariant, `Must*` constructors used at init time\n- **`.Close()` errors**: acceptable to not check — `defer f.Close()` is fine without error handling\n\n## Data Handling\n\n### string vs []byte vs []rune\n\n| Type     | Default for | Use when                                            |\n| -------- | ----------- | --------------------------------------------------- |\n| `string` | Everything  | Immutable, safe, UTF-8                              |\n| `[]byte` | I\u002FO         | Writing to `io.Writer`, building strings, mutations |\n| `[]rune` | Unicode ops | `len()` must mean characters, not bytes             |\n\nAvoid repeated conversions — each one allocates. Stay in one type until you need the other.\n\n### Iterators & Streaming for Large Data\n\nUse iterators (Go 1.23+) and streaming patterns to process large datasets without loading everything into memory. For large transfers between services (e.g., 1M rows DB to HTTP), stream to prevent OOM.\n\nFor code examples, see [Data Handling Patterns](references\u002Fdata-handling.md).\n\n## Resource Management\n\n`defer Close()` immediately after opening — don't wait, don't forget:\n\n```go\nf, err := os.Open(path)\nif err != nil {\n    return err\n}\ndefer f.Close() \u002F\u002F right here, not 50 lines later\n\nrows, err := db.QueryContext(ctx, query)\nif err != nil {\n    return err\n}\ndefer rows.Close()\n```\n\nFor graceful shutdown, resource pools, and `runtime.AddCleanup`, see [Resource Management](references\u002Fresource-management.md).\n\n## Resilience & Limits\n\n### Timeout Every External Call\n\n```go\nctx, cancel := context.WithTimeout(ctx, 5*time.Second)\ndefer cancel()\n\nresp, err := httpClient.Do(req.WithContext(ctx))\n```\n\n### Retry & Context Checks\n\nRetry logic MUST check `ctx.Err()` between attempts and use exponential\u002Flinear backoff via `select` on `ctx.Done()`. Long loops MUST check `ctx.Err()` periodically. → See `samber\u002Fcc-skills-golang@golang-context` skill.\n\n## Database Patterns\n\n→ See `samber\u002Fcc-skills-golang@golang-database` skill for sqlx\u002Fpgx, transactions, nullable columns, connection pools, repository interfaces, testing.\n\n## Architecture\n\nAsk the developer which architecture they prefer: clean architecture, hexagonal, DDD, or flat layout. Don't impose complex architecture on a small project.\n\nCore principles regardless of architecture:\n\n- **Keep domain pure** — no framework dependencies in the domain layer\n- **Fail fast** — validate at boundaries, trust internal code\n- **Make illegal states unrepresentable** — use types to enforce invariants\n- **Respect 12-factor app** principles — → see `samber\u002Fcc-skills-golang@golang-project-layout`\n\n## Detailed Guides\n\n| Guide | Scope |\n| --- | --- |\n| [Architecture Patterns](references\u002Farchitecture.md) | High-level principles, when each architecture fits |\n| [Clean Architecture](references\u002Fclean-architecture.md) | Use cases, dependency rule, layered adapters |\n| [Hexagonal Architecture](references\u002Fhexagonal-architecture.md) | Ports and adapters, domain core isolation |\n| [Domain-Driven Design](references\u002Fddd.md) | Aggregates, value objects, bounded contexts |\n\n## Code Philosophy\n\n- **Avoid repetitive code** — but don't abstract prematurely\n- **Minimize dependencies** — a little recode > a big dependency\n- **Design for testability** — accept interfaces, inject dependencies, keep functions pure\n\n## Cross-References\n\n- → See `samber\u002Fcc-skills-golang@golang-data-structures` skill for data structure selection, internals, and container\u002F packages\n- → See `samber\u002Fcc-skills-golang@golang-error-handling` skill for error wrapping, sentinel errors, and the single handling rule\n- → See `samber\u002Fcc-skills-golang@golang-structs-interfaces` skill for interface design and composition\n- → See `samber\u002Fcc-skills-golang@golang-concurrency` skill for goroutine lifecycle and graceful shutdown\n- → See `samber\u002Fcc-skills-golang@golang-context` skill for timeout and cancellation patterns\n- → See `samber\u002Fcc-skills-golang@golang-project-layout` skill for architecture and directory structure\n",{"name":5,"license":15,"metadata":54,"description":7,"allowed-tools":57,"compatibility":58,"user-invocable":50},{"author":55,"version":56},"samber","1.1.2","Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent AskUserQuestion","Designed for Claude Code or similar AI coding agents, and for projects using Golang.","master","b4819add93efbaf4d80627118ec34680406b309b","packages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-design-patterns",1,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats","https:\u002F\u002Fgithub.com\u002Fmuratovv","2026-11-05 20:59:10",{"source":8,"skillName":5,"commands":67,"prompt":77,"zipAvailable":78},[68,71,74],{"tool":69,"command":70},"npx","npx skills add muratovv\u002Fai-hats --skill golang-design-patterns",{"tool":72,"command":73},"bunx","bunx skills add muratovv\u002Fai-hats --skill golang-design-patterns",{"tool":75,"command":76},"pnpm","pnpm dlx skills add muratovv\u002Fai-hats --skill golang-design-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-design-patterns\u002FSKILL.md",true,[80,86,91,95,99,103,107,111,115],{"path":81,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":84,"sourceHtmlUrl":85},"evals\u002Fevals.json","REFERENCE","参考文档",20756,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-design-patterns\u002Fevals\u002Fevals.json",{"path":87,"resourceType":87,"resourceTypeDesc":88,"sizeBytes":89,"sourceHtmlUrl":90},"LICENSE","许可证",1070,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-design-patterns\u002FLICENSE",{"path":92,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":93,"sourceHtmlUrl":94},"metadata.yaml",672,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-design-patterns\u002Fmetadata.yaml",{"path":96,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":97,"sourceHtmlUrl":98},"references\u002Farchitecture.md",4786,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-design-patterns\u002Freferences\u002Farchitecture.md",{"path":100,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":101,"sourceHtmlUrl":102},"references\u002Fclean-architecture.md",5127,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-design-patterns\u002Freferences\u002Fclean-architecture.md",{"path":104,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":105,"sourceHtmlUrl":106},"references\u002Fdata-handling.md",1667,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-design-patterns\u002Freferences\u002Fdata-handling.md",{"path":108,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":109,"sourceHtmlUrl":110},"references\u002Fddd.md",6916,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-design-patterns\u002Freferences\u002Fddd.md",{"path":112,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":113,"sourceHtmlUrl":114},"references\u002Fhexagonal-architecture.md",6180,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-design-patterns\u002Freferences\u002Fhexagonal-architecture.md",{"path":116,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":117,"sourceHtmlUrl":118},"references\u002Fresource-management.md",4119,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-design-patterns\u002Freferences\u002Fresource-management.md",[120,146,170,191,215,229],{"skillNo":121,"name":122,"nameZh":6,"description":123,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":126,"publishedAt":49},"01M6PVFB1SM738R2SRSRSF7CY6","tool-evaluation-protocol","Time-bounded protocol for evaluating new tools, libraries, or methodologies before adoption. Use when evaluating a candidate dependency for the project, researching a methodology (e.g. ML\u002FLLM frameworks, testing approaches), or following up on a hype-driven recommendation.","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fexperimental\u002Fusage\u002Fskills\u002Ftool-evaluation-protocol\u002FSKILL.md",[],[127,128,129,130,131,132,133,134,135,136,137,34,138,139,140,141,142,143,144,145],"protocol","Evaluation","tool","tool evaluation protocol","testing","ml","libraries","adoption","methodology","Tools","use","up","frameworks","time","project","recommendation","for","bounded","candidate",{"skillNo":147,"name":148,"nameZh":6,"description":149,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":150,"categories":151,"keywords":152,"publishedAt":49},"01M6PVF7HATBEX1G7N50E2QT57","systematic-debugging","4-phase bug-fix protocol (evidence, pattern, hypothesis, verify). Use when investigating any error, failure, or unexpected behavior, handling bug reports from users or monitoring, or diagnosing test failures with non-obvious causes.","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fexperimental\u002Fusage\u002Fskills\u002Fsystematic-debugging\u002FSKILL.md",[],[153,154,155,156,127,157,158,159,160,161,137,162,163,164,165,166,37,167,168,169],"systematic debugging","debugging","systematic","test","monitoring","hypothesis","verify","behavior","fix","evidence","bug","reports","pattern","users","with","bug-fix","phase",{"skillNo":171,"name":172,"nameZh":6,"description":173,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":174,"categories":175,"keywords":179,"publishedAt":49},"01M6PVF3MTQN3RPF73AN34856J","skill-template","Canonical template and validation guide for ai-hats skills. Use when creating a new skill, reviewing an existing one for structural compliance, or deciding which pattern fits a new behavior.","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fexperimental\u002Fusage\u002Fskills\u002Fskill-template\u002FSKILL.md",[176],{"categoryNo":177,"categoryName":178,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[180,181,182,183,184,160,185,137,186,165,187,188,189,143,190],"template","skill template","validation","compliance","hats","guide","new skill","structural","canonical","which","Existing",{"skillNo":192,"name":193,"nameZh":6,"description":194,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":195,"categories":196,"keywords":198,"publishedAt":49},"01M6PVF06SCV28QARM5MQPANC9","skill-optimization","Audit and refactor library components to eliminate redundancy and staleness. Use during periodic library maintenance, after adding multiple new skills or rules, when a role's token budget is too high, or after retrospectives identify component issues.","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fexperimental\u002Fusage\u002Fskills\u002Fskill-optimization\u002FSKILL.md",[197],{"categoryNo":177,"categoryName":178,"taxonomyType":21,"taxonomyTypeDesc":22},[199,200,201,202,203,204,205,206,207,208,137,209,210,211,212,213,214],"Optimization","skill optimization","components","component","issues","library","audit","refactor","Budget","Rules","periodic","maintenance","token","token budget","role","high",{"skillNo":216,"name":217,"nameZh":6,"description":218,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":219,"categories":220,"keywords":221,"publishedAt":49},"01M6PVEXM9717016T9MW82HDCT","silent-fallback-gate","PreToolUse hook — refuses an Edit or Write that adds an inert broad except. Use when a Python edit was blocked for a silent fallback.","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fexperimental\u002Fusage\u002Fskills\u002Fsilent-fallback-gate\u002FSKILL.md",[],[222,223,224,225,226,227,137,228,143],"gate","fallback","silent fallback gate","python","write","edit","hook",{"skillNo":230,"name":231,"nameZh":6,"description":232,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":233,"categories":234,"keywords":236,"publishedAt":49},"01M6PVESM49C5NT7SB7N3F76VS","retro-to-framework","Convert an observation about agent behavior — from a retrospective or from a single incident — into a framework-level change (hook, rule, skill, skill update). Use after a retrospective identifies problems that are not project-specific, after an incident where an agent misapplied a component it had read, when CLAUDE.md band-aids accumulate (more than 3 per-project rules that could be generic), or when the same problem recurs across multiple projects.","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fexperimental\u002Fusage\u002Fskills\u002Fretro-to-framework\u002FSKILL.md",[235],{"categoryNo":177,"categoryName":178,"taxonomyType":21,"taxonomyTypeDesc":22},[237,238,239,240,202,241,42,242,208,160,137,243,244,141,245,246,247,248,249,250],"framework","retro","retro to framework","change","retrospective","convert","incident","across","problem","about","more","skill update","single","generic"]