Install
npx skillscat add dinhanhthi/coding-friend/cf-sys-debug Install via the SkillsCat registry.
SKILL.md
Systematic Debugging
Custom Guide
Run: bash "${CLAUDE_PLUGIN_ROOT}/lib/load-custom-guide.sh" cf-sys-debug
If output is not empty, integrate the returned sections:
## Before→ apply before the main content below## Rules→ apply as additional rules throughout## After→ apply after debugging completes
The 3-Fix Rule
If you've attempted 3+ fixes and the bug persists, stop. The problem is architectural, not local. Step back and re-examine your assumptions.
5-Phase Process
Phase 1: Root Cause Investigation
1a. Check existing bug docs (frontmatter recall):
Before investigating, search for related past bugs. Extract 2-3 keywords from the bug description.
- Grep
^description:lines across{docsDir}/memory/bugs/**/*.md— match against bug keywords - If no match, grep
^tags:lines across{docsDir}/memory/bugs/**/*.md - If matches found, read the top 1-2 matched files — they may reveal known root causes or patterns that save investigation time
Check {docsDir} from .coding-friend/config.json (default: docs).
1b. Investigate:
- Read the actual error. Do not guess. Read the full stack trace, error message, and logs.
- Reproduce the bug. Write a test or command that triggers the failure reliably.
- Trace backward. Follow the call chain from the error to its origin. The bug is usually NOT where the error appears.
Phase 2: Pattern Analysis
- When did it start? Check recent changes:
git log --oneline -20,git diff HEAD~5 - Is it consistent? Does it fail every time, or intermittently? Intermittent = timing/state issue.
- What's the minimal reproduction? Strip away everything unrelated until you have the smallest case.
Phase 3: Hypothesis Testing
- Form one hypothesis. "The bug is caused by X because Y."
- Design a test. What observation would confirm or disprove this hypothesis?
- Test it. Run the test. Read the output carefully.
- If disproved, go back to Phase 1 with new information. Do NOT patch around it.
Phase 4: Implementation
- Fix the root cause, not the symptom
- Write a regression test that would have caught this bug
- Run the full test suite — your fix must not break anything else
- Verify the original error is gone — reproduce the original failure and confirm it's fixed
Phase 5: Document the Bug
cf-sys-debug is only invoked for hard bugs — always document the findings.
- Read
languageconfig (local.coding-friend/config.jsonoverrides global, default:en) - Check
{docsDir}from config (default:docs) - Construct a write spec and delegate to cf-writer agent via the Agent tool with
subagent_type: "coding-friend:cf-writer":
WRITE SPEC
----------
task: create
file_path: {docsDir}/memory/bugs/{name}.md
language: {language from config}
content: |
---
title: "<Short bug title>"
description: "<One-line summary of the bug and fix, under 100 chars>"
tags: [tag1, tag2, tag3]
created: YYYY-MM-DD
updated: YYYY-MM-DD
---
# <Bug Title>
## Overview
<What went wrong — symptom and why it was hard to diagnose>
## Investigation
<What was tried and ruled out — hypotheses that didn't pan out>
## Root Cause
<What was actually wrong — the real cause>
## Fix
<What was changed to fix it>
## Prevention
<How to avoid this bug in the future>
## Related Files
- `path/to/file1`
- `path/to/file2`
readme_update: false
auto_commit: false
existing_file_action: skipFrontmatter rules:
description: factual summary for grep recall. Good:"Circular dependency in plugin loader causing silent init failure". Bad:"Hard bug fixed".tags: include error type, affected module, root cause category (e.g.,[circular-dependency, plugin-loader, initialization])
Common Traps
| Trap | Why It Fails | Do This Instead |
|---|---|---|
| "Let me just try this..." | Random fixes waste time and obscure the real cause | Form a hypothesis first |
Adding a try/catch to suppress the error |
Hides the bug, doesn't fix it | Find and fix the root cause |
| "It works on my machine" | Environment difference IS the bug | Compare environments systematically |
| Fixing where the error appears | Symptom vs cause confusion | Trace backward to the origin |
| Multiple changes at once | Can't tell which one fixed it | One change at a time, test after each |
Debugging Tools
git bisect— Find the exact commit that introduced a buggit stash— Isolate your changes to test clean state- Print/log tracing — Add strategic logging at decision points
- Minimal reproduction — Smallest possible code that triggers the bug
Review Reminder
After the fix is verified, ask the user if they want to run /cf-review or /cf-commit. Do NOT auto-run — wait for their choice.