go-context

Enforce correct Go context.Context propagation, cancellation, and timeout handling.

Updated May 2, 2026
One-click install
npx skills add https://github.com/Qunnnn/agents --skill go-context-qunnnn
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-context
Source: https://github.com/Qunnnn/agents/tree/main/skills/go/go-context
Command: npx skills add https://github.com/Qunnnn/agents --skill go-context-qunnnn

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps Go developers avoid incorrect context handling patterns that cause cancellation bugs, leaks, and poor request lifecycle management.

Core Features & Use Cases

  • Context Propagation: Guides passing context.Context correctly through handlers, services, databases, and external API calls.
  • Cancellation and Deadlines: Explains proper use of timeouts, manual cancellation, and detached background work.
  • Use Case: Apply this Skill when building Go backend services that need reliable request tracing, graceful shutdown behavior, and controlled long-running operations.

Quick Start

Ask the AI to review my Go code and apply idiomatic context.Context usage patterns for propagation, cancellation, and deadlines.

Frequently Asked Questions about go-context

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I properly use context.Context for cancellation and timeouts in Go backend services?

Correct context.Context propagation in Go involves passing it down the call chain as the first parameter, configuring explicit timeouts or deadlines at request boundaries, and handling cancellation signals to prevent resource leaks.

What is the correct way to propagate context through HTTP handlers and database operations in Go?

Context propagation in Go entails passing the context.Context parameter from incoming HTTP requests down through service layers and database calls, ensuring cancellation signals cascade correctly without storing contexts inside structs.

How do I prevent context-related leaks and anti-patterns when integrating external APIs in Go?

Preventing context leaks during Go external API integrations requires avoiding context.Background() in request-scoped paths, deferring cancel functions immediately, and ensuring HTTP clients respect context deadlines to release connections properly.

When should I use detached background context instead of request-scoped context in Go?

Use detached background context in Go for operations that must outlive the originating HTTP request, such as asynchronous cleanup or independent background tasks, ensuring parent request cancellation does not terminate necessary detached work.

Can this Skill review existing Go code for idiomatic context lifecycle management?

Yes, this Skill reviews existing Go code to enforce idiomatic context lifecycle management by detecting incorrect propagation patterns, missing timeouts, and unsafe cancellation handling across HTTP handlers, services, and database operations.

Why does my Go context cancellation not terminate long-running operations correctly?

Go context cancellation fails to terminate operations when functions ignore the context.Done() channel, block on synchronous calls without cancellation checks, or incorrectly detach from the parent context lifecycle.