analyzing-options
Analyzing different approaches for a task or problem with structured comparisons, effort…
Detecting goroutine leaks in Go: greps for goroutine patterns, audits goleak coverage (VerifyTestMain/VerifyNone), runs goleak, and dispatches ring:backend-go to fix leaks and add regression tests. Use after implementation or during review when code spawns goroutines or a leak
$ npx -y skills add LerianStudio/ring --skill detecting-goroutine-leaks --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/detecting-goroutine-leaksContext preview
The summary Claude sees to decide when to auto-load this skill.
Detecting goroutine leaks in Go: greps for goroutine patterns, audits goleak coverage (VerifyTestMain/VerifyNone), runs goleak, and dispatches ring:backend-go to fix leaks and add regression tests. Use after implementation or during review when code spawns goroutines or a leak
name: ring:detecting-goroutine-leaks description: "Detecting goroutine leaks in Go: greps for goroutine patterns, audits goleak coverage (VerifyTestMain/VerifyNone), runs goleak, and dispatches ring:backend-go to fix leaks and add regression tests. Use after implementation or during review when code spawns goroutines or a leak is suspected. Runs before ring:reviewing-code. Skip for non-Go or code with no goroutines. Skip for panic/silent-death observability (use ring:using-runtime)."
**Runs before:** ring:reviewing-code **Runs after:** ring:implementing-tasks
**Complementary:** ring:backend-go
Standards: WebFetch `https://raw.githubusercontent.com/LerianStudio/ring/main/dev-team/docs/standards/golang/architecture.md` → "Goroutine Leak Detection" section.
# Find goroutine patterns (excluding tests, go.mod, go.sum)
grep -rn "go func()\|go [a-zA-Z_][a-zA-Z0-9_]*\.\|go [a-zA-Z_][a-zA-Z0-9_]*(" \
--include="*.go" \
{target_path} \
| grep -v "_test.go" \
| grep -v "go.mod\|go.sum\|golang.org"Goroutine patterns:
Exclude: go.mod/go.sum, golang.org imports, comments, string literals.
# Package-level
grep -rn "goleak.VerifyTestMain" --include="*_test.go" {target_path}
# Per-test
grep -rn "goleak.VerifyNone" --include="*_test.go" {target_path}Requirements:
go test -v ./... -run TestMain 2>&1 | grep -E "goleak|leak|goroutine|PASS|FAIL"
Leak output looks like:
goleak.go:89: found unexpected goroutines:
[Goroutine 7 in state chan receive, with myapp/internal/worker.(*Worker).run on top of the stack:]Task:
subagent_type: "ring:backend-go"
description: "Fix goroutine leak in {package_path}"
prompt: |
Fix goroutine leak and add goleak regression test.
Package: {package_path}
File: {file}:{line}
Leak output:
{goleak_output}
Standards: Load architecture.md via WebFetch → Goroutine Leak Detection section.
Requirements:
1. Fix leak — ensure proper shutdown (context cancellation, close channels, cancel goroutines)
2. Add goleak.VerifyTestMain(m) to TestMain in package
3. Add specific test proving no leak occurs
Pattern templates:
```go
// Worker with proper shutdown
type Worker struct { done chan struct{} }
func (w *Worker) Start(ctx context.Context) {
go func() {
for {
select {
case <-ctx.Done(): return // MUST honor context
case <-w.done: return
case item := <-w.queue: w.process(item)
}
}
}()
}
// TestMain with goleak
func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}Known safe goroutines to ignore:
Output: files changed, test results (no "unexpected goroutines")
## Output Format
```markdown
## Goroutine Detection Summary
| Metric | Value |
|--------|-------|
| Target path | {target_path} |
| Files with goroutines | N |
| Packages analyzed | N |
## goleak Coverage
| Package | Goroutine Files | goleak Present | Status |
|---------|----------------|---------------|--------|
Coverage: X/Y packages (Z%)
## Leak Findings
| Package | File:Line | Pattern | Status |
|---------|-----------|---------|--------|
Leaks detected: N
## Actions
{PASS: goleak present, no leaks}
{or: Dispatched ring:backend-go to fix N leaks}Proven engineering practices, enforced through skills. Ring is a comprehensive skills library and workflow system for AI agents that transforms how AI assistants approach software development.
Repo: LerianStudio/ring
Analyzing different approaches for a task or problem with structured comparisons, effort…
Auditing a service's production readiness against Ring engineering standards across base…
Cleaning redundant and obvious comments following clean code principles while preserving…
Commit changes with scope allowlist enforcement, atomic grouping, GPG-signed conventional…
Creating a handoff document that captures session state (completed work, decisions, open…
Creating an isolated git worktree for parallel branch work: selects the directory by priority…