[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79ZXDTK8NN49XZ6CPJAC9KG":3,"skill-same:01M79ZXDTK8NN49XZ6CPJAC9KG":67},{"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":25,"commitSha":26,"skillDirectory":27,"forksCount":14,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M79ZXDTK8NN49XZ6CPJAC9KG","go-interfaces",null,"Use when defining or implementing Go interfaces, designing abstractions, creating mockable boundaries for testing, or composing types through embedding. Also use when deciding whether to accept an interface or return a concrete type, or using type assertions or type switches, even if the user doesn't explicitly mention interfaces. Does not cover generics-based polymorphism (see go-generics).","kongnakornna\u002Fgolangapi","kongnakornna","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F10528904?v=4","01M79Z5JQPPV5CWQHXS235Q9MD","Kongnakorn Jantakun","01M79Z5JRHJJJ6PR2DGQS4P985",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgolang-skills\u002Fskills\u002Fgo-interfaces\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: go-interfaces\ndescription: Use when defining or implementing Go interfaces, designing abstractions, creating mockable boundaries for testing, or composing types through embedding. Also use when deciding whether to accept an interface or return a concrete type, or using type assertions or type switches, even if the user doesn't explicitly mention interfaces. Does not cover generics-based polymorphism (see go-generics).\nallowed-tools: Bash(bash:*)\n---\n\n# Go Interfaces and Composition\n\n## Resource Routing\n\n- `scripts\u002Fcheck-interface-compliance.sh` - Run as a heuristic to find exported interfaces that may need compile-time assertions.\n- `scripts\u002Fcheck-interface-compliance.go` - Implementation helper invoked by `check-interface-compliance.sh`; patch this when changing method-set analysis.\n- `references\u002FEMBEDDING.md` - Read when embedding interfaces or structs in public APIs.\n- `references\u002FRECEIVER-TYPE.md` - Read when pointer\u002Fvalue receivers affect interface satisfaction.\n\n---\n\n## Accept Interfaces, Return Concrete Types\n\nInterfaces belong in the package that **consumes** values, not the package that\n**implements** them. Return concrete (usually pointer or struct) types from\nconstructors so new methods can be added without refactoring.\n\n```go\n\u002F\u002F Good: consumer defines the interface it needs\npackage consumer\n\ntype Thinger interface { Thing() bool }\n\nfunc Foo(t Thinger) string { ... }\n```\n\n```go\n\u002F\u002F Good: producer returns concrete type\npackage producer\n\ntype Thinger struct{ ... }\nfunc (t Thinger) Thing() bool { ... }\nfunc NewThinger() Thinger { return Thinger{ ... } }\n```\n\n```go\n\u002F\u002F Bad: producer defines and returns its own interface\npackage producer\n\ntype Thinger interface { Thing() bool }\ntype defaultThinger struct{ ... }\nfunc NewThinger() Thinger { return defaultThinger{ ... } }\n```\n\n**Do not define interfaces before they are used.** Without a realistic example\nof usage, it is too difficult to see whether an interface is even necessary.\n\n---\n\n## Generality: Hide Implementation, Expose Interface\n\nIf a type exists only to implement an interface with no exported methods beyond\nthat interface, return the interface from constructors to hide the implementation:\n\n```go\nfunc NewHash() hash.Hash32 {\n    return &myHash{}  \u002F\u002F unexported type\n}\n```\n\nBenefits: implementation can change without affecting callers, substituting\nalgorithms requires only changing the constructor call.\n\n---\n\n## Type Assertions: Comma-Ok Idiom\n\nWithout checking, a failed assertion causes a runtime panic. Always use the\ncomma-ok idiom to test safely:\n\n```go\nstr, ok := value.(string)\nif ok {\n    fmt.Printf(\"string value is: %q\\n\", str)\n}\n```\n\nTo check if a value implements an interface:\n\n```go\nif _, ok := val.(json.Marshaler); ok {\n    fmt.Printf(\"value %v implements json.Marshaler\\n\", val)\n}\n```\n\n---\n\n## Type Switch\n\nIt's idiomatic to reuse the variable name (`t := t.(type)`) — the variable has\nthe correct type in each case branch. When a case lists multiple types\n(`case int, int64:`), the variable has the interface type.\n\n---\n\n## Embedding\n\nAvoid embedding types in public structs — the inner type's full method set\nbecomes part of your public API. Use unexported fields instead.\n\n---\n\n## Interface Satisfaction Checks\n\nUse a blank identifier assignment to verify a type implements an interface at\ncompile time:\n\n```go\nvar _ json.Marshaler = (*RawMessage)(nil)\n```\n\nThis causes a compile error if `*RawMessage` doesn't implement `json.Marshaler`.\n\nUse this pattern when:\n- There are no static conversions that would verify the interface automatically\n- The type must satisfy an interface for correct behavior (e.g., custom JSON\n  marshaling)\n- Interface changes should break compilation, not silently degrade\n\n**Don't** add these checks for every interface — only when no other static\nconversion would catch the error.\n\n> **Validation**: After defining interfaces or implementations, run `bash scripts\u002Fcheck-interface-compliance.sh` to verify all concrete types have compile-time `var _ I = (*T)(nil)` checks.\n\n---\n\n## Receiver Type\n\nIf in doubt, use a pointer receiver. Don't mix receiver types on a single\ntype — if any method needs a pointer, use pointers for all methods. Use value\nreceivers only for small, immutable types (`Point`, `time.Time`) or basic types.\n\n---\n\n## Quick Reference\n\n| Concept | Pattern | Notes |\n|---------|---------|-------|\n| Consumer owns interface | Define interfaces where used | Not in the implementing package |\n| Safe type assertion | `v, ok := x.(Type)` | Returns zero value + false |\n| Type switch | `switch v := x.(type)` | Variable has correct type per case |\n| Interface embedding | `type RW interface { Reader; Writer }` | Union of methods |\n| Struct embedding | `type S struct { *T }` | Promotes T's methods |\n| Interface check | `var _ I = (*T)(nil)` | Compile-time verification |\n| Generality | Return interface from constructor | Hide implementation |\n\n---\n\n## Related Skills\n\n- **Interface naming**: See [go-naming](..\u002Fgo-naming\u002FSKILL.md) when naming interfaces (the `-er` suffix convention) or choosing receiver names\n- **Error types**: See [go-error-handling](..\u002Fgo-error-handling\u002FSKILL.md) when implementing the `error` interface, custom error types, or `errors.As` matching\n- **Generics vs interfaces**: See [go-generics](..\u002Fgo-generics\u002FSKILL.md) when deciding whether generics are needed or an interface already suffices\n- **Functional options**: See [go-functional-options](..\u002Fgo-functional-options\u002FSKILL.md) when using an interface-based Option pattern for flexible constructors\n- **Defensive boundaries**: See [go-defensive](..\u002Fgo-defensive\u002FSKILL.md) when interface assertions are one part of a broader API-boundary hardening pass\n","# Go Interfaces and Composition\n\n## Resource Routing\n\n- `scripts\u002Fcheck-interface-compliance.sh` - Run as a heuristic to find exported interfaces that may need compile-time assertions.\n- `scripts\u002Fcheck-interface-compliance.go` - Implementation helper invoked by `check-interface-compliance.sh`; patch this when changing method-set analysis.\n- `references\u002FEMBEDDING.md` - Read when embedding interfaces or structs in public APIs.\n- `references\u002FRECEIVER-TYPE.md` - Read when pointer\u002Fvalue receivers affect interface satisfaction.\n\n---\n\n## Accept Interfaces, Return Concrete Types\n\nInterfaces belong in the package that **consumes** values, not the package that\n**implements** them. Return concrete (usually pointer or struct) types from\nconstructors so new methods can be added without refactoring.\n\n```go\n\u002F\u002F Good: consumer defines the interface it needs\npackage consumer\n\ntype Thinger interface { Thing() bool }\n\nfunc Foo(t Thinger) string { ... }\n```\n\n```go\n\u002F\u002F Good: producer returns concrete type\npackage producer\n\ntype Thinger struct{ ... }\nfunc (t Thinger) Thing() bool { ... }\nfunc NewThinger() Thinger { return Thinger{ ... } }\n```\n\n```go\n\u002F\u002F Bad: producer defines and returns its own interface\npackage producer\n\ntype Thinger interface { Thing() bool }\ntype defaultThinger struct{ ... }\nfunc NewThinger() Thinger { return defaultThinger{ ... } }\n```\n\n**Do not define interfaces before they are used.** Without a realistic example\nof usage, it is too difficult to see whether an interface is even necessary.\n\n---\n\n## Generality: Hide Implementation, Expose Interface\n\nIf a type exists only to implement an interface with no exported methods beyond\nthat interface, return the interface from constructors to hide the implementation:\n\n```go\nfunc NewHash() hash.Hash32 {\n    return &myHash{}  \u002F\u002F unexported type\n}\n```\n\nBenefits: implementation can change without affecting callers, substituting\nalgorithms requires only changing the constructor call.\n\n---\n\n## Type Assertions: Comma-Ok Idiom\n\nWithout checking, a failed assertion causes a runtime panic. Always use the\ncomma-ok idiom to test safely:\n\n```go\nstr, ok := value.(string)\nif ok {\n    fmt.Printf(\"string value is: %q\\n\", str)\n}\n```\n\nTo check if a value implements an interface:\n\n```go\nif _, ok := val.(json.Marshaler); ok {\n    fmt.Printf(\"value %v implements json.Marshaler\\n\", val)\n}\n```\n\n---\n\n## Type Switch\n\nIt's idiomatic to reuse the variable name (`t := t.(type)`) — the variable has\nthe correct type in each case branch. When a case lists multiple types\n(`case int, int64:`), the variable has the interface type.\n\n---\n\n## Embedding\n\nAvoid embedding types in public structs — the inner type's full method set\nbecomes part of your public API. Use unexported fields instead.\n\n---\n\n## Interface Satisfaction Checks\n\nUse a blank identifier assignment to verify a type implements an interface at\ncompile time:\n\n```go\nvar _ json.Marshaler = (*RawMessage)(nil)\n```\n\nThis causes a compile error if `*RawMessage` doesn't implement `json.Marshaler`.\n\nUse this pattern when:\n- There are no static conversions that would verify the interface automatically\n- The type must satisfy an interface for correct behavior (e.g., custom JSON\n  marshaling)\n- Interface changes should break compilation, not silently degrade\n\n**Don't** add these checks for every interface — only when no other static\nconversion would catch the error.\n\n> **Validation**: After defining interfaces or implementations, run `bash scripts\u002Fcheck-interface-compliance.sh` to verify all concrete types have compile-time `var _ I = (*T)(nil)` checks.\n\n---\n\n## Receiver Type\n\nIf in doubt, use a pointer receiver. Don't mix receiver types on a single\ntype — if any method needs a pointer, use pointers for all methods. Use value\nreceivers only for small, immutable types (`Point`, `time.Time`) or basic types.\n\n---\n\n## Quick Reference\n\n| Concept | Pattern | Notes |\n|---------|---------|-------|\n| Consumer owns interface | Define interfaces where used | Not in the implementing package |\n| Safe type assertion | `v, ok := x.(Type)` | Returns zero value + false |\n| Type switch | `switch v := x.(type)` | Variable has correct type per case |\n| Interface embedding | `type RW interface { Reader; Writer }` | Union of methods |\n| Struct embedding | `type S struct { *T }` | Promotes T's methods |\n| Interface check | `var _ I = (*T)(nil)` | Compile-time verification |\n| Generality | Return interface from constructor | Hide implementation |\n\n---\n\n## Related Skills\n\n- **Interface naming**: See [go-naming](..\u002Fgo-naming\u002FSKILL.md) when naming interfaces (the `-er` suffix convention) or choosing receiver names\n- **Error types**: See [go-error-handling](..\u002Fgo-error-handling\u002FSKILL.md) when implementing the `error` interface, custom error types, or `errors.As` matching\n- **Generics vs interfaces**: See [go-generics](..\u002Fgo-generics\u002FSKILL.md) when deciding whether generics are needed or an interface already suffices\n- **Functional options**: See [go-functional-options](..\u002Fgo-functional-options\u002FSKILL.md) when using an interface-based Option pattern for flexible constructors\n- **Defensive boundaries**: See [go-defensive](..\u002Fgo-defensive\u002FSKILL.md) when interface assertions are one part of a broader API-boundary hardening pass\n",{"name":5,"description":7,"allowed-tools":24},"Bash(bash:*)","main","19f4d52a98d557f3a645a2cfbbeb5bd54f28831d",".github\u002Fskills\u002Fgolang-skills\u002Fskills\u002Fgo-interfaces","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":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add kongnakornna\u002Fgolangapi --skill go-interfaces",{"tool":39,"command":40},"bunx","bunx skills add kongnakornna\u002Fgolangapi --skill go-interfaces",{"tool":42,"command":43},"pnpm","pnpm dlx skills add kongnakornna\u002Fgolangapi --skill go-interfaces","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgolang-skills\u002Fskills\u002Fgo-interfaces\u002FSKILL.md",true,[47,53,57,63],{"path":48,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":51,"sourceHtmlUrl":52},"references\u002FEMBEDDING.md","REFERENCE","参考文档",3637,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgolang-skills\u002Fskills\u002Fgo-interfaces\u002Freferences\u002FEMBEDDING.md",{"path":54,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":55,"sourceHtmlUrl":56},"references\u002FRECEIVER-TYPE.md",2378,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgolang-skills\u002Fskills\u002Fgo-interfaces\u002Freferences\u002FRECEIVER-TYPE.md",{"path":58,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":61,"sourceHtmlUrl":62},"scripts\u002Fcheck-interface-compliance.go","SCRIPT","脚本",12358,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgolang-skills\u002Fskills\u002Fgo-interfaces\u002Fscripts\u002Fcheck-interface-compliance.go",{"path":64,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":65,"sourceHtmlUrl":66},"scripts\u002Fcheck-interface-compliance.sh",1399,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgolang-skills\u002Fskills\u002Fgo-interfaces\u002Fscripts\u002Fcheck-interface-compliance.sh",[68,75,82,89,96,103],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M7A0M9RJJ3383VEFYKABWV15","tb-writing-plans","Use when you have a spec or requirements for a multi-step task, before touching code","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-writing-plans\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"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":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"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":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"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":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"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":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"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",[],[]]