Debug Go logo

Debug Go

Community
yerdaulet-damir
debug-go

Systematic 5-step debugging flow for Go 1.22+ services. Load when a test fails, a goroutine leaks, a downstream provider hangs, errors lose context, or production logs are unhelpful. Forces layer isolation (handler vs service vs repo vs provider) and runs the 5 most common Go antipattern greps before any code change — prevents the "add a goroutine to fix a slow handler" cascade.

Overview

Publisheryerdaulet-damir
Repositoryvibe-coding-rules
Skill namedebug-go
Stars
34
Forks
1
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by yerdaulet-damir on GitHub. Read the source before you install it.

Installation

Install the Debug Go AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/yerdaulet-damir/vibe-coding-rules/tree/main/.claude/skills/debug-go
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/yerdaulet-damir/vibe-coding-rules.git /tmp/vibe-coding-rules
mkdir -p .claude/skills
cp -r /tmp/vibe-coding-rules/.claude/skills/debug-go .claude/skills/debug-go
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Debug Go in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Debug Go on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Debug Go is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

debug-go

Stop. Do not edit any file yet. Work through these 5 steps in order.


Step 1 — Locate the layer

Go bugs almost always live in one of these layers. Identify which one before touching code.

SymptomLikely layerFirst grep
500 in prod, no useful logHandler — error mappinggrep -n "errors.Is|errors.As" internal/server/handlers.go
Wrong amount / state after mutationService / repogrep -n "Hold|Confirm|Refund" internal/<domain>/service.go
Hangs under loadHTTP client / bulkheadgrep -rn "http.DefaultClient|MaxConnsPerHost" internal/
context deadline exceeded everywhereMissing ctx propagationgrep -rn "context.Background()|context.TODO()" internal/
Goroutine leak in pproferrgroup not used / unclosed channelsgrep -rn "go func\b" internal/
Test passes locally, race on CIShared mutable statego test ./... -race
Panic crashes serverMissing recover middlewaregrep -rn "recover()" internal/server/
Downstream API change broke usProvider parsergrep -rn "json.Unmarshal|json.NewDecoder" internal/providers/

Pick one layer. Do not touch any other layer in this debug pass.


Step 2 — Run the 5 most common Go antipattern greps

bash
# Antipattern 1: http.DefaultClient (no per-provider isolation)
grep -rn "http\.DefaultClient" internal/

# Antipattern 2: context.Background() / context.TODO() in non-main code
grep -rn "context\.Background()\|context\.TODO()" internal/ \
  --include="*.go" | grep -v "_test.go"

# Antipattern 3: panic in production code
grep -rn "panic(" internal/ --include="*.go" | grep -v "_test.go\|recover"

# Antipattern 4: fmt.Println / log.Printf instead of slog
grep -rn "fmt\.Println\|log\.Printf" internal/ --include="*.go" | grep -v "_test.go"

# Antipattern 5: errors not wrapped with %w
grep -rn "errors\.New(\"[^%]*: \"" internal/ --include="*.go"
# Hits with concatenation suggest a missed `%w` opportunity.
ResultRoot causePrinciple
http.DefaultClient usedBulkhead broken — one slow downstream blocks allF4
context.Background() in handler chainLost cancellation/deadline propagationF2
panic() in handler/serviceServer crashes on edge caseF3
fmt.Println/log.PrintfLogs without context, unsearchableF6
errors.New with concatenated contextLost error chain, errors.Is/As failsF3

Step 3 — Reproduce with go test -run and -race

For service/repo bugs — write a failing test first:

go
func TestService_RaceOnConcurrentCharge(t *testing.T) {
    t.Parallel()
    svc := newTestService(t, dec("10.00"))
    ctx := context.Background()

    // Two concurrent charges with the same idempotency key.
    // Should hold once, not twice.
    var wg sync.WaitGroup
    var ids [2]string
    for i := 0; i < 2; i++ {
        i := i
        wg.Add(1)
        go func() {
            defer wg.Done()
            id, _ := svc.Charge(ctx, "u-1", dec("4.00"), "idem-x")
            ids[i] = id
        }()
    }
    wg.Wait()
    if ids[0] != ids[1] {
        t.Fatalf("idempotency violated: %s vs %s", ids[0], ids[1])
    }
}

Run it:

bash
go test -run TestService_RaceOnConcurrentCharge -race -v ./internal/credits/

It must FAIL before the fix.

For HTTP client / provider bugs — use httptest.Server to simulate the failure:

go
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
    w.WriteHeader(http.StatusTooManyRequests)
}))
defer srv.Close()

p := &FalAI{client: srv.Client(), baseURL: srv.URL, log: slog.Default()}
_, err := p.Generate(context.Background(), JobRequest{ModelID: "m", Prompt: "p"})
if !errors.Is(err, ErrRateLimited) {
    t.Fatalf("expected ErrRateLimited, got %v", err)
}

Step 4 — Fix in the correct layer

Minimum change. Do not refactor unrelated code.

LayerWhere to fix
Handler / error → HTTP codeinternal/server/handlers.go
Business logicinternal/<domain>/service.go
Persistence / concurrencyinternal/<domain>/repository.go
External API parsinginternal/providers/<name>.go (the ACL)
HTTP client configinternal/httpclient/client.go
Logging contextinternal/context/keys.go + middleware
Graceful shutdowninternal/server/run.go

Goroutine leaks specifically: add errgroup with a parent context.WithCancel. Every go func should be replaceable by g.Go(func() error { ... }). (Principle F8.)


Step 5 — Verify

bash
# Type / vet check
go vet ./...

# Race detector — catches concurrency bugs you can't see by reading
go test ./... -race

# All tests pass
go test ./...

# (If you have a linter)
golangci-lint run

Then re-run all 5 antipattern greps from Step 2. You must not have introduced any new violations while fixing.


Common error → root cause table

Error / SymptomWhere to lookLikely cause
runtime error: invalid memory addressnil pointerA struct field not initialized — check the constructor
concurrent map read and writeshared mutable mapAdd sync.Mutex or use sync.Map if read-heavy
context deadline exceeded cascading everywhereparent ctxProbably a fixed context.WithTimeout(ctx, 1s) upstream
dial tcp: i/o timeoutnetwork or DNSCheck provider client Timeout; check pod DNS
too many open filesFD exhaustionBulkhead violation (F4): a hung downstream eating the pool
Test hangs foreverUnbuffered channelProducer goroutine exited without sending; receiver waits forever
interface conversion: ... is not ...wrong concrete typeHandler accepts a too-wide interface; tighten with the smallest method set
Panic mid-request, server stays up but log is silentrecover swallowsMake sure the recover middleware logs rec and debug.Stack()
Server doesn't drain on SIGTERMsignal.Notify not wiredUse signal.NotifyContext (Go 1.16+) — Principle F7
Provider response field appears null after parseUnmarshal hit zero valueCheck JSON tag spelling; use *string if true-null matters

Verification

The skill was applied correctly when:

  • A reproducible test exists (Step 3) — failing before, passing after
  • Fix touches exactly one layer
  • All 5 antipattern greps still come up clean
  • go vet ./... && go test ./... -race exits 0
  • No new file exceeds 500 LOC; no new package named utils/helpers/common

Frequently asked questions

What does the Debug Go AI skill do?

Systematic 5-step debugging flow for Go 1.22+ services. Load when a test fails, a goroutine leaks, a downstream provider hangs, errors lose context, or production logs are unhelpful. Forces layer isolation (handler vs service vs repo vs provider) and runs the 5 most common Go antipattern greps before any code change — prevents the "add a goroutine to fix a slow handler" cascade.

Why use Debug Go on TypingMind?

Because you install it once and use it with any model. Debug Go is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Debug Go in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/yerdaulet-damir/vibe-coding-rules/tree/main/.claude/skills/debug-go. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Debug Go?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Debug Go?

As many as you like. As long as a model supports skills, you can use Debug Go with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Debug Go AI skill free?

Yes. It is published on GitHub by yerdaulet-damir under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇