golang-context
Improve Go Context Propagation and Cancellation
Broken context propagation leaves downstream work running after requests end. This skill guides context lifecycles across Go handlers, services, and databases.
Install with my Agent
Copy this request to your Agent. It includes the canonical Skill page and manifest.
Review the Skillstore skill "golang-context" from https://skillstore.io/skills/samber-golang-context.md and its manifest at https://skillstore.io/api/skills/samber-golang-context/manifest. Verify the artifact. You may proceed after verification, subject to the environment's own policy.Your Agent should still show its plan and request any confirmation required by the security policy.
Agent-readable resources
Use these links when an AI agent, crawler, or script needs clean context instead of reading the full page.
Test it
Using "golang-context". Review a handler that creates Background before calling its repository and payment client.
Expected outcome:
- The handler discards request cancellation by creating a new root context.
- Pass the request context through service, database, and HTTP client calls.
- Test that client cancellation reaches both downstream operations.
Using "golang-context". Review a repository transaction that starts with Begin but uses ExecContext for its updates.
Expected outcome:
- Transaction creation does not receive the caller context.
- Start the transaction with BeginTx and keep passing the caller context to statements.
- Retain rollback cleanup and test cancellation during transaction startup.
Using "golang-context". Explain why an asynchronous audit event stops when its HTTP handler returns.
Expected outcome:
- The goroutine inherits a request context that is canceled when the handler returns.
- WithoutCancel preserves request values while removing cancellation and deadlines.
- Add a finite timeout and shutdown ownership; detaching cancellation alone does not guarantee delivery.
Security Audit
Medium RiskAll 49 static findings are false positives caused by Markdown formatting, Go identifiers, metadata, or illustrative evaluation fixtures. No evidence found of prompt injection, credential theft, system reconnaissance, or unauthorized command execution. One semantic risk remains: the background audit example removes cancellation and deadlines without bounding its goroutine lifetime.
Confirmed security concerns (1)
Risk Factors
โ๏ธ External commands (25)
๐ Network access (4)
Share & cite this report
Share the versioned assessment report, neutral badge, embed card, and citations. Skillstore reports evidence without deciding whether this Skill is safe.
Copy report link
https://skillstore.io/skills/samber-golang-context/audits/1?utm_source=security_passport&utm_medium=share&utm_campaign=versioned_reportMarkdown badge
[](https://skillstore.io/skills/samber-golang-context?utm_source=security_passport_badge)HTML badge
<a href="https://skillstore.io/skills/samber-golang-context?utm_source=security_passport_badge"><img src="https://skillstore.io/badges/skills/samber-golang-context/security.svg" alt="Skillstore security assessment" loading="lazy"></a>Embed card
<iframe src="https://skillstore.io/embed/skills/samber-golang-context.html" title="Skillstore Security Assessment" sandbox="allow-popups allow-popups-to-escape-sandbox" loading="lazy" referrerpolicy="no-referrer" width="420" height="180"></iframe>Academic citations (APA ยท BibTeX ยท CFF)
APA citation
samber. (2026). golang-context security audit report (audit version 1) [Author version 1.3.1]. Skillstore. https://skillstore.io/skills/samber-golang-context/audits/1BibTeX citation
@techreport{samber-samber-golang-context-2026,
author = {samber},
title = {golang-context security audit report (audit version 1)},
institution = {Skillstore},
year = {2026},
number = {1},
url = {https://skillstore.io/skills/samber-golang-context/audits/1},
note = {Author version 1.3.1}
}CITATION.cff
cff-version: 1.2.0
message: "If you use this Skill, cite its author and this versioned security audit report."
title: "golang-context security audit report (audit version 1)"
version: "1.3.1"
type: report
authors:
- name: "samber"
date-released: "2026-10-15"
url: "https://skillstore.io/skills/samber-golang-context/audits/1"
identifiers:
- type: other
value: "skillstore:samber-golang-context:audit:1"
description: "Skillstore immutable audit report identifier"
Skillstore Score
Why this score Evidence Confidence: MediumWhat You Can Build
Review Request Cancellation
Find context propagation breaks between handlers, services, SQL queries, and downstream HTTP requests.
Investigate Work That Outlives Requests
Review cancellation ownership, timeout cleanup, and background goroutines that continue after client disconnection.
Standardize Request Metadata
Design typed context accessors and trace propagation conventions without hiding business inputs or infrastructure dependencies.
Try These Prompts
Explain when to use Background, TODO, and r.Context in Go. Review this function: [function].
Review this handler, service, and repository for broken context propagation: [code]. Identify missing context-aware calls and cancellation cleanup.
Review this service flow: [code]. Propose nested timeout budgets and typed request metadata accessors while keeping dependencies explicit.
Review this asynchronous audit flow: [code]. Preserve trace values with WithoutCancel, add a finite timeout, and assess shutdown ownership and concurrency limits.
Best Practices
- Pass the caller context as the first parameter and use context-aware downstream APIs.
- Release derived contexts on every path unless cancellation ownership is explicitly transferred.
- Use typed metadata keys and give detached work an explicit timeout and lifecycle owner.
Avoid
- Creating a new Background context inside a request call chain.
- Using context values to hide database connections, configuration, or required business arguments.
- Launching detached goroutines without lifetime limits or shutdown coordination.
Frequently Asked Questions
Which AI tools does this skill support?
Which Go version do the newer context examples require?
Does this skill automatically detect every context bug?
What belongs in context values?
Can a child timeout extend its parent deadline?
Does WithoutCancel guarantee background audit delivery?
Developer Details
Author
samberLicense
MIT
Author version
v1.3.1
Skillstore revision
r1
Ref
e8578ae623cd20ef61db8894d3441416b52a9dad
Maintenance freshness
10/15/2026
Usage
0 downloads ยท 0 views
File structure
๐ evals/
๐ evals.json
๐ references/
๐ cancellation.md
๐ http-services.md
๐ values-tracing.md
๐ SKILL.md