원클릭으로
arib-dev-debug
Dev | Scientific debugging - observe, 3 hypotheses, test, fix, verify, document
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Dev | Scientific debugging - observe, 3 hypotheses, test, fix, verify, document
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | arib-dev-debug |
| argument-hint | <issue-description> |
| description | Dev | Scientific debugging - observe, 3 hypotheses, test, fix, verify, document |
Activate scientific debugging protocol to systematically diagnose and fix issues using hypothesis testing, not guessing.
User types /arib-dev-debug [description]
Example: /arib-dev-debug API timeout errors in user registration
Debugging is a science: observe behavior, form testable hypotheses, run experiments, narrow down root cause. Wild guesses waste hours. This protocol forces systematic thinking: 3 different hypotheses, test one at a time, gather evidence before moving on, prevent regression with tests.
Enter focused debugging mode. Set context to:
Obtain the exact error message:
Read and analyze:
bugs_and_fixes.md - Search for similar error patternsERROR_PATTERNS.md - Check for known pitfalls in this area of codeError: Button state not updating after click
Hypotheses:
Error: Request timeout, works sometimes but not always
Hypotheses:
Error: User data shows as undefined in component
Hypotheses:
Error: Feature works locally but not in production
Hypotheses:
Based on the error and known patterns, form exactly 3 testable hypotheses:
Document each hypothesis clearly with supporting evidence.
Symptom: Request times out intermittently
1. Baseline: Measure time with no modifications
2. Split: Remove half the code/features
3. Measure: Does timeout still occur?
├─ YES (timeout with half): bug in remaining half, go to step 2
└─ NO (no timeout): bug in removed half, restore and split again
4. Repeat until isolated to single function/query
Add logging/debugging to isolate the issue
// Before API call
console.time('fetchUsers');
const users = await fetch('/api/users');
console.timeEnd('fetchUsers');
// Output: fetchUsers: 234.5ms
Create a minimal reproduction case
// Isolated test case
const test = async () => {
const result = await problematicFunction(testData);
console.log('Result:', result);
console.assert(result.isValid, 'Expected result to be valid');
};
test();
Verify the hypothesis with evidence
If confirmed, proceed to fix
If not confirmed, move to next hypothesis
Document findings after each test:
## Hypothesis A: State not updating
- Test: Added console.log in onClick handler
- Result: CONFIRMED - handler fires, but setState shows stale value
- Evidence: State updates but component not re-rendering
- Next: Check if component wrapped in React.memo
| Language | Tool | Usage |
|---|---|---|
| JavaScript | DevTools Console | console.log(), breakpoints, debugger |
| JavaScript | Chrome DevTools Network | See API calls, latency, response |
| TypeScript | VS Code Debugger | Set breakpoints, step through code |
| React | React DevTools | Inspect component state, props, re-renders |
| Node.js | node --inspect | Remote debugging via Chrome DevTools |
| Python | pdb | import pdb; pdb.set_trace() |
| Python | logging | logging.debug() for production diagnostics |
| SQL | EXPLAIN PLAN | EXPLAIN SELECT... to see query performance |
| Docker | docker logs | docker logs [container] for service issues |
Test one hypothesis at a time in this order:
Document findings after each test.
Once root cause is confirmed:
After fixing, add tests to prevent this bug from returning:
Unit Test (test the specific fix):
test('user button click updates state', () => {
const { getByText } = render(<UserButton />);
fireEvent.click(getByText('Click me'));
expect(getByText('Clicked!')).toBeInTheDocument();
});
Integration Test (test the full flow):
test('user data loads and displays on page load', async () => {
const { getByText } = render(<Dashboard />);
await waitFor(() => expect(getByText('Alice')).toBeInTheDocument());
});
Performance Test (if it was a perf issue):
test('fetch users completes in < 500ms', async () => {
const start = performance.now();
await fetchUsers();
const duration = performance.now() - start;
expect(duration).toBeLessThan(500);
});
Verification Checklist:
Document in bugs_and_fixes.md:
## Bug: User registration timeout errors
**Original Error:** "API timeout during user registration"
**Frequency:** Intermittent, ~5% of registrations
**Discovered:** 2024-04-15
**Fixed:** 2024-04-16
### Root Cause
N+1 queries: User signup endpoint fetches all users to check email uniqueness.
With 1M users, query takes 500ms, hitting 1s timeout.
### Fix Applied
Added database index on email column, reducing query time to 10ms.
```sql
CREATE INDEX CONCURRENTLY idx_users_email ON users(email);
### Step 8: Commit Changes
Create a clear commit message:
git commit -m "Fix: API timeout during user registration
Root cause: N+1 queries on email uniqueness check Fix: Added database index on email column Tests: Unit test for email query latency, integration test for signup flow Performance improvement: 500ms → 10ms per signup
Fixes issue #1234"
## Root Cause Analysis Template
[One sentence describing the problem]
[Describe the fix in 1-2 sentences]
## Common Mistakes
1. **Fixing the symptom, not the cause** - Adding retry logic hides timeout; fixing N+1 query solves it
2. **Over-testing the fix** - If you test wrong thing, you won't know when it breaks again
3. **Not documenting why the bug happened** - Next developer will make same mistake
4. **Testing in isolation** - Bug may only appear under load; test with production-scale data
5. **No regression test** - Fix passes once, but breaks again with next change
## Edge Cases & Debugging Scenarios
| Scenario | Debugging Technique |
|----------|---|
| Intermittent bug | Binary search (disable features until it disappears) |
| Slow API | Measure: curl, DevTools network, APM traces |
| Memory leak | Monitor process memory over time, heap dump analysis |
| Silent failure | Add error logging, check error boundaries, network tab |
| Flaky test | Run 100x in a loop; if fails even once, it's a race condition |
| Different environments | Config diff (local vs prod), dependency versions, data volume |
## Related Skills
- `/arib-check-services` - Verify backend services running (not a code bug)
- `/arib-check-reality` - Is data actually coming from real API? (not a mock issue)
- `/arib-check-perf` - Is this a performance issue? (timing issues)
## Notes
- Never guess - test each hypothesis with evidence
- Document everything for the bugs_and_fixes.md knowledge base
- Hypotheses should be different approaches, not variations
- Always add regression tests
- Share findings to help future debugging efforts
- One hypothesis per iteration - no parallel testing
- Fastest debugging: measure/profile, don't estimate
Memory | Code-graph subsystem — a native lightweight IMPORT graph (which file imports which, god-node candidates) built with ripgrep/grep, so a large monorepo can be navigated by structure instead of re-grepping every session. build/refresh/query. Honest scope: structural import graph, NOT semantic (no call-graph/type resolution); no Graphify dependency. Loads ON DEMAND only (zero always-on tokens). ADR-034.
Dev | Over-engineering review — reads a diff/module and returns a delete-list of bloat (single-use abstractions, premature generalization, speculative config, dead options) WITHOUT stripping legitimate structure. Advisory: returns recommendations, never auto-deletes. The on-demand companion to the ponytail-lite tripwire hook. Authored natively (no Ponytail dependency). ADR-033.
Wave | Pre-wave requirement lock — Act 1 derives the requirements from the codebase + memory (an honest grill, not guesswork), Act 2 hands the locked plan to an independent model (Codex) to tear apart until sign-off. Produces waves/<id>/PLAN.md + PLAN-REVIEW-LOG.md. Auto-chained idempotently from /arib-wave-start. If Act 2 can't run (no Codex), the wave proceeds but HOLDS MERGE for a human. Absorbs grill-me-codex (ADR-032).
Wave | Start a multi-session delivery wave — branch, plan, parallel architect+planner
Engine | Command the engineering team to deliver a known goal — dispatches the engineer-manager to decompose → dispatch specialists (parallel where safe) → integrate → reconcile (verification-agent) → merge gate. Scales its own reach: runs inline for a bounded goal, escalates to a parallel Workflow for a broad one, and paces under /loop for a multi-turn campaign — only when it needs to. Use when a goal needs a coordinated TEAM, not one specialist. Sibling of /arib-engine: the engine DISCOVERS its own backlog; /arib-build EXECUTES a goal you hand it.
Stack | NestJS architecture & patterns reference — modules/providers/DI, DTO+validation, guards/interceptors/pipes/filters, config, async lifecycle, testing, and the security + performance pitfalls that bite at scale. Use when building or reviewing a NestJS backend. Composes with security-auditor (OWASP), database-guardian (TypeORM/Prisma migrations), and performance (N+1). Authored natively (the ECC graft was unsourceable; this is CCM's own, MIT).