Windsurf Track
Module 29
Windsurf Track -- Module 29
Debugging a ShopMate Bug: Customers report that ShopMate is occasionally replying with the wrong store's return policy -- PetThreads policy showing up in ThreadCo chat sessions. The bug is intermittent and hard to reproduce. This module shows how Cascade's codebase awareness tracks down the tenant isolation bug in 20 minutes.

AI-Assisted Debugging Workflows

Debugging is where Windsurf's terminal integration and codebase awareness deliver the most dramatic productivity gains. This module covers systematic debugging flows that leverage Cascade's ability to read errors, trace call stacks, and iterate on fixes autonomously.

Error-First Debugging

Paste the full error and stack trace into a Flow prompt: "Fix this error -- include the full context of why it occurs." Cascade reads the stack trace, traverses the call chain across files, identifies the root cause, and proposes a fix with an explanation.

Test-Driven Debugging

Ask Cascade to write a failing test that reproduces the bug, then fix the implementation to make it pass. This creates a regression guard and forces the fix to be precise rather than masking the symptom.

Terminal-Loop Debugging

Start a Flow, let Cascade make changes, run the test suite in terminal, read the output, and iterate. Cascade can loop autonomously through run-fail-fix-run cycles until tests pass. You watch; you do not need to intervene.

Differential Debugging

Describe what changed and when the bug started: "This worked last week. Since we upgraded SQLModel to 0.0.14 the relationship loading breaks." Cascade narrows the search space dramatically with this context.

Debugging Flow Template

Prompt Template -- Systematic Debug Flow
Bug report:
[Describe what you expected vs what actually happened]

Error output:
[Full error message and stack trace]

Steps to reproduce:
[Minimal reproduction steps]

Context:
[Recent changes, version upgrades, environment differences]

Task:
1. Identify the root cause -- explain your reasoning
2. Write a failing test that reproduces the bug
3. Fix the implementation to make the test pass
4. Verify no existing tests regress
5. Add a comment explaining why the bug occurred
!
Always Provide the Full Stack Trace

Truncated error messages dramatically reduce Cascade's ability to locate the root cause. Always paste the complete stack trace, including the outermost caller. If the trace is very long, include the first 20 lines and the last 20 lines -- the entry point and the failure point are what matter.

ShopMate -- Debug the Tenant Isolation Bug

Text -- Debug Flow: Wrong Brand Voice
# The bug: PetThreads product descriptions are using ThreadCo's voice.
# Paste this into Cascade (Cmd+I):

BUG: ShopMate is using ThreadCo's brand voice when generating descriptions
for PetThreads. Customers are complaining the PetThreads site sounds too serious.

Evidence:
- describe_for_brand("petthreads", product) returns a ThreadCo-style description
- No exclamation marks, no playful language -- should have both per brands.yaml
- ThreadCo descriptions seem fine

Reproduction:
  from shopmate.multi_brand import describe_for_brand
  product = {"name": "Paw Print Tee", "material": "organic cotton", "price": 27.99}
  result = describe_for_brand("petthreads", product)
  # Expected: playful, pet-focused, exclamation marks OK
  # Got: serious ThreadCo-style copy

Task:
1. Find the bug in @shopmate/multi_brand.py and @shopmate/config/brands.yaml
2. Write a failing test in tests/test_multi_brand.py that checks brand voice isolation
3. Fix the bug
4. Run: pytest tests/test_multi_brand.py -v to verify