[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79Z6P77M0EW42WHGQNQT4D7":3,"skill-same:01M79Z6P77M0EW42WHGQNQT4D7":62},{"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":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":31,"commitSha":32,"skillDirectory":33,"forksCount":14,"repositoryHtmlUrl":34,"repositoryHomepageUrl":6,"ownerHtmlUrl":35,"ownerBlogUrl":36,"ownerDescription":37,"updatedAt":38,"install":39,"resources":51},"01M79Z6P77M0EW42WHGQNQT4D7","go-design-patterns",null,"Idiomatic Go design patterns: functional options, builder, factory, strategy, middleware chain, pub\u002Fsub, 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).","kongnakornna\u002Fgolangapi","kongnakornna","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F10528904?v=4","01M79Z5JQPPV5CWQHXS235Q9MD","Kongnakorn Jantakun","01M79Z5JRHJJJ6PR2DGQS4P985",0,"MIT","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(architecture)\u002Fgo-design-patterns\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: go-design-patterns\ndescription: >\n  Idiomatic Go design patterns: functional options, builder, factory,\n  strategy, middleware chain, pub\u002Fsub, and other patterns adapted for Go's\n  type system. Use when: \"design pattern\", \"functional options\", \"builder\n  pattern\", \"factory pattern\", \"strategy pattern\", \"middleware chain\",\n  \"option pattern\", \"how to structure this\".\n  Not for: interface design (go-interface-design), package layout\n  (go-architecture-review), concurrency patterns (go-concurrency-review).\nuser-invocable: true\nlicense: MIT\ncompatibility: Designed for Claude Code or similar AI coding agents working on Go projects. Requires the Go toolchain.\nallowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(gofmt:*)\nmetadata:\n  author: eduardo-sl\n  version: \"1.2.1\"\n---\n\n# Go Design Patterns\n\nGo favors composition over inheritance and simplicity over abstraction.\nThese patterns are idiomatic Go — not Java patterns ported to Go.\n\nDetailed reference material, loaded on demand:\n\n- `references\u002Fcreation-patterns.md` — functional options (full example),\n  options vs config struct, constructors, factory.\n- `references\u002Fbehavioral-patterns.md` — strategy, middleware\u002Fdecorator,\n  result type, defer cleanup, sentinel vs zero values.\n\nRead a reference file only when the summary below is not enough.\n\n## Pattern Selection\n\n| Need | Pattern | Reference |\n|---|---|---|\n| Constructor with many optional settings | Functional options | creation-patterns.md |\n| Config loaded from file\u002Fenv, mostly required fields | Config struct | creation-patterns.md |\n| Enforce invariants at creation | Constructor returning error | creation-patterns.md |\n| Pick implementation from runtime config | Factory returning interface | creation-patterns.md |\n| Swap simple behavior at runtime | Strategy via function type | behavioral-patterns.md |\n| Swap complex behavior at runtime | Strategy via interface | behavioral-patterns.md |\n| Wrap cross-cutting concerns (log, cache, metrics) | Middleware \u002F decorator | behavioral-patterns.md |\n| Value-or-error in concurrent pipelines | `Result[T]` struct | behavioral-patterns.md |\n\n## 1. Functional Options (essentials)\n\n```go\ntype Option func(*Server)\n\nfunc WithAddr(addr string) Option {\n    return func(s *Server) { s.addr = addr }\n}\n\nfunc NewServer(opts ...Option) *Server {\n    s := &Server{\n        addr:        \":8080\", \u002F\u002F sensible defaults first\n        readTimeout: 5 * time.Second,\n        logger:      slog.Default(),\n    }\n    for _, opt := range opts {\n        opt(s)\n    }\n    return s\n}\n\nsrv := NewServer(WithAddr(\":9090\"))\n```\n\nUse when: many optional parameters with sensible defaults, API evolves over\ntime (new options don't break callers), options need validation.\nUse a plain config struct instead when most fields are required or the\nconfiguration is deserialized from file\u002Fenv.\n\n## 2. Constructor Rules\n\n- Every exported type with invariants needs a constructor.\n- Validate required dependencies; return an error, don't panic:\n\n```go\n\u002F\u002F ✅ Good — constructor enforces invariants\nfunc NewUserService(repo UserRepository, logger *slog.Logger) (*UserService, error) {\n    if repo == nil {\n        return nil, errors.New(\"user service: nil repository\")\n    }\n    return &UserService{repo: repo, logger: logger}, nil\n}\n\n\u002F\u002F ❌ Bad — struct literal with no validation\nsvc := &UserService{} \u002F\u002F nil dependencies → panic at runtime\n```\n\n## 3. Factory\n\nReturn the interface, not a concrete type. The factory is the only place\nthat knows about concrete implementations:\n\n```go\nfunc NewStore(cfg Config) (Store, error) {\n    switch cfg.StoreType {\n    case \"redis\":\n        return newRedisStore(cfg.RedisAddr)\n    case \"memory\":\n        return newMemoryStore(), nil\n    default:\n        return nil, fmt.Errorf(\"unknown store type: %s\", cfg.StoreType)\n    }\n}\n```\n\n## 4. Middleware Chain\n\nThe standard HTTP composition pattern:\n\n```go\ntype Middleware func(http.Handler) http.Handler\n\nfunc Chain(handler http.Handler, middlewares ...Middleware) http.Handler {\n    for i := len(middlewares) - 1; i >= 0; i-- {\n        handler = middlewares[i](handler)\n    }\n    return handler\n}\n\nhandler := Chain(appHandler, Recoverer, RequestID, Logger, Auth)\n```\n\nThe same shape works for any interface: stack decorators as\n`cache → logging → metrics → actual repo`\n(see `references\u002Fbehavioral-patterns.md`).\n\n## 5. Zero Values First\n\nPrefer types whose zero value is useful (`sync.Mutex`, `bytes.Buffer`,\nnil slices). Reach for sentinel wrappers or pointers only when the zero\nvalue is ambiguous as an input (`nil *float64` = \"not configured\").\n\n## Anti-Patterns to Avoid\n\n```go\n\u002F\u002F ❌ God interface — too many methods\ntype Service interface {\n    GetUser(ctx context.Context, id string) (*User, error)\n    CreateUser(ctx context.Context, u *User) error\n    DeleteUser(ctx context.Context, id string) error\n    ListOrders(ctx context.Context, userID string) ([]Order, error)\n    \u002F\u002F 20 more methods...\n}\n\u002F\u002F → Split into focused interfaces: UserReader, UserWriter, OrderLister\n\n\u002F\u002F ❌ Premature abstraction — interface for one implementation\ntype UserCache interface {\n    Get(key string) (*User, bool)\n    Set(key string, user *User)\n}\n\u002F\u002F If there's only ever one implementation, use the concrete type.\n\u002F\u002F Extract an interface when a second consumer or implementation appears.\n\n\u002F\u002F ❌ Java-style inheritance simulation\ntype BaseService struct{ \u002F* ... *\u002F }\ntype UserService struct{ BaseService } \u002F\u002F embedding is NOT inheritance\n\u002F\u002F → Use composition: UserService has a dependency, not a parent.\n```\n\n## Verification Checklist\n\n1. Functional options used for types with optional configuration\n2. Constructors validate required dependencies and return errors\n3. Factory functions return interfaces, not concrete types\n4. No god interfaces — each interface has 1-3 methods\n5. Middleware follows `func(http.Handler) http.Handler` signature\n6. Decorators wrap interfaces, not concrete types\n7. `defer` used for all resource cleanup (files, connections, locks)\n8. Zero values are meaningful — no unnecessary initialization\n9. No premature abstractions — interfaces extracted only when needed\n10. Composition used instead of embedding for code reuse\n","# Go Design Patterns\n\nGo favors composition over inheritance and simplicity over abstraction.\nThese patterns are idiomatic Go — not Java patterns ported to Go.\n\nDetailed reference material, loaded on demand:\n\n- `references\u002Fcreation-patterns.md` — functional options (full example),\n  options vs config struct, constructors, factory.\n- `references\u002Fbehavioral-patterns.md` — strategy, middleware\u002Fdecorator,\n  result type, defer cleanup, sentinel vs zero values.\n\nRead a reference file only when the summary below is not enough.\n\n## Pattern Selection\n\n| Need | Pattern | Reference |\n|---|---|---|\n| Constructor with many optional settings | Functional options | creation-patterns.md |\n| Config loaded from file\u002Fenv, mostly required fields | Config struct | creation-patterns.md |\n| Enforce invariants at creation | Constructor returning error | creation-patterns.md |\n| Pick implementation from runtime config | Factory returning interface | creation-patterns.md |\n| Swap simple behavior at runtime | Strategy via function type | behavioral-patterns.md |\n| Swap complex behavior at runtime | Strategy via interface | behavioral-patterns.md |\n| Wrap cross-cutting concerns (log, cache, metrics) | Middleware \u002F decorator | behavioral-patterns.md |\n| Value-or-error in concurrent pipelines | `Result[T]` struct | behavioral-patterns.md |\n\n## 1. Functional Options (essentials)\n\n```go\ntype Option func(*Server)\n\nfunc WithAddr(addr string) Option {\n    return func(s *Server) { s.addr = addr }\n}\n\nfunc NewServer(opts ...Option) *Server {\n    s := &Server{\n        addr:        \":8080\", \u002F\u002F sensible defaults first\n        readTimeout: 5 * time.Second,\n        logger:      slog.Default(),\n    }\n    for _, opt := range opts {\n        opt(s)\n    }\n    return s\n}\n\nsrv := NewServer(WithAddr(\":9090\"))\n```\n\nUse when: many optional parameters with sensible defaults, API evolves over\ntime (new options don't break callers), options need validation.\nUse a plain config struct instead when most fields are required or the\nconfiguration is deserialized from file\u002Fenv.\n\n## 2. Constructor Rules\n\n- Every exported type with invariants needs a constructor.\n- Validate required dependencies; return an error, don't panic:\n\n```go\n\u002F\u002F ✅ Good — constructor enforces invariants\nfunc NewUserService(repo UserRepository, logger *slog.Logger) (*UserService, error) {\n    if repo == nil {\n        return nil, errors.New(\"user service: nil repository\")\n    }\n    return &UserService{repo: repo, logger: logger}, nil\n}\n\n\u002F\u002F ❌ Bad — struct literal with no validation\nsvc := &UserService{} \u002F\u002F nil dependencies → panic at runtime\n```\n\n## 3. Factory\n\nReturn the interface, not a concrete type. The factory is the only place\nthat knows about concrete implementations:\n\n```go\nfunc NewStore(cfg Config) (Store, error) {\n    switch cfg.StoreType {\n    case \"redis\":\n        return newRedisStore(cfg.RedisAddr)\n    case \"memory\":\n        return newMemoryStore(), nil\n    default:\n        return nil, fmt.Errorf(\"unknown store type: %s\", cfg.StoreType)\n    }\n}\n```\n\n## 4. Middleware Chain\n\nThe standard HTTP composition pattern:\n\n```go\ntype Middleware func(http.Handler) http.Handler\n\nfunc Chain(handler http.Handler, middlewares ...Middleware) http.Handler {\n    for i := len(middlewares) - 1; i >= 0; i-- {\n        handler = middlewares[i](handler)\n    }\n    return handler\n}\n\nhandler := Chain(appHandler, Recoverer, RequestID, Logger, Auth)\n```\n\nThe same shape works for any interface: stack decorators as\n`cache → logging → metrics → actual repo`\n(see `references\u002Fbehavioral-patterns.md`).\n\n## 5. Zero Values First\n\nPrefer types whose zero value is useful (`sync.Mutex`, `bytes.Buffer`,\nnil slices). Reach for sentinel wrappers or pointers only when the zero\nvalue is ambiguous as an input (`nil *float64` = \"not configured\").\n\n## Anti-Patterns to Avoid\n\n```go\n\u002F\u002F ❌ God interface — too many methods\ntype Service interface {\n    GetUser(ctx context.Context, id string) (*User, error)\n    CreateUser(ctx context.Context, u *User) error\n    DeleteUser(ctx context.Context, id string) error\n    ListOrders(ctx context.Context, userID string) ([]Order, error)\n    \u002F\u002F 20 more methods...\n}\n\u002F\u002F → Split into focused interfaces: UserReader, UserWriter, OrderLister\n\n\u002F\u002F ❌ Premature abstraction — interface for one implementation\ntype UserCache interface {\n    Get(key string) (*User, bool)\n    Set(key string, user *User)\n}\n\u002F\u002F If there's only ever one implementation, use the concrete type.\n\u002F\u002F Extract an interface when a second consumer or implementation appears.\n\n\u002F\u002F ❌ Java-style inheritance simulation\ntype BaseService struct{ \u002F* ... *\u002F }\ntype UserService struct{ BaseService } \u002F\u002F embedding is NOT inheritance\n\u002F\u002F → Use composition: UserService has a dependency, not a parent.\n```\n\n## Verification Checklist\n\n1. Functional options used for types with optional configuration\n2. Constructors validate required dependencies and return errors\n3. Factory functions return interfaces, not concrete types\n4. No god interfaces — each interface has 1-3 methods\n5. Middleware follows `func(http.Handler) http.Handler` signature\n6. Decorators wrap interfaces, not concrete types\n7. `defer` used for all resource cleanup (files, connections, locks)\n8. Zero values are meaningful — no unnecessary initialization\n9. No premature abstractions — interfaces extracted only when needed\n10. Composition used instead of embedding for code reuse\n",{"name":5,"license":15,"metadata":24,"description":27,"allowed-tools":28,"compatibility":29,"user-invocable":30},{"author":25,"version":26},"eduardo-sl","1.2.1","Idiomatic Go design patterns: functional options, builder, factory, strategy, middleware chain, pub\u002Fsub, 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).\n","Read Edit Write Glob Grep Bash(go:*) Bash(gofmt:*)","Designed for Claude Code or similar AI coding agents working on Go projects. Requires the Go toolchain.",true,"main","19f4d52a98d557f3a645a2cfbbeb5bd54f28831d",".github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(architecture)\u002Fgo-design-patterns","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi","https:\u002F\u002Fgithub.com\u002Fkongnakornna","http:\u002F\u002Fcmoniot.trueddns.com:52160","Technical Skills and Expertise\r\nLanguages and Frameworks\r\nFrontend: HTML, JavaScript, TypeScript, React, Vue, Angular, Next.js\r\nBackend: Node.js,Python,Golang","2026-10-06 23:01:46",{"source":8,"skillName":5,"commands":40,"prompt":50,"zipAvailable":30},[41,44,47],{"tool":42,"command":43},"npx","npx skills add kongnakornna\u002Fgolangapi --skill go-design-patterns",{"tool":45,"command":46},"bunx","bunx skills add kongnakornna\u002Fgolangapi --skill go-design-patterns",{"tool":48,"command":49},"pnpm","pnpm dlx skills add kongnakornna\u002Fgolangapi --skill go-design-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(architecture)\u002Fgo-design-patterns\u002FSKILL.md",[52,58],{"path":53,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":56,"sourceHtmlUrl":57},"references\u002Fbehavioral-patterns.md","REFERENCE","参考文档",4425,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(architecture)\u002Fgo-design-patterns\u002Freferences\u002Fbehavioral-patterns.md",{"path":59,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":60,"sourceHtmlUrl":61},"references\u002Fcreation-patterns.md",3189,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(architecture)\u002Fgo-design-patterns\u002Freferences\u002Fcreation-patterns.md",[63,71,78,85,92,99],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M7A0M9RJJ3383VEFYKABWV15","tb-writing-plans","Use when you have a spec or requirements for a multi-step task, before touching code","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-writing-plans\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7A0M4JKY4DEDRP1CBHT00WV","tb-using-git-worktrees","Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-using-git-worktrees\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7A0KZ5HRAQAAT2KXR6146Q7","tb-test-driven-development","Use when implementing any feature or bugfix, before writing implementation code","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-test-driven-development\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M7A0KW92W3F18E2MRP8H62P2","tb-subagent-driven-development","Use when executing implementation plans with independent tasks in the current session","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-subagent-driven-development\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":19},"01M7A0KKYQCHYYRHA5J5BAP24M","tb-scrutinize","Outsider-perspective end-to-end review of a plan, PR, or code change. First questions intent and whether a simpler\u002Fmore elegant approach would achieve the same goal, then traces the actual code path (not just the diff) to verify the change does what it claims. Output is concise, actionable, and every call carries its rationale. Trigger on \u002Ftb-scrutinize and proactively whenever the user asks to review, audit, sanity-check, or get a second opinion on a plan, PR, diff, design doc, or proposed code change.","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-scrutinize\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":19},"01M7A0KFDR1V3RW7SW1XNHP82P","tb-requesting-code-review","Use when completing tasks, implementing major features, or before merging to verify work meets requirements","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-requesting-code-review\u002FSKILL.md",[],[]]