[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79Z9AYN0H26C6MJD95GCDEF":3,"skill-same:01M79Z9AYN0H26C6MJD95GCDEF":52},{"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},"01M79Z9AYN0H26C6MJD95GCDEF","go-error-handling",null,"Go error handling patterns, wrapping, sentinel errors, custom error types, and the errors package. Grounded in Effective Go, Go Code Review Comments, and production-proven idioms. Use when implementing error handling, designing error types, debugging error chains, or reviewing error handling patterns. Trigger examples: \"handle errors\", \"error wrapping\", \"custom error type\", \"sentinel errors\", \"errors.Is\", \"errors.As\". Not for: panic\u002Frecover in middleware (go-api-design), test assertions (go-test-quality).","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(code-quality)\u002Fgo-error-handling\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: go-error-handling\ndescription: >\n  Go error handling patterns, wrapping, sentinel errors, custom error types,\n  and the errors package. Grounded in Effective Go, Go Code Review Comments,\n  and production-proven idioms. Use when implementing error handling,\n  designing error types, debugging error chains, or reviewing error handling\n  patterns. Trigger examples: \"handle errors\", \"error wrapping\", \"custom\n  error type\", \"sentinel errors\", \"errors.Is\", \"errors.As\".\n  Not for: panic\u002Frecover in middleware (go-api-design), test assertions\n  (go-test-quality).\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 Error Handling\n\nGo's explicit error handling is a feature, not a limitation.\nThese patterns ensure errors are informative, actionable, and properly propagated.\n\n## 1. Error Decision Tree\n\nWhen creating or returning an error, follow this tree:\n\n1. **Simple, no extra context needed?** → `errors.New(\"message\")`\n2. **Need to add context to existing error?** → `fmt.Errorf(\"doing X: %w\", err)`\n3. **Caller needs to detect this error?** → Sentinel `var` or custom type\n4. **Error carries structured data?** → Custom type implementing `error`\n5. **Propagating from downstream?** → Wrap with `%w` and add context\n\n## 2. Sentinel Errors\n\nUse package-level `var` for errors that callers need to check:\n\n```go\n\u002F\u002F ✅ Good — exported sentinel error\nvar (\n    ErrNotFound     = errors.New(\"user: not found\")\n    ErrUnauthorized = errors.New(\"user: unauthorized\")\n)\n\n\u002F\u002F Naming convention: Err + Description\n\u002F\u002F Prefix with package context in the message\n```\n\nCallers check with `errors.Is`:\n\n```go\nif errors.Is(err, user.ErrNotFound) {\n    \u002F\u002F handle not found\n}\n```\n\nNEVER compare errors with `==`. Always use `errors.Is()`.\n\n## 3. Custom Error Types\n\nWhen errors need to carry structured information:\n\n```go\ntype ValidationError struct {\n    Field   string\n    Message string\n}\n\nfunc (e *ValidationError) Error() string {\n    return fmt.Sprintf(\"validation: field %s: %s\", e.Field, e.Message)\n}\n\n\u002F\u002F Callers extract with errors.As:\nvar valErr *ValidationError\nif errors.As(err, &valErr) {\n    log.Printf(\"invalid field: %s\", valErr.Field)\n}\n```\n\n## 4. Error Wrapping\n\nALWAYS add context when propagating errors up the stack.\nUse `%w` to preserve the error chain:\n\n```go\n\u002F\u002F ✅ Good — context added, chain preserved\nfunc getUser(id int64) (*User, error) {\n    row, err := db.QueryRow(ctx, query, id)\n    if err != nil {\n        return nil, fmt.Errorf(\"get user %d: %w\", id, err)\n    }\n    \u002F\u002F ...\n}\n\n\u002F\u002F ❌ Bad — no context\nreturn nil, err\n\n\u002F\u002F ❌ Bad — chain broken, callers can't errors.Is\u002FAs\nreturn nil, fmt.Errorf(\"failed: %v\", err)\n```\n\n### When NOT to use `%w`\n\nUse `%v` instead of `%w` when you explicitly want to **break** the error chain,\npreventing callers from depending on internal implementation errors:\n\n```go\n\u002F\u002F Intentionally hiding internal DB error from public API\nreturn nil, fmt.Errorf(\"user lookup failed: %v\", err)\n```\n\n## 5. Handle Errors Exactly Once\n\nAn error should be either logged OR returned, never both:\n\n```go\n\u002F\u002F ✅ Good — return the error, let caller decide\nfunc loadConfig(path string) (*Config, error) {\n    data, err := os.ReadFile(path)\n    if err != nil {\n        return nil, fmt.Errorf(\"load config %s: %w\", path, err)\n    }\n    \u002F\u002F ...\n}\n\n\u002F\u002F ❌ Bad — log AND return (error handled twice)\nfunc loadConfig(path string) (*Config, error) {\n    data, err := os.ReadFile(path)\n    if err != nil {\n        log.Printf(\"failed to read config: %v\", err) \u002F\u002F handled once\n        return nil, err                                 \u002F\u002F handled again\n    }\n    \u002F\u002F ...\n}\n```\n\nThe rule: the component that *decides what to do* about the error is the one\nthat logs\u002Fmetrics it. Everyone else wraps and returns.\n\n## 6. Error Naming Conventions\n\n```go\n\u002F\u002F Sentinel errors: Err prefix\nvar ErrNotFound = errors.New(\"not found\")\n\n\u002F\u002F Error types: Error suffix\ntype NotFoundError struct { ... }\ntype ValidationError struct { ... }\n\n\u002F\u002F Error messages: lowercase, no punctuation, no \"failed to\" prefix\n\u002F\u002F Include context: \"package: action: detail\"\nerrors.New(\"auth: token expired\")\nfmt.Errorf(\"user: get by id %d: %w\", id, err)\n```\n\n## 7. Panic Rules\n\nPanic is NOT error handling. Use panic only when:\n- Program initialization fails and cannot continue (`template.Must`, flag parsing)\n- Programmer error that should never happen (violated invariant)\n- Nil dereference that indicates a bug, not a runtime condition\n\nIn tests, use `t.Fatal` \u002F `t.FailNow`, never `panic`.\n\nIn HTTP handlers and middleware, recover from panics at the boundary\nto prevent one request from crashing the server.\n\n## 8. Error Checking Patterns\n\n```go\n\u002F\u002F Inline error check — preferred for simple cases\nif err := doSomething(); err != nil {\n    return fmt.Errorf(\"do something: %w\", err)\n}\n\n\u002F\u002F Multi-return with named result — acceptable for complex functions\nfunc process() (result string, err error) {\n    defer func() {\n        if err != nil {\n            err = fmt.Errorf(\"process: %w\", err)\n        }\n    }()\n    \u002F\u002F ...\n}\n\n\u002F\u002F errors.Join for multiple errors (Go 1.20+)\nvar errs []error\nfor _, item := range items {\n    if err := validate(item); err != nil {\n        errs = append(errs, err)\n    }\n}\nreturn errors.Join(errs...)\n```\n\n## Executable Verification\n\nAfter writing or reviewing error handling, run the linters that prove\nthe rules above (skip any that is not installed and note it):\n\n```bash\ngo vet .\u002F...                                  # includes printf %w misuse\ngolangci-lint run --enable errcheck,errorlint # unchecked errors, %v-vs-%w,\n                                              # == comparisons on errors\n```\n\n## Verification Checklist\n\n1. No `_` discarding errors (unless explicitly justified with comment)\n2. Every `fmt.Errorf` wrapping uses `%w` (or `%v` with documented reason)\n3. Sentinel errors use `var Err...` naming\n4. Custom error types implement `error` interface\n5. Callers use `errors.Is` \u002F `errors.As`, never `==` or type assertion\n6. No log-and-return patterns\n7. Error messages are lowercase, contextual, chain-friendly\n","# Go Error Handling\n\nGo's explicit error handling is a feature, not a limitation.\nThese patterns ensure errors are informative, actionable, and properly propagated.\n\n## 1. Error Decision Tree\n\nWhen creating or returning an error, follow this tree:\n\n1. **Simple, no extra context needed?** → `errors.New(\"message\")`\n2. **Need to add context to existing error?** → `fmt.Errorf(\"doing X: %w\", err)`\n3. **Caller needs to detect this error?** → Sentinel `var` or custom type\n4. **Error carries structured data?** → Custom type implementing `error`\n5. **Propagating from downstream?** → Wrap with `%w` and add context\n\n## 2. Sentinel Errors\n\nUse package-level `var` for errors that callers need to check:\n\n```go\n\u002F\u002F ✅ Good — exported sentinel error\nvar (\n    ErrNotFound     = errors.New(\"user: not found\")\n    ErrUnauthorized = errors.New(\"user: unauthorized\")\n)\n\n\u002F\u002F Naming convention: Err + Description\n\u002F\u002F Prefix with package context in the message\n```\n\nCallers check with `errors.Is`:\n\n```go\nif errors.Is(err, user.ErrNotFound) {\n    \u002F\u002F handle not found\n}\n```\n\nNEVER compare errors with `==`. Always use `errors.Is()`.\n\n## 3. Custom Error Types\n\nWhen errors need to carry structured information:\n\n```go\ntype ValidationError struct {\n    Field   string\n    Message string\n}\n\nfunc (e *ValidationError) Error() string {\n    return fmt.Sprintf(\"validation: field %s: %s\", e.Field, e.Message)\n}\n\n\u002F\u002F Callers extract with errors.As:\nvar valErr *ValidationError\nif errors.As(err, &valErr) {\n    log.Printf(\"invalid field: %s\", valErr.Field)\n}\n```\n\n## 4. Error Wrapping\n\nALWAYS add context when propagating errors up the stack.\nUse `%w` to preserve the error chain:\n\n```go\n\u002F\u002F ✅ Good — context added, chain preserved\nfunc getUser(id int64) (*User, error) {\n    row, err := db.QueryRow(ctx, query, id)\n    if err != nil {\n        return nil, fmt.Errorf(\"get user %d: %w\", id, err)\n    }\n    \u002F\u002F ...\n}\n\n\u002F\u002F ❌ Bad — no context\nreturn nil, err\n\n\u002F\u002F ❌ Bad — chain broken, callers can't errors.Is\u002FAs\nreturn nil, fmt.Errorf(\"failed: %v\", err)\n```\n\n### When NOT to use `%w`\n\nUse `%v` instead of `%w` when you explicitly want to **break** the error chain,\npreventing callers from depending on internal implementation errors:\n\n```go\n\u002F\u002F Intentionally hiding internal DB error from public API\nreturn nil, fmt.Errorf(\"user lookup failed: %v\", err)\n```\n\n## 5. Handle Errors Exactly Once\n\nAn error should be either logged OR returned, never both:\n\n```go\n\u002F\u002F ✅ Good — return the error, let caller decide\nfunc loadConfig(path string) (*Config, error) {\n    data, err := os.ReadFile(path)\n    if err != nil {\n        return nil, fmt.Errorf(\"load config %s: %w\", path, err)\n    }\n    \u002F\u002F ...\n}\n\n\u002F\u002F ❌ Bad — log AND return (error handled twice)\nfunc loadConfig(path string) (*Config, error) {\n    data, err := os.ReadFile(path)\n    if err != nil {\n        log.Printf(\"failed to read config: %v\", err) \u002F\u002F handled once\n        return nil, err                                 \u002F\u002F handled again\n    }\n    \u002F\u002F ...\n}\n```\n\nThe rule: the component that *decides what to do* about the error is the one\nthat logs\u002Fmetrics it. Everyone else wraps and returns.\n\n## 6. Error Naming Conventions\n\n```go\n\u002F\u002F Sentinel errors: Err prefix\nvar ErrNotFound = errors.New(\"not found\")\n\n\u002F\u002F Error types: Error suffix\ntype NotFoundError struct { ... }\ntype ValidationError struct { ... }\n\n\u002F\u002F Error messages: lowercase, no punctuation, no \"failed to\" prefix\n\u002F\u002F Include context: \"package: action: detail\"\nerrors.New(\"auth: token expired\")\nfmt.Errorf(\"user: get by id %d: %w\", id, err)\n```\n\n## 7. Panic Rules\n\nPanic is NOT error handling. Use panic only when:\n- Program initialization fails and cannot continue (`template.Must`, flag parsing)\n- Programmer error that should never happen (violated invariant)\n- Nil dereference that indicates a bug, not a runtime condition\n\nIn tests, use `t.Fatal` \u002F `t.FailNow`, never `panic`.\n\nIn HTTP handlers and middleware, recover from panics at the boundary\nto prevent one request from crashing the server.\n\n## 8. Error Checking Patterns\n\n```go\n\u002F\u002F Inline error check — preferred for simple cases\nif err := doSomething(); err != nil {\n    return fmt.Errorf(\"do something: %w\", err)\n}\n\n\u002F\u002F Multi-return with named result — acceptable for complex functions\nfunc process() (result string, err error) {\n    defer func() {\n        if err != nil {\n            err = fmt.Errorf(\"process: %w\", err)\n        }\n    }()\n    \u002F\u002F ...\n}\n\n\u002F\u002F errors.Join for multiple errors (Go 1.20+)\nvar errs []error\nfor _, item := range items {\n    if err := validate(item); err != nil {\n        errs = append(errs, err)\n    }\n}\nreturn errors.Join(errs...)\n```\n\n## Executable Verification\n\nAfter writing or reviewing error handling, run the linters that prove\nthe rules above (skip any that is not installed and note it):\n\n```bash\ngo vet .\u002F...                                  # includes printf %w misuse\ngolangci-lint run --enable errcheck,errorlint # unchecked errors, %v-vs-%w,\n                                              # == comparisons on errors\n```\n\n## Verification Checklist\n\n1. No `_` discarding errors (unless explicitly justified with comment)\n2. Every `fmt.Errorf` wrapping uses `%w` (or `%v` with documented reason)\n3. Sentinel errors use `var Err...` naming\n4. Custom error types implement `error` interface\n5. Callers use `errors.Is` \u002F `errors.As`, never `==` or type assertion\n6. No log-and-return patterns\n7. Error messages are lowercase, contextual, chain-friendly\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","Go error handling patterns, wrapping, sentinel errors, custom error types, and the errors package. Grounded in Effective Go, Go Code Review Comments, and production-proven idioms. Use when implementing error handling, designing error types, debugging error chains, or reviewing error handling patterns. Trigger examples: \"handle errors\", \"error wrapping\", \"custom error type\", \"sentinel errors\", \"errors.Is\", \"errors.As\". Not for: panic\u002Frecover in middleware (go-api-design), test assertions (go-test-quality).\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(code-quality)\u002Fgo-error-handling","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-error-handling",{"tool":45,"command":46},"bunx","bunx skills add kongnakornna\u002Fgolangapi --skill go-error-handling",{"tool":48,"command":49},"pnpm","pnpm dlx skills add kongnakornna\u002Fgolangapi --skill go-error-handling","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(code-quality)\u002Fgo-error-handling\u002FSKILL.md",[],[53,61,68,75,82,89],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":57,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"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":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":57,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"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":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":57,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"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":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":57,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"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":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":57,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"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":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":57,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"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",[],[]]