golang-context

Apply best practices for managing context.Context in Golang applications.

Updated May 19, 2026
One-click install
npx skills add https://github.com/monforje/.opencode --skill golang-context-monforje
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-context
Source: https://github.com/monforje/.opencode/tree/main/skills/cc-skills-golang/skills/golang-context
Command: npx skills add https://github.com/monforje/.opencode --skill golang-context-monforje

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and evals (resource) components.

What problem does it solve?

This Skill unit provides guidance and best practices for managing context.Context in Golang applications, helping to prevent context-related issues like cancellation leaks and deadlocks.

Core Features & Use Cases

  • Best Practices Guide: Offers a summary of key principles for using context effectively, including propagation, value storage, and lifecycle management.
  • Context Propagation: Explains how to propagate contexts across different layers and services to ensure consistent behavior.
  • Use Case: When designing a Golang application that needs to manage cancellation, deadlines, and request-scoped values, this skill unit will help you avoid common pitfalls.

Quick Start

Use the golang-context skill to apply best practices for handling context.Context in your Golang application.

Frequently Asked Questions about golang-context

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

FAQPage Schema
How do I prevent context leaks and deadlocks in Golang?

To prevent context leaks and deadlocks in Golang, apply best practices for context propagation, value storage, and lifecycle management to ensure reliable cancellation and timeout handling.

What is the best way to propagate context across Golang services?

The best way to propagate context across Golang services is to follow established propagation principles across layers, ensuring consistent behavior for deadlines and request-scoped values.

How do I manage deadlines and timeouts with context in Golang?

You manage deadlines and timeouts with context in Golang by applying targeted best practices for lifecycle management, ensuring your application handles cancellation reliably without deadlocks.

Do I need to understand Golang concurrency patterns to use context effectively?

Yes, you need to understand basic Golang concurrency patterns and the context package to use context effectively, as this ensures proper handling of cancellation and request-scoped values.

Why does storing request-scoped values in Golang context cause issues?

Storing request-scoped values in Golang context can cause issues if lifecycle management is poor, but applying proper context propagation principles ensures consistent behavior and prevents cancellation leaks.