golang-context
CommunityIdiomatic Go: safe, cancellable context usage.
System Documentation
What problem does it solve?
Go applications often struggle to propagate cancellation, deadlines, and request-scoped values across layers. This skill codifies idiomatic practices for using context.Context in Go, including propagation through HTTP handlers, services, and data stores, and avoiding common pitfalls like storing contexts in structs or bypassing context-aware APIs.
Core Features & Use Cases
- Propagate cancellation and deadlines across HTTP, gRPC, and background tasks using WithCancel, WithTimeout, and WithDeadline.
- Use context values judiciously for trace IDs and request-scoped metadata, without abusing context for business parameters.
- Ensure all downstream calls (HTTP, database) use context-aware APIs (e.g., Do with Request with Context, QueryContext/ExecContext/QueryRowContext).
Quick Start
Refactor a Go service to consistently pass and propagate a context.Context through handlers, services, and database calls, avoiding storing Context in structs.
Dependency Matrix
Required Modules
None requiredComponents
💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: golang-context Download link: https://github.com/samber/cc-skills-golang/archive/main.zip#golang-context Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.