Systematic bug hunting combining Sherpa's debugging workflow, Julie's execution tracing, and Goldfish's investigation tracking...
Conduct systematic, methodical bug investigations using detective-style debugging. This workflow combines Sherpa's bug hunt phases, Julie's execution tracing, and Goldfish's investigation logging to find and fix bugs confidently.
Use when the user:
1. Goldfish recall({ search: "[error/bug description]" })
→ See if similar bug investigated before
2. Learn from previous investigations
3. If same bug → Resume investigation
4. If new → Start fresh investigation
Sherpa Activation:
approach({ workflow: "bug-hunt" })
guide() → "Phase 1: Reproduce & Isolate - Find the crime scene!"
Error Discovery: User reports: "Getting 'Invalid token' error"
Julie Investigation:
fast_search({ query: "Invalid token", mode: "lines" })
→ Find all error message locations
fast_goto on error location
→ Jump to where error is thrown
trace_call_path({ symbol: "validateToken", direction: "upstream" })
→ See what calls this (who triggers the error?)
Reproduce Reliably:
Goldfish Investigation Log:
checkpoint({
description: "Isolated 'Invalid token' error: thrown in validateToken() when refresh tokens expire, called from authenticate() middleware",
tags: ["bug-hunt", "investigation", "phase-1", "auth"]
})
Sherpa Progress:
guide({ done: "reproduced bug: token validation fails with expired refresh tokens" })
→ 🕵️ "Excellent detective work! The case is taking shape..."
→ "Phase 2: Capture in Test"
Sherpa Guidance:
guide() → "Phase 2: Capture in Test - Document the crime!"
Julie Pattern Search:
fast_search({ query: "token validation test examples", mode: "semantic" })
→ Find similar test patterns
get_symbols({ file: "tests/auth.test.ts", mode: "structure" })
→ See existing test structure
Write Failing Test:
Run test → Fails (as expected!)
Goldfish Checkpoint:
checkpoint({
description: "Created failing test: 'should handle expired refresh tokens gracefully' - reproduces Invalid token error",
tags: ["bug-hunt", "test", "phase-2", "auth"]
})
Sherpa Progress:
guide({ done: "wrote failing test that reproduces the expired token bug" })
→ 🎯 "Perfect! You've documented the crime. Now let's solve it!"
→ "Phase 3: Fix the Bug"
Sherpa Guidance:
guide() → "Phase 3: Fix - Solve the mystery!"
Julie Code Understanding:
get_symbols({ file: "src/auth/jwt.ts", mode: "full" })
→ Understand token validation logic
trace_call_path({ symbol: "validateToken", direction: "downstream" })
→ See what validateToken calls (jwt.verify, etc.)
fast_refs({ symbol: "refreshToken" })
→ See all refresh token usage
Analysis:
Implement Fix:
// Add expiration check
if (isRefreshTokenExpired(token)) {
throw new TokenExpiredError('Refresh token expired');
}
Run test → Passes! ✅
Goldfish Checkpoint:
checkpoint({
description: "Fixed expired token bug: added expiration check in validateToken, test now passes",
tags: ["bug-hunt", "fix", "phase-3", "auth", "test-pass"]
})
Sherpa Progress:
guide({ done: "implemented fix for expired tokens, failing test now passes" })
→ 🎉 "Case solved! The bug has been caught!"
→ "Phase 4: Verify & Prevent"
Sherpa Guidance:
guide() → "Phase 4: Verify - Close the case with confidence!"
Verification Steps:
Julie Impact Analysis:
fast_refs({ symbol: "validateToken" })
→ See all usage points (15 locations)
→ Verify fix doesn't break anything
Prevention:
Goldfish Final Checkpoint:
checkpoint({
description: "Bug hunt complete: expired token handling fixed and verified. Added 3 additional tests for edge cases. All 18 auth tests passing.",
tags: ["bug-hunt", "complete", "phase-4", "auth", "verified"]
})
Sherpa Completion:
guide({ done: "verified fix across all test cases, added prevention tests, all tests green" })
→ 🌟 "Bug Hunt Complete! Detective work at its finest!"
→ Potential milestone: "🏆 Milestone: Bug Detective Mastery!"
User: "Users are getting randomly logged out"
=== SESSION START ===
→ Goldfish: recall({ search: "logout session" })
No previous investigation. New case!
=== PHASE 1: REPRODUCE & ISOLATE ===
→ Sherpa: approach({ workflow: "bug-hunt" })
🕵️ Bug Hunt Workflow activated!
→ Sherpa: guide()
"Phase 1: Reproduce & Isolate"
→ Julie: fast_search({ query: "logout session destroy", mode: "semantic" })
Found: session.ts, auth-middleware.ts
→ Julie: trace_call_path({ symbol: "logout", direction: "both" })
Execution flow:
- logout() calls session.destroy()
- authenticate() checks session.exists()
- Race condition: destroy happens while checking!
→ Goldfish: checkpoint({
description: "Isolated race condition: session.destroy() can execute during session.exists() check, causing random logouts",
tags: ["bug-hunt", "investigation", "race-condition"]
})
→ Sherpa: guide({ done: "found race condition between session destroy and exists check" })
🕵️ "Aha! A race condition! Classic mystery..."
=== PHASE 2: CAPTURE IN TEST ===
→ Sherpa: guide()
"Phase 2: Capture in Test"
→ Write test with concurrent operations:
- Simulate logout during auth check
- Reproduce race condition
- Test fails (intermittently - race condition!)
→ Goldfish: checkpoint({
description: "Created failing test: 'should handle concurrent logout during auth' - reproduces race condition",
tags: ["bug-hunt", "test", "phase-2", "race-condition"]
})
→ Sherpa: guide({ done: "wrote test that reproduces race condition" })
🎯 "Documented the crime!"
=== PHASE 3: FIX THE BUG ===
→ Sherpa: guide()
"Phase 3: Fix the Bug"
→ Julie: get_symbols({ file: "src/session.ts", mode: "full" })
Understand session management
→ Solution: Add mutex/lock for session operations
→ Implement fix with proper locking
→ Test passes consistently! ✅
→ Goldfish: checkpoint({
description: "Fixed race condition: added mutex for session operations, test now passes consistently",
tags: ["bug-hunt", "fix", "phase-3", "race-condition"]
})
→ Sherpa: guide({ done: "fixed race condition with mutex, test passes" })
🎉 "Mystery solved!"
=== PHASE 4: VERIFY & PREVENT ===
→ Sherpa: guide()
"Phase 4: Verify & Prevent"
→ Run full test suite → All pass ✅
→ Stress test with 100 concurrent operations → Stable! ✅
→ Julie: fast_refs({ symbol: "session" })
Check all session usage → All safe
→ Goldfish: checkpoint({
description: "Race condition fix verified: stress tested with 100 concurrent ops, added 5 concurrency tests, all 23 session tests pass",
tags: ["bug-hunt", "complete", "verified", "race-condition"]
})
→ Sherpa: guide({ done: "verified fix under stress, added prevention tests" })
🌟 "Bug Hunt Complete! Case closed!"
trace_call_path shows WHO calls buggy code:
- Identify entry points
- See call chain
- Understand flow
fast_search for error patterns:
- Find related errors
- See similar issues
- Learn from fixes
fast_refs shows WHERE code is used:
- Impact analysis
- Breaking change detection
- Edge case discovery
checkpoint({
description: "Discovered: [finding]",
tags: ["discovery", "hypothesis"]
})
checkpoint({
description: "Hypothesis: [theory about root cause]",
tags: ["hypothesis", "analysis"]
})
checkpoint({
description: "Solution: [fix description]",
tags: ["solution", "fix"]
})
Benefit: Investigation trail is preserved even across context resets!
Bug Detective succeeds when:
Result: Systematic debugging that finds root causes fast!
Remember: Every good detective documents their investigation. Sherpa guides, Julie traces, Goldfish preserves. Together, they solve the mystery!