debugging-mindset
Skill4 starsChanged 9 months agoMITView on GitHub
Use this skill when debugging code, diagnosing unexpected behavior, troubleshooting errors, or approaching a problem systematically. Trigger on keywords: debug, bug, error, not working, unexpected behavior, troubleshoot, investigate, root cause, why is this, something is wrong, failing test, crash.
In this repository37 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- ai-agent-designSkill
- ai-assisted-learningSkill
- ai-prompting-patternsSkill
- api-designSkill
- backend-devSkill
- career-growthSkill
- client-communicationSkill
- code-explanationSkill
- code-readingSkill
- code-reviewSkill
- cross-functional-collabSkill
- database-designSkill
- devops-cicdSkill
- doc-creationSkill
- focus-productivitySkill
- frontend-designSkill
- git-workflowSkill
- incident-responseSkill
- internal-commsSkill
- interview-prepSkill
- mcp-builderSkill
- performance-reviewSkill
- problem-solvingSkill
- prompt-engineeringSkill
- research-synthesisSkill
- resume-portfolioSkill
- self-healing-mindsetSkill
- side-project-planningSkill
- sprint-planningSkill
- system-designSkill
- technical-communicationSkill
- technical-mentoringSkill
- tech-researchSkill
- testingSkill
- threat-modelingSkill
- web-artifacts-builderSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. About 0 are common, 18 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈18
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 28
Never skip step 7. Every bug is a test that doesn't exist yet.
- Distinctive: line 34
Before writing a single line of debug code, answer these:
- Distinctive: line 92
Check if the issue is data (wrong value) or rendering (correct value, wrong display)
- Distinctive: line 94
Check browser compatibility if intermittent
- Distinctive: line 97
Check request payload first — is the input correct?
- Distinctive: line 98
Check database state — is the data what you expect?
- Distinctive: line 100
Add temporary logging at key points to see actual values
- Distinctive: line 103
Run the query directly against the DB (not through ORM)
- Distinctive: line 104
Check actual data vs expected data
- Distinctive: line 106
Check indexes for slow queries
- Distinctive: line 109
Add comprehensive logging — capture state at every step
- Distinctive: line 110
Look for shared mutable state
- Distinctive: line 111
Check for timing dependencies
- Distinctive: line 113
Check for memory leaks or resource exhaustion
- Distinctive: line 130
After 20-30 minutes without progress:
- Distinctive: line 153
Document: if the root cause was non-obvious
- Distinctive: line 155
Update the lessons log: if it was a new class of mistake you want to remember
- Distinctive: line 156
Commit message: should explain the root cause, not just the fix:
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Debugging Mindset
Core Principle
Debug the system, not your assumptions.
Most bugs persist because developers debug what they think is happening instead of what's actually happening. Every assumption is a potential hiding place for a bug.
The Scientific Debugging Method
1. OBSERVE — What exactly is the symptom? (not interpretation, raw facts)
2. HYPOTHESIZE — What are the possible causes?
3. TEST — Design the smallest possible test to confirm/deny each hypothesis
4. CONCLUDE — What does the evidence tell you?
5. FIX — Address the root cause, not the symptom
6. VERIFY — Confirm the fix works and nothing else broke
7. PREVENT — Add a test that would catch this regressionNever skip step 7. Every bug is a test that doesn't exist yet.
Start Here: The Five Questions
Before writing a single line of debug code, answer these:
- What did I expect to happen?
- What actually happened? (exact error message, exact output)
- What changed recently? (last commit, dependency update, config change)
- Can I reproduce it reliably? (if not, it might be timing/state/environment)
- Is this the first time this happened? (regression vs new bug)
Answering these five questions often reveals the bug before you even look at code.
Divide and Conquer
For complex bugs in large codebases:
1. Identify the full path of execution involved
2. Pick the midpoint
3. Add a check there — does the data look correct?
4. If yes → bug is in second half. If no → bug is in first half.
5. Repeat until you've narrowed to a single function or line.This is binary search for bugs. Cuts debugging time in half at each step.
Read the Error Message (Actually Read It)
Most developers skim error messages. Read them:
- What failed (error type)
- Where it failed (file, line, function name)
- Why it failed (message body)
- Stack trace — read bottom-up to find your code vs framework code
For cryptic errors: paste the exact error into the AI with context, not a paraphrase.
Common Bug Patterns
| Pattern | Signs | Fix |
| Off-by-one | Wrong count, first/last element skipped | Check loop bounds and index math |
| Null / undefined | "Cannot read property of undefined" | Add null guards, check API contracts |
| Async/await | Data appears empty, timing-sensitive | Ensure every async call is awaited |
| Stale state | Works sometimes, not always | Check state mutation, cache invalidation |
| Type mismatch | Unexpected behavior with numbers/strings | Check types explicitly, don't trust coercion |
| Environment diff | Works locally, fails in prod | Check env vars, dependency versions, OS differences |
| Race condition | Fails under load, works in isolation | Add locks, use atomic operations, review shared state |
Debugging Strategies by Context
Frontend / UI Bugs
- Open DevTools → Console (errors), Network (failed requests), Elements (DOM state)
- Check if the issue is data (wrong value) or rendering (correct value, wrong display)
- Isolate: reproduce in the smallest possible component
- Check browser compatibility if intermittent
Backend / API Bugs
- Check request payload first — is the input correct?
- Check database state — is the data what you expect?
- Trace through the service layer step by step
- Add temporary logging at key points to see actual values
Database / Query Bugs
- Run the query directly against the DB (not through ORM)
- Check actual data vs expected data
- Watch for N+1 queries (loop with individual DB calls)
- Check indexes for slow queries
Intermittent Bugs
- Add comprehensive logging — capture state at every step
- Look for shared mutable state
- Check for timing dependencies
- Reproduce under load (concurrency issues)
- Check for memory leaks or resource exhaustion
The Rubber Duck Method
Explain the bug out loud (to a rubber duck, a colleague, or an AI) as if they know nothing:
- What the code is supposed to do
- What it's actually doing
- Walk through the code line by line
The act of explaining forces you to examine every assumption. 60-70% of the time, you find the bug while explaining — before anyone responds.
When You're Stuck
After 20-30 minutes without progress:
- Take a break — 10 minutes away often produces the insight
- Rubber duck — explain the problem from scratch
- Question your most confident assumption — bugs often hide behind certainties
- Simplify — reduce to the minimal reproduction case
- Revert — if the bug is recent, git bisect or revert to last working state
- Ask for help — but prepare a clear problem statement first
Asking for Help Effectively
Context: [what the code is doing]
Expected: [what should happen]
Actual: [what is happening — exact error/output]
Tried: [what you've already attempted]
Suspicion: [your current best hypothesis]After Fixing the Bug
- Write a test that would have caught this bug
- Document if the root cause was non-obvious
- Check for similar bugs elsewhere in the codebase
- Update the lessons log if it was a new class of mistake you want to remember
- Commit message should explain the root cause, not just the fix:
fix(auth): handle null session on token refresh Previously crashed when session expired during token refresh. Root cause: session.user was null after expiry but code assumed it was always present. Added null guard and redirect to login.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

