
Go Context
Go context conventions covering placement, cancellation, deadlines, and when to store values in context.
- CCM score
- 63 of 100
- skills.sh installs
- 1.4K
- GitHub stars
- 197
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers
context.Contextplacement in signatures, propagating cancellation and deadlines, and storing request-scoped values - Includes a routing reference (
references/PATTERNS.md) for deriving contexts, checking cancellation, HTTP request contexts, and typed value keys - Enforces context as the first parameter, no Context fields in structs, and no custom context types in signatures
- Designed for Go developers working with timeouts, cancellation, or request-scoped data, and points to go-concurrency for goroutine lifecycle
Install
$ npx -y skills add cxuu/golang-skills --skill go-context -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Go Context Usage
Compatibility:
contexthas been in the standard library since Go 1.7.
Resource Routing
references/PATTERNS.md- Read when deriving contexts, checking cancellation, handling HTTP request contexts, or using typed context-value keys.
Context as First Parameter
Functions that use a Context should accept it as their first parameter:
func F(ctx context.Context, /* other arguments */) error
func ProcessRequest(ctx context.Context, req *Request) (*Response, error)
This is a strong convention in Go that makes context flow visible and consistent across codebases.
Don't Store Context in Structs
Do not add a Context member to a struct type. Instead, pass ctx as a parameter
to each method that needs it:
// Bad: Context stored in struct
type Worker struct {
ctx context.Context // Don't do this
}
// Good: Context passed to methods
type Worker struct{ /* ... */ }
func (w *Worker) Process(ctx context.Context) error {
// Context explicitly passed — lifetime clear
}
Exception: Methods whose signature must match an interface in the standard library or a third-party library may need to work around this.
Details
- Repository
- github.com/cxuu/golang-skills
- Category
- Go
- First seen
- May 16, 2026
More from cxuu/golang-skills
All 20- Go Performance1.4K
- Go Naming1.3K
- Go Defensive1.3K
- Go Packages1.3K
- Go Functional Options1.3K
- Go Data Structures1.3K
- Go Control Flow1.3K
- Go Logging1.1K
- Go Generics1.1K
- Go Functions1.1K
- Go Declarations1.1K
- Go Code Review1.8K
- Go Testing1.5K
- Go Error Handling1.4K
- Go Concurrency1.4K
- Go Interfaces1.4K
- Go Linting1.4K
- Go Style Core1.4K
- Go Documentation1.4K
Similar to Go Context
More Go
golang-contextsamber/cc-skills-golang43.8K installsIdiomatic context.Context guidance for propagation, cancellation, timeouts, values, and detached background work in Go.
go-concurrencycxuu/golang-skills1.4K installsGo concurrency guidance covering goroutine lifetimes, channel-versus-mutex choice, and safe shared state.
go-concurrency-patternswshobson/agents12K installsConcurrency primitives and worked patterns for Go, covering goroutines, channels, sync, and context-driven cancellation.
golang-concurrencysamber/cc-skills-golang44.7K installsGo concurrency design guide covering goroutine lifecycles, channels, sync primitives, and worker pools.
go-loggingcxuu/golang-skills1.1K installsStructured Go logging guide for slog, log levels, request-scoped context, and what to keep out of logs.