Agent skill

Golang Context

by context-labs in context-labs/whip

Idiomatic context.Context usage in Golang — cancellation, timeouts/deadlines, request-scoped values, WithoutCancel for background work.

MITAuto-check passedDevelopment

Install Golang Context

skills CLI
$ npx skills add context-labs/whip --skill golang-context -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install context-labs/whip golang-context --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/context-labs/whip.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/golang-context .claude/skills/golang-context && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
golang-context
GitHub stars
1.1k
Token cost
~1.3k tokens
SKILL.md length
470 words
Files
5 (incl. references)
Skills in repo
40
Repo updated
First seen
Licence
MIT

At a glance

Idiomatic context.Context usage in Golang — cancellation, timeouts/deadlines, request-scoped values, WithoutCancel for background work.

  • Works in 11 steps: The same context MUST be propagated… → ctx MUST be the first parameter, named… → NEVER store context in a struct — pass… → …
  • Designing context propagation across layers
  • SKILL.md covers Best Practices Summary, Creating Contexts, Context Propagation: The Core… and Deep Dives, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Golang Context is an agent skill from context-labs/whip. Idiomatic context.Context usage in Golang — cancellation, timeouts/deadlines, request-scoped values, WithoutCancel for background work. Use when designing context propagation across layers, debugging leaked contexts, or choosing Background/TODO/WithoutCancel. Not for code merely accepting ctx.

Its SKILL.md is about 1.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 6 other files, including reference files (for example `evals/evals.json`, `references/cancellation.md` and `references/http-services.md`). Compatibility notes: Designed for Claude Code, Codex or similar harness, and for projects using Golang.

It sits in Development. It works with Go. The repository describes itself as: A fast coding-agent harness in Go. Tool-use loop, bubbletea TUI, provider-routable models with live catalog discovery, MCP support, background subagents. One binary, no runtime… The licence is MIT.

When your agent uses it

  • Designing context propagation across layers
  • Debugging leaked contexts
  • Choosing Background/TODO/WithoutCancel

Example prompts

  • “/golang-context”

Requirements

  • Compatibility (from SKILL.md): Designed for Claude Code, Codex or similar harness, and for projects using Golang.
  • Pre-approved tools (allowed-tools): Read, Edit, Write, Glob, Grep, Bash(go:*), Bash(golangci-lint:*), Bash(git:*), Agent

Workflow steps

11 steps, taken from the first numbered list in SKILL.md.

  1. The same context MUST be propagated through the entire request lifecycle: HTTP handler → service → DB → external APIs
  2. ctx MUST be the first parameter, named ctx context.Context
  3. NEVER store context in a struct — pass explicitly through function parameters
  4. NEVER pass nil context — use context.TODO() if unsure
  5. cancel() MUST be called on all control-flow paths for WithCancel/WithTimeout/WithDeadline, unless ownership of the context and cancel…
  6. context.Background() MUST only be used at the top level (main, init, tests)
  7. Use context.TODO() as a placeholder when you know a context is needed but don't have one yet
  8. NEVER create a new context.Background() in the middle of a request path
  9. Context value keys MUST be unexported types to prevent collisions
  10. Context values MUST only carry request-scoped metadata — NEVER function parameters
  11. Use context.WithoutCancel (Go 1.21+) when spawning background work that must outlive the parent request

What it can do on your machine

Read from SKILL.md and the folder at commit 8876467. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Edit
    • Write
    • Glob
    • Grep
    • Bash(go:*)
    • Bash(golangci-lint:*)
    • Bash(git:*)
    • Agent

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are go).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Designed for Claude Code, Codex or similar harness, and for projects using Golang.

    From compatibility in the SKILL.md frontmatter.

Context cost

Golang Context loads about 1.3k tokens when it runs, and up to ~4.3k if it reads all its reference files. Until then it costs about 77 tokens; SKILL.md has 470 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~77
When it runs · the whole SKILL.md, loaded when a task matches
~1.3k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from context-labs/whip at commit 8876467, republished under its MIT licence (© context-labs). 470 words, ~1,308 tokens.

Download SKILL.mdSave it as .claude/skills/golang-context/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
golang-context
description
Idiomatic context.Context usage in Golang — cancellation, timeouts/deadlines, request-scoped values, WithoutCancel for background work. Use when designing context propagation across layers, debugging leaked contexts, or choosing Background/TODO/WithoutCancel. Not for code merely accepting ctx.
allowed-tools
Read, Edit, Write, Glob, Grep, Bash(go:*), Bash(golangci-lint:*), Bash(git:*), Agent
compatibility
Designed for Claude Code, Codex or similar harness, and for projects using Golang.
user-invocable
true
license
MIT
metadata.author
samber
metadata.version
1.3.0
paths
**/*.go

Community default. A company skill that explicitly supersedes samber/cc-skills-golang@golang-context skill takes precedence.

Go context.Context Best Practices

context.Context is Go's mechanism for propagating cancellation signals, deadlines, and request-scoped values across API boundaries and between goroutines. Think of it as the "session" of a request — it ties together every operation that belongs to the same unit of work.

Best Practices Summary

  1. The same context MUST be propagated through the entire request lifecycle: HTTP handler → service → DB → external APIs
  2. ctx MUST be the first parameter, named ctx context.Context
  3. NEVER store context in a struct — pass explicitly through function parameters
  4. NEVER pass nil context — use context.TODO() if unsure
  5. cancel() MUST be called on all control-flow paths for WithCancel/WithTimeout/WithDeadline, unless ownership of the context and cancel function is explicitly returned or transferred
  6. context.Background() MUST only be used at the top level (main, init, tests)
  7. Use context.TODO() as a placeholder when you know a context is needed but don't have one yet
  8. NEVER create a new context.Background() in the middle of a request path
  9. Context value keys MUST be unexported types to prevent collisions
  10. Context values MUST only carry request-scoped metadata — NEVER function parameters
  11. Use context.WithoutCancel (Go 1.21+) when spawning background work that must outlive the parent request

Creating Contexts

SituationUse
Entry point (main, init, test)context.Background()
Function needs context but caller doesn't provide one yetcontext.TODO()
Inside an HTTP handlerr.Context()
Need cancellation controlcontext.WithCancel(parentCtx)
Need a deadline/timeoutcontext.WithTimeout(parentCtx, duration)

Context Propagation: The Core Principle

The most important rule: propagate the same context through the entire call chain. When you propagate correctly, cancelling the parent context cancels all downstream work automatically.

go
// ✗ Bad — creates a new context, breaking the chain
func (s *OrderService) Create(ctx context.Context, order Order) error {
    return s.db.ExecContext(context.Background(), "INSERT INTO orders ...", order.ID)
}

// ✓ Good — propagates the caller's context
func (s *OrderService) Create(ctx context.Context, order Order) error {
    return s.db.ExecContext(ctx, "INSERT INTO orders ...", order.ID)
}
Show full SKILL.md (192 more words)Show less

Deep Dives

  • Cancellation, Timeouts & Deadlines — How cancellation propagates: WithCancel for manual cancellation, WithTimeout for automatic cancellation after a duration, WithDeadline for absolute time deadlines. Patterns for listening (<-ctx.Done()) in concurrent code, AfterFunc callbacks, and WithoutCancel for operations that must outlive their parent request (e.g., audit logs).

  • Context Values & Cross-Service Tracing — Safe context value patterns: unexported key types to prevent namespace collisions, when to use context values (request ID, user ID) vs function parameters. Trace context propagation: OpenTelemetry trace headers, correlation IDs for log aggregation, and marshaling/unmarshaling context across service boundaries.

  • Context in HTTP Servers & Service Calls — HTTP handler context: r.Context() for request-scoped cancellation, middleware integration, and propagating to services. HTTP client patterns: NewRequestWithContext, client timeouts, and retries with context awareness. Database operations: always use *Context variants (QueryContext, ExecContext) to respect deadlines.

Cross-References

  • → See the samber/cc-skills-golang@golang-concurrency skill for goroutine cancellation patterns using context
  • → See the samber/cc-skills-golang@golang-database skill for context-aware database operations (QueryContext, ExecContext)
  • → See the samber/cc-skills-golang@golang-observability skill for trace context propagation with OpenTelemetry
  • → See the samber/cc-skills-golang@golang-design-patterns skill for timeout and resilience patterns

Enforce with Linters

Many context pitfalls are caught automatically by linters: govet, staticcheck. → See the samber/cc-skills-golang@golang-lint skill for configuration and usage.

© context-labs, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (references) in .agents/skills/golang-context of context-labs/whip.

  • SKILL.md
  • evals/evals.json
  • references/cancellation.md
  • references/http-services.md
  • references/values-tracing.md

Open the folder on GitHubat commit 8876467

Compare with similar skills

Golang Context next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Golang Context compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Golang Context this skillcontext-labs/whip1.1k—~1.3kAutomated safety check: PassMIT
Add Redis Command to go-redisredis/go-redis22k—~1.4kAutomated safety check: PassBSD-2-Clause
Go Pedantrychromedp/chromedp13k—~3.7kAutomated safety check: PassMIT
AO Desktop App LauncherOrchestratorInc/agent-orchestrator13k—~2.4kAutomated safety check: PassApache-2.0
Go-Redis Release Preparationredis/go-redis22k—~1.1kAutomated safety check: PassBSD-2-Clause
Run Dozzle Dev Instanceamir20/dozzle15k—~747Automated safety check: PassMIT

Similar skills

  • Official

    Walks through adding a new Redis or Redis module command to the go-redis client, from fetching the spec and docs to the type, interface wiring, parsing and tests.

    22k GitHub stars~1.4k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Go Pedantry

    chromedp/chromedp

    This skill should be used when the user is writing Go code and needs guidance on Go-specific pedantry: error wrapping with fmt.Errorf and %w, interface design (accept interfaces return structs)…

    13k GitHub stars~3.7k tokensUpdated 4 days ago
    DevelopmentAuto-check passed
  • AO Desktop App Launcher

    OrchestratorInc/agent-orchestrator

    Launches, restarts and troubleshoots the real AO Electron desktop app from a checkout, with isolated or real local data and checks for stale processes.

    13k GitHub stars~2.4k tokensUpdated today
    DevelopmentAuto-check passed
  • Official

    Prepares a go-redis release locally: picks the next semver, gathers merged PRs, writes the RELEASE-NOTES entry and bumps versions, without publishing.

    22k GitHub stars~1.1k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Starts a Dozzle dev server on a port derived from the current worktree so you can test by hand in a browser, without disturbing instances started elsewhere.

    15k GitHub stars~747 tokensUpdated today
    DevelopmentAuto-check passed
  • Code Review

    yaklang/yakit

    对 Yakit 仓库的代码改动做规范化 code review:按代码逻辑、TS 定义、UI 引用与 Props、CSS 样式、依赖版本、配置项六个维度审查,检查测试用例缺失,强制执行 tsc 类型检查与 vitest 测试验证,输出「结果汇总 / 明细解释 / 合并结论」三块报告,经用户确认后写入文件。当用户要求 review、审查、评审代码改动,或在提交、合并、提 PR…

    7.8k GitHub stars~1.5k tokensUpdated today
    DevelopmentAuto-check: notes

More from context-labs/whip

All 40 skills in this repo
  • Golang Lint

    context-labs/whip

    Linting best practices and golangci-lint configuration for Go — running linters, configuring .golangci.yml, nolint suppressions, selecting linters.

    1.1k GitHub starsUsed in 2 repos~1.8k tokens
    Auto-check passed
  • Golang Project Layout

    context-labs/whip

    Golang project layouts and workspaces. An agent skill from context-labs/whip.

    1.1k GitHub starsUsed in 1 repo~1.8k tokens
    Auto-check passed
  • Golang Pkg Go Dev

    context-labs/whip

    Golang package/module docs via godig, a pkg.go.dev API client (CLI + MCP) — APIs, symbols, versions, importers, licenses, vulnerabilities.

    1.1k GitHub starsUsed in 2 repos~3k tokens
    Auto-check passed
  • Golang Stretchr Testify

    context-labs/whip

    Golang testing with stretchr/testify — assert, require, mock, suite: assertions, mock expectations, argument matchers, suite lifecycle, Eventually, JSONEq.

    1.1k GitHub starsUsed in 2 repos~1.8k tokens
    Auto-check passed
  • CI/CD with GitHub Actions for Golang — testing, linting, SAST, security scanning, coverage, Dependabot, Renovate, GoReleaser, release pipelines.

    1.1k GitHub stars~3.5k tokensUpdated 4 days ago
    Auto-check passed
  • Golang Data Structures

    context-labs/whip

    Golang data structures — slices/maps internals (capacity growth, preallocation, hash buckets), slices/maps packages, container/list/heap/ring, strings.Builder vs bytes.Buffer, generic collections…

    1.1k GitHub starsUsed in 1 repo~2.6k tokens
    Auto-check passed

Works with

Categories

Questions about Golang Context

What does Golang Context do?

Idiomatic context.Context usage in Golang — cancellation, timeouts/deadlines, request-scoped values, WithoutCancel for background work. Golang Context is an agent skill from context-labs/whip.Context usage in Golang — cancellation, timeouts/deadlines, request-scoped values, WithoutCancel for background work.

When should I use Golang Context?

Golang Context fits situations like: designing context propagation across layers; debugging leaked contexts; choosing Background/TODO/WithoutCancel.

How do I install Golang Context in Claude Code?

Run `npx skills add context-labs/whip --skill golang-context -a claude-code`. Or copy the skill folder (.agents/skills/golang-context in context-labs/whip) into .claude/skills/golang-context in your project. Claude Code loads it when a task matches its description.

How do I install Golang Context in Codex?

Run `npx skills add context-labs/whip --skill golang-context -a codex`. Or copy the skill folder (.agents/skills/golang-context in context-labs/whip) into .agents/skills/golang-context in your project. Codex loads it when a task matches its description.

Can I use Golang Context in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add context-labs/whip --skill golang-context -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/golang-context, .gemini/skills/golang-context, .github/skills/golang-context and .opencode/skills/golang-context in your project.

What does Golang Context need to run?

SKILL.md names no scripts, command-line tools or credentials: Golang Context is instructions for the agent only. Its frontmatter pre-approves these tools: Read, Edit, Write, Glob, Grep, Bash(go:*), Bash(golangci-lint:*), Bash(git:*), Agent. Compatibility (from SKILL.md): Designed for Claude Code, Codex or similar harness, and for projects using Golang..

Does Golang Context access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Golang Context safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Golang Context use?

Golang Context is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Golang Context use?

About 1.3k tokens (SKILL.md is roughly 5.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 3k tokens, read only when the agent opens those files.

What are the alternatives to Golang Context?

Skills that share tags, products or a category with Golang Context: Add Redis Command to go-redis (redis/go-redis, 22k stars), Go Pedantry (chromedp/chromedp, 13k stars), AO Desktop App Launcher (OrchestratorInc/agent-orchestrator, 13k stars) and Go-Redis Release Preparation (redis/go-redis, 22k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Golang Context?

context-labs (a GitHub organization) maintains it in context-labs/whip, which has 1,083 GitHub stars. The repository holds 40 skills in this directory. The repository was last updated on October 5, 2026.

Source: context-labs/whip on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.