What problem does it solve?
This Skill prevents broken cancellation, leaked resources, and lost request metadata in Go applications by enforcing correct use of context.Context across handlers, service layers, databases, and outbound calls.
Core Features & Use Cases
- Correct context propagation across API boundaries: ensures the same ctx flows from entry points through every downstream operation.
- Cancellation, deadlines, and timeouts done safely: applies context.WithCancel/WithTimeout/WithDeadline patterns with proper cancel() handling to avoid leaks.
- Safe use of request-scoped values: recommends unexported key types for context.WithValue and limits values to request metadata (e.g., trace IDs).
- Background work that outlives requests: uses context.WithoutCancel for goroutines that must continue after the request completes, while preserving context values.
- Go 1.21+ cleanup and lifecycle tooling: covers context.AfterFunc for non-blocking cleanup on cancellation.
Quick Start
Apply the golang-context Skill to review or refactor your Go call chain so every operation uses the incoming request context and respects cancellation and deadlines.