[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79ZF6FNBSKWHRQCJ1XPE150":3,"skill-same:01M79ZF6FNBSKWHRQCJ1XPE150":78},{"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":39,"commitSha":40,"skillDirectory":41,"forksCount":14,"repositoryHtmlUrl":42,"repositoryHomepageUrl":6,"ownerHtmlUrl":43,"ownerBlogUrl":44,"ownerDescription":45,"updatedAt":46,"install":47,"resources":59},"01M79ZF6FNBSKWHRQCJ1XPE150","golang-context",null,"Idiomatic context.Context usage in Golang — propagation through API boundaries, cancellation, timeouts and deadlines, request-scoped values, context.WithoutCancel for background work outliving requests. Apply when designing context propagation across layers, debugging leaked or unexpired contexts, choosing between context.Background\u002FTODO\u002FWithoutCancel, or storing values in context. Not for code that merely accepts ctx as first parameter.","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-cc-skills\u002Fskills\u002Fgolang-context\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: golang-context\ndescription: \"Idiomatic context.Context usage in Golang — propagation through API boundaries, cancellation, timeouts and deadlines, request-scoped values, context.WithoutCancel for background work outliving requests. Apply when designing context propagation across layers, debugging leaked or unexpired contexts, choosing between context.Background\u002FTODO\u002FWithoutCancel, or storing values in context. Not for code that merely accepts ctx as first parameter.\"\nuser-invocable: true\nlicense: MIT\ncompatibility: Designed for Claude Code, Codex or similar harness, and for projects using Golang.\nmetadata:\n  author: samber\n  version: \"1.3.1\"\n  openclaw:\n    emoji: \"🔗\"\n    homepage: https:\u002F\u002Fgithub.com\u002Fsamber\u002Fcc-skills-golang\n    requires:\n      bins:\n        - go\n    install: []\nallowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent\npaths:\n  - \"**\u002F*.go\"\n---\n\n> **Community default.** A company skill that explicitly supersedes `samber\u002Fcc-skills-golang@golang-context` skill takes precedence.\n\n# Go context.Context Best Practices\n\n`context.Context` is Go's mechanism for propagating cancellation signals, deadlines, and request-scoped values across API boundaries and between goroutines. Think of it as the \"session\" of a request — it ties together every operation that belongs to the same unit of work.\n\n## Best Practices Summary\n\n1. Propagate the same context through the entire request lifecycle: HTTP handler → service → DB → external APIs — any link that starts a fresh context keeps working after the client is gone.\n2. Take `ctx` as the first parameter, named `ctx context.Context` — the fixed position is what makes context-aware APIs recognizable at a glance and what linters check.\n3. Pass context through function parameters instead of storing it in a struct — the struct outlives the request that filled it, so later calls reuse a context that is already cancelled or belongs to someone else.\n4. Pass `context.TODO()` rather than a `nil` context — `nil` panics on the first `Done()` or `Value()` call, far from the caller that passed it.\n5. Call `cancel()` on all control-flow paths for `WithCancel`\u002F`WithTimeout`\u002F`WithDeadline`, unless ownership of the context and cancel function is explicitly returned or transferred — an uncalled `cancel()` keeps the child attached to its parent and leaks its timer until the parent finishes.\n6. Create `context.Background()` only at top-level entry points (main, init, tests). Deeper in the call chain — especially mid-request — it detaches the work from the caller's deadline and cancellation, the propagation break shown below.\n7. Use `context.TODO()` as a placeholder when a context is needed but none exists yet — it marks the gap for a later fix instead of hiding it behind a `Background()` that looks deliberate.\n8. Declare context value keys as unexported types — with a plain `string` key, two packages using `\"user\"` silently overwrite each other.\n9. Carry only request-scoped metadata in context values, never function parameters — values retrieved through `Value()` lose compile-time typing and disappear from the function signature.\n10. Use `context.WithoutCancel` (Go 1.21+) when spawning background work that must outlive the parent request — otherwise the handler returning cancels the audit log or cleanup just started.\n\n## Creating Contexts\n\n| Situation | Use |\n| --- | --- |\n| Entry point (main, init, test) | `context.Background()` |\n| Function needs context but caller doesn't provide one yet | `context.TODO()` |\n| Inside an HTTP handler | `r.Context()` |\n| Need cancellation control | `context.WithCancel(parentCtx)` |\n| Need a deadline\u002Ftimeout | `context.WithTimeout(parentCtx, duration)` |\n\n## Context Propagation: The Core Principle\n\nThe most important rule: **propagate the same context through the entire call chain**. When you propagate correctly, cancelling the parent context cancels all downstream work automatically.\n\n```go\n\u002F\u002F ✗ Bad — creates a new context, breaking the chain\nfunc (s *OrderService) Create(ctx context.Context, order Order) error {\n    return s.db.ExecContext(context.Background(), \"INSERT INTO orders ...\", order.ID)\n}\n\n\u002F\u002F ✓ Good — propagates the caller's context\nfunc (s *OrderService) Create(ctx context.Context, order Order) error {\n    return s.db.ExecContext(ctx, \"INSERT INTO orders ...\", order.ID)\n}\n```\n\n## Deep Dives\n\n- **[Cancellation, Timeouts & Deadlines](.\u002Freferences\u002Fcancellation.md)** — How cancellation propagates: `WithCancel` for manual cancellation, `WithTimeout` for automatic cancellation after a duration, `WithDeadline` for absolute time deadlines. Patterns for listening (`\u003C-ctx.Done()`) in concurrent code, `AfterFunc` callbacks, and `WithoutCancel` for operations that must outlive their parent request (e.g., audit logs).\n\n- **[Context Values & Cross-Service Tracing](.\u002Freferences\u002Fvalues-tracing.md)** — Safe context value patterns: unexported key types to prevent namespace collisions, when to use context values (request ID, user ID) vs function parameters. Trace context propagation: OpenTelemetry trace headers, correlation IDs for log aggregation, and marshaling\u002Funmarshaling context across service boundaries.\n\n- **[Context in HTTP Servers & Service Calls](.\u002Freferences\u002Fhttp-services.md)** — HTTP handler context: `r.Context()` for request-scoped cancellation, middleware integration, and propagating to services. HTTP client patterns: `NewRequestWithContext`, client timeouts, and retries with context awareness. Database operations: always use `*Context` variants (`QueryContext`, `ExecContext`) to respect deadlines.\n\n## Cross-References\n\n- → See the `samber\u002Fcc-skills-golang@golang-concurrency` skill for goroutine cancellation patterns using context\n- → See the `samber\u002Fcc-skills-golang@golang-database` skill for context-aware database operations (QueryContext, ExecContext)\n- → See the `samber\u002Fcc-skills-golang@golang-observability` skill for trace context propagation with OpenTelemetry\n- → See the `samber\u002Fcc-skills-golang@golang-design-patterns` skill for timeout and resilience patterns\n\n## Enforce with Linters\n\nMany context pitfalls are caught automatically by linters: `govet`, `staticcheck`. → See the `samber\u002Fcc-skills-golang@golang-lint` skill for configuration and usage.\n","> **Community default.** A company skill that explicitly supersedes `samber\u002Fcc-skills-golang@golang-context` skill takes precedence.\n\n# Go context.Context Best Practices\n\n`context.Context` is Go's mechanism for propagating cancellation signals, deadlines, and request-scoped values across API boundaries and between goroutines. Think of it as the \"session\" of a request — it ties together every operation that belongs to the same unit of work.\n\n## Best Practices Summary\n\n1. Propagate the same context through the entire request lifecycle: HTTP handler → service → DB → external APIs — any link that starts a fresh context keeps working after the client is gone.\n2. Take `ctx` as the first parameter, named `ctx context.Context` — the fixed position is what makes context-aware APIs recognizable at a glance and what linters check.\n3. Pass context through function parameters instead of storing it in a struct — the struct outlives the request that filled it, so later calls reuse a context that is already cancelled or belongs to someone else.\n4. Pass `context.TODO()` rather than a `nil` context — `nil` panics on the first `Done()` or `Value()` call, far from the caller that passed it.\n5. Call `cancel()` on all control-flow paths for `WithCancel`\u002F`WithTimeout`\u002F`WithDeadline`, unless ownership of the context and cancel function is explicitly returned or transferred — an uncalled `cancel()` keeps the child attached to its parent and leaks its timer until the parent finishes.\n6. Create `context.Background()` only at top-level entry points (main, init, tests). Deeper in the call chain — especially mid-request — it detaches the work from the caller's deadline and cancellation, the propagation break shown below.\n7. Use `context.TODO()` as a placeholder when a context is needed but none exists yet — it marks the gap for a later fix instead of hiding it behind a `Background()` that looks deliberate.\n8. Declare context value keys as unexported types — with a plain `string` key, two packages using `\"user\"` silently overwrite each other.\n9. Carry only request-scoped metadata in context values, never function parameters — values retrieved through `Value()` lose compile-time typing and disappear from the function signature.\n10. Use `context.WithoutCancel` (Go 1.21+) when spawning background work that must outlive the parent request — otherwise the handler returning cancels the audit log or cleanup just started.\n\n## Creating Contexts\n\n| Situation | Use |\n| --- | --- |\n| Entry point (main, init, test) | `context.Background()` |\n| Function needs context but caller doesn't provide one yet | `context.TODO()` |\n| Inside an HTTP handler | `r.Context()` |\n| Need cancellation control | `context.WithCancel(parentCtx)` |\n| Need a deadline\u002Ftimeout | `context.WithTimeout(parentCtx, duration)` |\n\n## Context Propagation: The Core Principle\n\nThe most important rule: **propagate the same context through the entire call chain**. When you propagate correctly, cancelling the parent context cancels all downstream work automatically.\n\n```go\n\u002F\u002F ✗ Bad — creates a new context, breaking the chain\nfunc (s *OrderService) Create(ctx context.Context, order Order) error {\n    return s.db.ExecContext(context.Background(), \"INSERT INTO orders ...\", order.ID)\n}\n\n\u002F\u002F ✓ Good — propagates the caller's context\nfunc (s *OrderService) Create(ctx context.Context, order Order) error {\n    return s.db.ExecContext(ctx, \"INSERT INTO orders ...\", order.ID)\n}\n```\n\n## Deep Dives\n\n- **[Cancellation, Timeouts & Deadlines](.\u002Freferences\u002Fcancellation.md)** — How cancellation propagates: `WithCancel` for manual cancellation, `WithTimeout` for automatic cancellation after a duration, `WithDeadline` for absolute time deadlines. Patterns for listening (`\u003C-ctx.Done()`) in concurrent code, `AfterFunc` callbacks, and `WithoutCancel` for operations that must outlive their parent request (e.g., audit logs).\n\n- **[Context Values & Cross-Service Tracing](.\u002Freferences\u002Fvalues-tracing.md)** — Safe context value patterns: unexported key types to prevent namespace collisions, when to use context values (request ID, user ID) vs function parameters. Trace context propagation: OpenTelemetry trace headers, correlation IDs for log aggregation, and marshaling\u002Funmarshaling context across service boundaries.\n\n- **[Context in HTTP Servers & Service Calls](.\u002Freferences\u002Fhttp-services.md)** — HTTP handler context: `r.Context()` for request-scoped cancellation, middleware integration, and propagating to services. HTTP client patterns: `NewRequestWithContext`, client timeouts, and retries with context awareness. Database operations: always use `*Context` variants (`QueryContext`, `ExecContext`) to respect deadlines.\n\n## Cross-References\n\n- → See the `samber\u002Fcc-skills-golang@golang-concurrency` skill for goroutine cancellation patterns using context\n- → See the `samber\u002Fcc-skills-golang@golang-database` skill for context-aware database operations (QueryContext, ExecContext)\n- → See the `samber\u002Fcc-skills-golang@golang-observability` skill for trace context propagation with OpenTelemetry\n- → See the `samber\u002Fcc-skills-golang@golang-design-patterns` skill for timeout and resilience patterns\n\n## Enforce with Linters\n\nMany context pitfalls are caught automatically by linters: `govet`, `staticcheck`. → See the `samber\u002Fcc-skills-golang@golang-lint` skill for configuration and usage.\n",{"name":5,"paths":24,"license":15,"metadata":26,"description":7,"allowed-tools":36,"compatibility":37,"user-invocable":38},[25],"**\u002F*.go",{"author":27,"version":28,"openclaw":29},"samber","1.3.1",{"emoji":30,"install":31,"homepage":32,"requires":33},"🔗",[],"https:\u002F\u002Fgithub.com\u002Fsamber\u002Fcc-skills-golang",{"bins":34},[35],"go","Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent","Designed for Claude Code, Codex or similar harness, and for projects using Golang.",true,"main","19f4d52a98d557f3a645a2cfbbeb5bd54f28831d",".github\u002Fskills\u002Fgo-cc-skills\u002Fskills\u002Fgolang-context","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":48,"prompt":58,"zipAvailable":38},[49,52,55],{"tool":50,"command":51},"npx","npx skills add kongnakornna\u002Fgolangapi --skill golang-context",{"tool":53,"command":54},"bunx","bunx skills add kongnakornna\u002Fgolangapi --skill golang-context",{"tool":56,"command":57},"pnpm","pnpm dlx skills add kongnakornna\u002Fgolangapi --skill golang-context","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-cc-skills\u002Fskills\u002Fgolang-context\u002FSKILL.md",[60,66,70,74],{"path":61,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":64,"sourceHtmlUrl":65},"evals\u002Fevals.json","REFERENCE","参考文档",13535,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-cc-skills\u002Fskills\u002Fgolang-context\u002Fevals\u002Fevals.json",{"path":67,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":68,"sourceHtmlUrl":69},"references\u002Fcancellation.md",6075,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-cc-skills\u002Fskills\u002Fgolang-context\u002Freferences\u002Fcancellation.md",{"path":71,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":72,"sourceHtmlUrl":73},"references\u002Fhttp-services.md",3805,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-cc-skills\u002Fskills\u002Fgolang-context\u002Freferences\u002Fhttp-services.md",{"path":75,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":76,"sourceHtmlUrl":77},"references\u002Fvalues-tracing.md",3162,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-cc-skills\u002Fskills\u002Fgolang-context\u002Freferences\u002Fvalues-tracing.md",[79,87,94,101,108,115],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":83,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"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":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":83,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"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":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":83,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"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":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":83,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"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":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":83,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"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":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":83,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":121,"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",[],[]]