| name | debug-investigate |
|---|---|
| description | Use when investigating bugs, diagnosing failures, debugging runtime issues, or when a fix attempt hasn't worked. Provides structured debugging workflow: instrument first, gather evidence, never commit speculative fixes, mobile bug handling. |
If structured logging or error handling is missing from the code under investigation, add it FIRST. Treat missing instrumentation as a bug to fix before diagnosing the actual issue.
// Add before the suspected failure point:
logger.info({ operation: 'functionName', input: relevantData }, 'Starting operation');
try {
// ... suspected code ...
logger.info({ operation: 'functionName', result }, 'Operation succeeded');
} catch (err) {
logger.error({ operation: 'functionName', err: err.message, input: relevantData }, 'Operation failed');
throw err;
}Do NOT commit speculative fixes. Instead:
- Add diagnostic logging at suspected failure points
- Run the failing scenario
- Read the logs/output
- Identify the actual root cause from evidence
If a fix doesn't work on the first attempt, STOP guessing. Add more diagnostics instead.
Only commit a fix when you have:
- Clear evidence of what was wrong (log output, error message, stack trace)
- Confidence the fix addresses the root cause (not just a symptom)
- Verified the fix works (ran the scenario again)
Once uncommitted changes resolve the issue:
- Run
git addandgit commitimmediately - Do NOT continue investigating root causes or alternatives
- Ask the user if they want deeper analysis after committing
For 4xx/5xx errors in edge functions:
- Check structured logs first (
console.erroroutput in Supabase dashboard or local serve) - Verify env vars are loaded (check
--env-fileflag orsupabase secrets list) - If logs insufficient, request the Network tab payload from the user
- Playwright/emulator taps bypass real hit-testing — don't trust emulation for touch bugs
- Secure-context checks differ — features requiring HTTPS may work in emulator but fail on device
- iOS Safari auto-zoom — triggered by inputs with font-size < 16px. Fix: use
text-base - Mobile bugs require runtime evidence — test on a real device or ask user for screenshots/recordings
The Supabase JS client returns { error: null } when RLS blocks DELETE/UPDATE — it affects 0 rows silently. Verify with:
const { count, error } = await supabase.from('table').delete({ count: 'exact' }).eq('id', id);
if (!count) console.error('RLS may have blocked this operation');If getting 401 on a function that should work:
- Check if using new key format (
sb_secret_...) vs old JWT (eyJhbGci...) - Verify the env var name matches what the function reads (
SB_SECRET_API_KEYvsSUPABASE_SERVICE_ROLE_KEY) - Check if the function expects
apikeyheader vsAuthorization: Bearerheader
If UI isn't updating after a successful operation:
- Check if the service function returns the updated data
- Verify the component re-renders (add a
console.login the render body) - Check if there's a stale closure (common with
useEffectdependencies)
After committing the fix, co-invoke related skills:
- If the fix touched visual presentation, layout, or CSS → invoke
/ux-reviewto verify UX compliance - If tests exist for the affected component → invoke
/frontend-testto run them