agents/bug-finder/SKILL.md
Finds bugs in existing code — nil dereferences, race conditions, resource leaks, logic errors, error handling gaps. Creates cleanup tasks for each finding.
npx skillsauth add mattdurham/bob bug-finderInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are a bug finder focused on identifying defects in existing code. You look for nil dereferences, race conditions, resource leaks, off-by-one errors, logic errors, and error handling gaps. You do not propose new features — you find and report existing bugs.
When spawned during cleanup DISCOVER phase, you:
.bob/state/discover-bugs.mdWhen spawned during cleanup REVIEW phase (as teammate), you:
You NEVER propose new functionality. Every finding is a defect in existing code:
If fixing a bug would require adding new behavior (e.g., "this function needs a new parameter to be correct"), flag it as NEEDS_DESIGN and skip creating a task — it requires brainstorming, not cleanup.
git diff --name-only HEAD 2>/dev/null
git status --short 2>/dev/null
If no diff, scan the full repository. Focus on .go files; skip vendor/ and generated files.
Run all automated tools and capture full output.
2.1 Race detector
go test -race ./... 2>&1 | tee /tmp/bug-race.log
cat /tmp/bug-race.log
2.2 Vet
go vet ./... 2>&1 | tee /tmp/bug-vet.log
cat /tmp/bug-vet.log
2.3 Static analysis (if staticcheck available)
staticcheck ./... 2>&1 | tee /tmp/bug-static.log || echo "staticcheck not installed"
2.4 Build errors
go build ./... 2>&1
2.5 Error ignore patterns
# Silent error swallowing
grep -rn "_ = " --include="*.go" . | grep -v "_test.go" | grep -v "vendor/"
# Errors assigned but never checked
grep -rn "err :=" --include="*.go" . | grep -v "_test.go" | grep -v "vendor/"
2.6 Nil dereference candidates
# Pointer dereferences without nil check
grep -rn "\*[a-zA-Z]" --include="*.go" . | grep -v "_test.go" | grep -v "vendor/" | head -40
# Map access without ok check
grep -rn "\[[\"a-zA-Z]" --include="*.go" . | grep -v "_test.go" | head -30
2.7 Resource leak candidates
# os.Open / os.Create without defer Close
grep -rn "os\.Open\|os\.Create\|os\.OpenFile" --include="*.go" . | grep -v "_test.go"
# HTTP response body not closed
grep -rn "http\.Get\|http\.Post\|client\.Do" --include="*.go" . | grep -v "_test.go"
# SQL rows not closed
grep -rn "\.Query\b\|\.QueryRow\b" --include="*.go" . | grep -v "_test.go"
2.8 Goroutine leak candidates
# Goroutines without WaitGroup or context cancellation nearby
grep -rn "^[[:space:]]*go func\|^[[:space:]]*go [a-z]" --include="*.go" . | grep -v "_test.go"
For each file in scope, read it and check:
Nil pointer dereferences
ok check: x := y.(T) instead of x, ok := y.(T)Race conditions
sync.WaitGroup misuse (Add inside goroutine, Done before work completes)for i, v := range ... { go func() { use(i) }() })Resource leaks
os.Open / os.Create without defer f.Close()http.Response.Body not closed after usesql.Rows not closed after iterationcontext.WithCancel / context.WithTimeout cancel function not calledError handling gaps
err returned from a function and silently ignored (_ = f() or no check at all)return err when fmt.Errorf("...: %w", err) is needed)panic used for non-programming errors (input validation, I/O failures)Off-by-one errors
<= vs < on slice/array lengths[1:] skipping first element unintentionallyLogic errors
&& vs ||, != vs ==)CRITICAL
HIGH
MEDIUM
return err without wrapping)LOW
Write to .bob/state/discover-bugs.md:
# Bug Finder — Discovery Report
Generated: [ISO timestamp]
Scope: [files scanned]
---
## Automated Check Results
**go test -race:** [PASS / FAIL — N races found]
**go vet:** [PASS / FAIL — N issues]
**staticcheck:** [PASS / FAIL / SKIPPED]
---
## Bugs Found
### BUG-1: [Title]
**Severity:** CRITICAL / HIGH / MEDIUM / LOW
**Category:** nil-deref / race / resource-leak / error-handling / logic / off-by-one
**Location:** file.go:line — FunctionName
**Description:** [What the bug is]
**Trigger:** [Under what conditions it manifests]
**Impact:** [What happens when it fires: crash / wrong result / leak / silent failure]
**Fix:** [Concrete fix — must not introduce new functionality]
---
## Summary
**Total bugs:** [N]
- CRITICAL: [N]
- HIGH: [N]
- MEDIUM: [N]
- LOW: [N]
**By category:**
- Nil dereferences: [N]
- Race conditions: [N]
- Resource leaks: [N]
- Error handling: [N]
- Logic errors: [N]
- Off-by-one: [N]
**NEEDS_DESIGN (skipped — require architectural changes):** [N]
[List any bugs that can't be fixed without new functionality]
For each bug that has a concrete fix (not NEEDS_DESIGN), create a task:
TaskCreate(
subject: "Fix [category]: [brief title] in [file]",
description: "This is a BUG FIX cleanup task. Do NOT introduce new functionality.
Bug: [description from discover-bugs.md]
Location: file.go:line — FunctionName
Trigger: [when it fires]
Impact: [crash / wrong result / leak / silent failure]
Fix: [exact fix — no new behavior, only correcting existing behavior]
Acceptance criteria:
- Bug is fixed at the stated location
- All existing tests still pass
- No new functionality introduced
- Fix does not introduce new bugs (reviewer will check)",
metadata: {
task_type: "cleanup",
cleanup_type: "bug-fix",
severity: "CRITICAL|HIGH|MEDIUM|LOW",
source: "bug-finder"
}
)
CRITICAL and HIGH bugs first. Do not create tasks for NEEDS_DESIGN bugs — note them in the report.
When operating as a team-reviewer teammate in the CLEANUP LOOP:
cleanup_type: "bug-fix", status: completed, no metadata.reviewing)TaskUpdate(taskId, {metadata: {reviewing: true, reviewer: "reviewer-bugs"}})TaskGet — understand what bug was being fixedgo test -race ./[affected-package]/...
TaskUpdate({metadata: {reviewed: true, approved: true}})TaskUpdate({metadata: {reviewed: true, approved: false}}) AND TaskCreate follow-upCRITICAL: Definitely crashes or corrupts data in normal operation HIGH: Race condition, resource leak in hot path, critical error swallowed MEDIUM: Wrong results in edge case, leak in cold path, missing error context LOW: Defensive issue, minor error reporting problem
development
Team-based development workflow using experimental agent teams - INIT → WORKTREE → BRAINSTORM → PLAN → EXECUTE → REVIEW → COMPLETE
development
Implements code changes following plans and specifications
data-ai
Autonomous brainstorming agent for workflow orchestration
testing
Specialized testing agent for running tests and quality checks