[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7DNBY6FH1PA7V75MDMGYN5Y":3,"skill-same:01M7DNBY6FH1PA7V75MDMGYN5Y":46},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":13,"repositoryHtmlUrl":26,"repositoryHomepageUrl":27,"ownerHtmlUrl":28,"ownerBlogUrl":29,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M7DNBY6FH1PA7V75MDMGYN5Y","go-errors-and-context",null,"Design Go error contracts, context propagation, cancellation, deadline budgets, and retry boundaries. Use when adding failures, wrapping dependency errors, or changing operation lifetime.","Cratis\u002FFundamentals.Go","Cratis","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F16456213?v=4","01M6BXRH290K4C8RS4PTKK3HXQ","01M7DN6YCMASAFGKYBBH3C1Z6E",0,"MIT","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fgo-errors-and-context\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: go-errors-and-context\ndescription: Design Go error contracts, context propagation, cancellation, deadline budgets, and retry boundaries. Use when adding failures, wrapping dependency errors, or changing operation lifetime.\n---\n\n# Go errors and context\n\nRead `Documentation\u002Fproject-context.md` and `.cratis\u002Fai\u002Frules\u002Fgo.md` first.\nLoad the transport skill for gRPC status mapping or HTTP response envelopes.\n\n## Workflow\n\n1. List failures callers must distinguish. Choose a sentinel for a category, a\n   typed error for structured detail, or an opaque translation for private\n   implementation failures. Document which identities callers can inspect.\n2. Add operation context with `%w` only when the cause is intended public API.\n   A future dependency swap must preserve exposed error semantics. Avoid both\n   logging and returning the same error; log at the boundary making the decision.\n3. Return a real nil `error` on success, not a typed nil in an interface.\n   Preserve important cleanup errors, using `errors.Join` if the Go minimum\n   supports it and multiple causes belong in the public contract.\n4. Accept `context.Context` first and propagate it to blocking dependencies.\n   Do not store request contexts in clients or replace canceled contexts with\n   `Background`. Use context values only for request-scoped metadata.\n5. Assign cancel ownership. Child timeouts cannot extend the parent's deadline;\n   call their cancel functions on every path. Cancellation is not a goroutine join.\n6. Set a total operation budget before retrying; keep attempts and backoff within\n   it. Cancellation during a wait must terminate it. Retrying append after an\n   ambiguous response needs demonstrated server idempotency, not optimism.\n7. Define whether transport statuses remain inspectable or are translated. Keep\n   domain rejection distinct from transport failure and partial success.\n8. Test wrapping, `errors.Is`\u002F`As`, nil success, caller cancellation, deadline\n   expiry, cleanup, and ambiguous writes. Update public docs and parity entries.\n\n## Small example: bounded propagation\n\nIllustrative helper. It does not retry and deliberately exposes the callback's\nerror identity; the callback must honor its context.\n\n```go\npackage operation\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n)\n\n\u002F\u002F Run executes call within both the parent's and the supplied time budget.\n\u002F\u002F Errors returned by call remain inspectable through errors.Is and errors.As.\nfunc Run(ctx context.Context, budget time.Duration,\n\tcall func(context.Context) error,\n) error {\n\tif budget \u003C= 0 || call == nil {\n\t\treturn fmt.Errorf(\"positive budget and non-nil call required\")\n\t}\n\tctx, cancel := context.WithTimeout(ctx, budget)\n\tdefer cancel()\n\tif err := ctx.Err(); err != nil {\n\t\treturn err\n\t}\n\tif err := call(ctx); err != nil {\n\t\treturn fmt.Errorf(\"run operation: %w\", err)\n\t}\n\treturn nil\n}\n```\n\nA timeout cannot forcibly interrupt a callback that ignores its context. Do not\nstart an unjoinable goroutine to pretend this helper can enforce termination.\n\n## Verification boundary\n\nRun targeted error\u002Fdeadline tests and the repository gates. Stop for an unresolved\nretry guarantee or public error contract; do not guess transport semantics or\nclaim a timed-out write definitely failed on the server.\n\n## References and attribution\n\n- [Errors as values](https:\u002F\u002Fgo.dev\u002Fblog\u002Ferrors-are-values)\n- [Wrapping as API](https:\u002F\u002Fgo.dev\u002Fblog\u002Fgo1.13-errors)\n- [Context ownership](https:\u002F\u002Fpkg.go.dev\u002Fcontext)\n- [Google best practices](https:\u002F\u002Fgoogle.github.io\u002Fstyleguide\u002Fgo\u002Fbest-practices.html):\n  Google, [CC-BY-3.0](https:\u002F\u002Fcreativecommons.org\u002Flicenses\u002Fby\u002F3.0\u002F); error-boundary\n  advice paraphrased for Cratis. Workflow and example are original.\n","# Go errors and context\n\nRead `Documentation\u002Fproject-context.md` and `.cratis\u002Fai\u002Frules\u002Fgo.md` first.\nLoad the transport skill for gRPC status mapping or HTTP response envelopes.\n\n## Workflow\n\n1. List failures callers must distinguish. Choose a sentinel for a category, a\n   typed error for structured detail, or an opaque translation for private\n   implementation failures. Document which identities callers can inspect.\n2. Add operation context with `%w` only when the cause is intended public API.\n   A future dependency swap must preserve exposed error semantics. Avoid both\n   logging and returning the same error; log at the boundary making the decision.\n3. Return a real nil `error` on success, not a typed nil in an interface.\n   Preserve important cleanup errors, using `errors.Join` if the Go minimum\n   supports it and multiple causes belong in the public contract.\n4. Accept `context.Context` first and propagate it to blocking dependencies.\n   Do not store request contexts in clients or replace canceled contexts with\n   `Background`. Use context values only for request-scoped metadata.\n5. Assign cancel ownership. Child timeouts cannot extend the parent's deadline;\n   call their cancel functions on every path. Cancellation is not a goroutine join.\n6. Set a total operation budget before retrying; keep attempts and backoff within\n   it. Cancellation during a wait must terminate it. Retrying append after an\n   ambiguous response needs demonstrated server idempotency, not optimism.\n7. Define whether transport statuses remain inspectable or are translated. Keep\n   domain rejection distinct from transport failure and partial success.\n8. Test wrapping, `errors.Is`\u002F`As`, nil success, caller cancellation, deadline\n   expiry, cleanup, and ambiguous writes. Update public docs and parity entries.\n\n## Small example: bounded propagation\n\nIllustrative helper. It does not retry and deliberately exposes the callback's\nerror identity; the callback must honor its context.\n\n```go\npackage operation\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n)\n\n\u002F\u002F Run executes call within both the parent's and the supplied time budget.\n\u002F\u002F Errors returned by call remain inspectable through errors.Is and errors.As.\nfunc Run(ctx context.Context, budget time.Duration,\n\tcall func(context.Context) error,\n) error {\n\tif budget \u003C= 0 || call == nil {\n\t\treturn fmt.Errorf(\"positive budget and non-nil call required\")\n\t}\n\tctx, cancel := context.WithTimeout(ctx, budget)\n\tdefer cancel()\n\tif err := ctx.Err(); err != nil {\n\t\treturn err\n\t}\n\tif err := call(ctx); err != nil {\n\t\treturn fmt.Errorf(\"run operation: %w\", err)\n\t}\n\treturn nil\n}\n```\n\nA timeout cannot forcibly interrupt a callback that ignores its context. Do not\nstart an unjoinable goroutine to pretend this helper can enforce termination.\n\n## Verification boundary\n\nRun targeted error\u002Fdeadline tests and the repository gates. Stop for an unresolved\nretry guarantee or public error contract; do not guess transport semantics or\nclaim a timed-out write definitely failed on the server.\n\n## References and attribution\n\n- [Errors as values](https:\u002F\u002Fgo.dev\u002Fblog\u002Ferrors-are-values)\n- [Wrapping as API](https:\u002F\u002Fgo.dev\u002Fblog\u002Fgo1.13-errors)\n- [Context ownership](https:\u002F\u002Fpkg.go.dev\u002Fcontext)\n- [Google best practices](https:\u002F\u002Fgoogle.github.io\u002Fstyleguide\u002Fgo\u002Fbest-practices.html):\n  Google, [CC-BY-3.0](https:\u002F\u002Fcreativecommons.org\u002Flicenses\u002Fby\u002F3.0\u002F); error-boundary\n  advice paraphrased for Cratis. Workflow and example are original.\n",{"name":5,"description":7},"main","45728854e223fd51b203724ca0e5be9c8f93a5a4",".cratis\u002Fai\u002Fskills\u002Fgo-errors-and-context","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go","https:\u002F\u002Fwww.cratis.io\u002Ffundamentals\u002Fgo\u002F","https:\u002F\u002Fgithub.com\u002FCratis","https:\u002F\u002Fwww.cratis.io","Open-source (MIT) event sourcing and CQRS for .NET and beyond: Chronicle, Arc, Components and Screenplay.","2026-11-14 15:52:19",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add Cratis\u002FFundamentals.Go --skill go-errors-and-context",{"tool":38,"command":39},"bunx","bunx skills add Cratis\u002FFundamentals.Go --skill go-errors-and-context",{"tool":41,"command":42},"pnpm","pnpm dlx skills add Cratis\u002FFundamentals.Go --skill go-errors-and-context","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fgo-errors-and-context\u002FSKILL.md",true,[],[47,55,63,71,80,87],{"skillNo":48,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":51,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":18},"01M7DNCY3BCGY3MC5BFJ9S59BF","spf13-go","Review Go library APIs, package boundaries, tests, iterators and standard-library choices. Load for broad design or idiom reviews after the repository-owned Go skills.","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fspf13-go\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fspf13-go\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":59,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":18},"01M7DNCSQQH7GQ03ZETFX9XHAS","samber-golang-error-handling","Review Go error creation, wrapping, inspection and logging boundaries. Load when changing caller-visible failures after go-errors-and-context.","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fsamber-golang-error-handling\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fsamber-golang-error-handling\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":67,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":18},"01M7DNCM4ZC15SSDA5FAAHN5S0","samber-golang-context","Design Go context propagation, cancellation, deadlines and request metadata. Load for operation-lifetime changes or context-related leaks after go-errors-and-context.","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fsamber-golang-context\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fsamber-golang-context\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":75,"licenseFileUrl":76,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":18},"01M7DNCGNSMHK640AK1R3J0CPD","jetbrains-go-modern-guidelines","Choose version-compatible modern Go syntax and standard-library APIs. Load when modernizing touched Go code after reading go.mod and build constraints.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fjetbrains-go-modern-guidelines\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fjetbrains-go-modern-guidelines\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":18},"01M7DNCBYSD6FPAPWM6PPSJR96","go-testing","Write and review Go unit, contract, transport, race, fuzz, and deterministic concurrency tests. Use for new behavior, bug fixes, flaky tests, and public API parity evidence.","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fgo-testing\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":18},"01M7DNC7ES2RD6WGKC94KMMXTD","go-release-modules","Review Go module dependencies, minimum versions, compatibility, semantic labels, release-action tags, and proxy discoverability. Use for release preparation, retractions, and major-version migration planning.","https:\u002F\u002Fgithub.com\u002FCratis\u002FFundamentals.Go\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fgo-release-modules\u002FSKILL.md",[],[]]