en un clic
debugging-patterns
// Use when a bug, flaky test, or runtime/build failure needs root-cause tracing and a nearby duplicate-pattern scan before any fix.
// Use when a bug, flaky test, or runtime/build failure needs root-cause tracing and a nearby duplicate-pattern scan before any fix.
Safe cc10x upgrade that preserves local modifications. Stashes diffs, pulls upstream, rebuilds cache, rebases patches. Use this skill when: updating cc10x, upgrading, pulling latest cc10x, syncing plugin, refreshing cache, or checking for new versions. Triggers: update cc10x, upgrade cc10x, pull cc10x, sync plugin, refresh cc10x, check for updates, new version, update plugin, upgrade plugin.
THE ONLY ENTRY POINT FOR CC10X. Activate this skill for build, debug, review, and plan requests. Use when the user asks to implement, fix, review, plan, test, refactor, or continue code work. Trigger keywords: build, implement, create, write, add, review, audit, debug, fix, error, bug, broken, plan, design, architect, spec, brainstorm, test, refactor, optimize, update, change, research, cc10x, c10x. CRITICAL: Route and execute immediately. Do not stop at describing capabilities.
Use when a BUILD phase completes, a commit is staged, or a PR is about to be created, and the diff has not yet been reflected in documentation. Also use when the user says "update docs", "sync docs", "document this", or asks whether documentation is up to date.
Internal skill. Use cc10x-router for all development tasks.
Internal skill. Synthesis guidance loaded via SKILL_HINTS by planner and bug-investigator when research files are available.
Internal skill. Use cc10x-router for all development tasks.
| name | debugging-patterns |
| description | Use when a bug, flaky test, or runtime/build failure needs root-cause tracing and a nearby duplicate-pattern scan before any fix. |
| allowed-tools | Read Grep Glob Bash LSP |
Random fixes waste time and create new bugs. Quick patches mask underlying issues.
Core principle: ALWAYS find root cause before attempting fixes. Symptom fixes are failure.
This skill is advisory in v10. It deepens investigation quality. It does not authorize local-only patches, guesswork, or "fix the line that crashed" thinking.
Read only the references needed for the current investigation:
references/root-cause-playbooks.md for build/type failures, flaky tests, runtime crashes, browser errors, git bisect, and boundary tracingreferences/investigation-hygiene.md for context discipline, evidence logging, hypothesis tracking, restart protocol, and architectural escalationNO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
If you haven't completed Phase 1, you cannot propose fixes.
For rapid debugging, use this concise flow:
1. Capture error message and stack trace
2. Identify reproduction steps
3. Isolate the failure location
4. Implement minimal general fix
5. Verify solution works
Debugging techniques:
Root Cause Tracing Technique:
1. Observe symptom - Where does error manifest?
2. Find immediate cause - Which code produces the error?
3. Ask "What called this?" - Map call chain upward
4. Keep tracing up - Follow invalid data backward
5. Find original trigger - Where did problem actually start?
Never fix solely where errors appear—trace to the original trigger. After root cause is identified, scan for the same signature nearby before declaring success.
Use LSP to trace execution flow systematically:
| Debugging Need | LSP Tool | Usage |
|---|---|---|
| "Where is this function defined?" | lspGotoDefinition | Jump to source |
| "What calls this function?" | lspCallHierarchy(incoming) | Trace callers up |
| "What does this function call?" | lspCallHierarchy(outgoing) | Trace callees down |
| "All usages of this variable?" | lspFindReferences | Find all access points |
Systematic Call Chain Tracing:
1. localSearchCode("errorFunction") → get file + lineHint
2. lspGotoDefinition(lineHint=N) → see implementation
3. lspCallHierarchy(incoming, lineHint=N) → who calls this?
4. For each caller: lspCallHierarchy(incoming) → trace up
5. Continue until you find the root cause
CRITICAL: Always get lineHint from localSearchCode first. Never guess line numbers.
For each issue provide:
Read references/root-cause-playbooks.md when the failure matches one of these
shapes:
Keep this SKILL.md focused on the four-phase investigation workflow. Use the
reference for concrete commands, boundary tracing patterns, and git-bisect
recipes.
Use for ANY technical issue:
Use this ESPECIALLY when:
Don't skip when:
You MUST complete each phase before proceeding to the next.
BEFORE attempting ANY fix:
Read Error Messages Carefully
Reproduce Consistently
Check Recent Changes
Gather Evidence in Multi-Component Systems
WHEN system has multiple components (CI → build → signing, API → service → database):
BEFORE proposing fixes, add diagnostic instrumentation:
For EACH component boundary:
- Log what data enters component
- Log what data exits component
- Verify environment/config propagation
- Check state at each layer
Run once to gather evidence showing WHERE it breaks
THEN analyze evidence to identify failing component
THEN investigate that specific component
For a concrete boundary-tracing recipe, read
references/root-cause-playbooks.md.
Trace Data Flow
WHEN error is deep in call stack:
Trace configuration to its consumer (third-party SDKs, env, import time)
BEFORE proposing replacements, migrations, or large refactors:
process.env (or language equivalents) at module import / load time—not through your app's DI or config objects. The fix may be setting or correcting env, not changing application code.node_modules (or vendor path). The failure may be a wrong endpoint or flag, not a need for a different library.Find the pattern before fixing:
Find Working Examples
Compare Against References
Identify Differences
Understand Dependencies
Scientific method:
Form Single Hypothesis
Test Minimally
Verify Before Continuing
When You Don't Know
Falsifiability Requirement: A good hypothesis can be proven wrong. If you can't design an experiment to disprove it, it's not useful.
Bad (unfalsifiable):
Good (falsifiable):
The difference: Specificity. Good hypotheses make specific, testable claims.
Track multiple hypotheses with confidence levels:
H1: [hypothesis] — Confidence: [0-100]
Evidence for: [what supports this]
Evidence against: [what contradicts this]
Next test: [what would raise or lower confidence]
H2: [hypothesis] — Confidence: [0-100]
Evidence for: [...]
Evidence against: [...]
Next test: [...]
H3: [hypothesis] — Confidence: [0-100]
Evidence for: [...]
Evidence against: [...]
Next test: [...]
Scoring guidance:
| Range | Meaning | Action |
|---|---|---|
| 80-100 | Strong evidence, high certainty | Proceed to fix |
| 50-79 | Circumstantial, needs more data | Run "Next test" |
| 0-49 | Speculation, weak evidence | Deprioritize or discard |
Rules:
| Bias | Trap | Antidote |
|---|---|---|
| Confirmation | Only look for evidence supporting your hypothesis | "What would prove me wrong?" |
| Anchoring | First explanation becomes your anchor | Generate 3+ hypotheses before investigating any |
| Availability | Recent bugs → assume similar cause | Treat each bug as novel until evidence suggests otherwise |
| Sunk Cost | Spent 2 hours on path, keep going despite evidence | Every 30 min: "If fresh, would I take this path?" |
When debugging code you wrote, you're fighting your own mental model.
Why this is harder:
The discipline:
The hardest admission: "I implemented this wrong." Not "requirements were unclear" - YOU made an error.
Consider starting over when:
Restart protocol:
Fix the root cause, not the symptom:
Create Failing Test Case
Implement Single Fix
Verify Fix
If Fix Doesn't Work
If 3+ Fixes Failed: Question Architecture
Pattern indicating architectural problem:
STOP and question fundamentals:
Discuss with your human partner before attempting more fixes
This is NOT a failed hypothesis - this is a wrong architecture.
If you catch yourself thinking:
ALL of these mean: STOP. Return to Phase 1.
If 3+ fixes failed: Question the architecture (see Phase 4.5)
Watch for these redirections:
When you see these: STOP. Return to Phase 1.
| Excuse | Reality |
|---|---|
| "Issue is simple, don't need process" | Simple issues have root causes too. Process is fast for simple bugs. |
| "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check thrashing. |
| "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |
| "I'll write test after confirming fix works" | Untested fixes don't stick. Test first proves it. |
| "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |
| "Reference too long, I'll adapt the pattern" | Partial understanding guarantees bugs. Read it completely. |
| "I see the problem, let me fix it" | Seeing symptoms ≠ understanding root cause. |
| "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. Question pattern, don't fix again. |
| Phase | Key Activities | Success Criteria |
|---|---|---|
| 1. Root Cause | Read errors, reproduce, check changes, gather evidence | Understand WHAT and WHY |
| 2. Pattern | Find working examples, compare | Identify differences |
| 3. Hypothesis | Form theory, test minimally | Confirmed or new hypothesis |
| 4. Implementation | Create test, fix, verify | Bug resolved, tests pass |
If systematic investigation reveals issue is truly environmental, timing-dependent, or external:
But: 95% of "no root cause" cases are incomplete investigation.
## Bug Investigation
### Phase 1: Evidence Gathered
- **Error**: [exact error message]
- **Stack trace**: [relevant lines]
- **Reproduction**: [steps to reproduce]
- **Recent changes**: [commits/changes]
### Phase 2: Pattern Analysis
- **Working example**: [similar working code]
- **Key differences**: [what's different]
### Phase 3: Hypothesis
- **Theory**: [I think X because Y]
- **Test**: [minimal change made]
- **Result**: [confirmed/refuted]
### Phase 4: Fix
- **Root cause**: [actual cause with evidence]
- **Change**: [summary of fix]
- **File**: [path:line]
- **Regression test**: [test added]
### Verification
- Test command: [command] → exit 0
- All tests: PASS
- Functionality: Restored