/safeword:debugfrom safeword
Enforces investigate-first discipline for debugging bugs, test failures, and unexpected behavior. Walks through root cause investigation, reproduction, change review, and data flow tracing before any fix.
Ships in safeword. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Find root cause before fixing. Symptom fixes are failure.
Investigate the root cause before attempting any fix.
Use for bugs, errors, test failures, unexpected behavior, repeated failed fixes, or performance problems — skip for greenfield work.
Use especially when:
Complete each phase before proceeding.
BEFORE attempting ANY fix:
Don't skip past errors. They often contain the exact solution.
- Full stack trace (note line numbers, file paths)
- Error codes and messages
- Warnings that preceded the error
When the error mentions a library/framework symbol (a function, class, or module from a dependency) — read the installed version's docs before forming a hypothesis. Signatures, defaults, and deprecation behavior change between versions; training memory may describe a different version than the one running. Check package.json / lockfile, then the source wired up (Context7, official docs, README at the pinned ref).
| Can reproduce? | Action |
|---|---|
| Yes, every time | Proceed to step 3 |
| Sometimes | Gather more data - when does it happen vs not? |
| Never | Cannot debug what you cannot reproduce - gather logs |
When repro hinges on user-only context (env, timeline, "what were you doing"), call /elicit — its multiple-choice format constrains the answer space better than open prompts.
git diff HEAD~5 # Recent code changes
git log --oneline -10 # Recent commits
What changed that could cause this? Dependencies? Config? Environment?
When error is deep in call stack:
Symptom: Error at line 50 in utils.js
↑ Called by handler.js:120
↑ Called by router.js:45
↑ Called by app.js:10 ← ROOT CAUSE: bad input here
Technique:
When system has multiple layers (API → service → database):
# Log at EACH boundary before proposing fixes
echo "=== Layer 1 (API): request=$REQUEST ==="
echo "=== Layer 2 (Service): input=$INPUT ==="
echo "=== Layer 3 (DB): query=$QUERY ==="
Run once to find WHERE it breaks. Then investigate that layer.
When the bug appeared after some change, or lives somewhere in a large input/state, binary-search it instead of reading linearly. Each step halves the suspect space — a maximally-discriminating disconfirming test:
git bisect start && git bisect bad && git bisect good <known-good-ref>), then git bisect run <script> — a non-interactive predicate (e.g. bun test foo; exit 0 = good, non-0 = bad). git finds the first bad commit for you; git bisect reset when done.Prefer the cheapest bisection that splits the space — it usually beats linear tracing.
Locate similar working code in same codebase. What works that's similar?
| Working code | Broken code | Could this matter? |
|---|---|---|
| Uses async/await | Uses callbacks | Yes - timing |
| Validates input | No validation | Yes - bad data |
List ALL differences. Don't assume "that can't matter."
List 2–3 candidate causes, ranked by plausibility — not one. A single locked-in hypothesis invites confirmation bias; competing ones force you to discriminate ("consider the opposite" reliably reduces that bias).
Write each as "X could be root cause because Y", then ask: what evidence would rule it out?
Test the cheapest disconfirming check first — the one that eliminates the most candidates. Rule hypotheses out; don't hunt to confirm a favorite. (Bisection — Phase 1 §6 — is often the cheapest discriminator.)
| Rule | Why |
|---|---|
| ONE change at a time | Isolate what works |
| Smallest possible change | Avoid side effects |
| Don't bundle fixes | Can't tell what helped |
| Result | Action |
|---|---|
| Confirms a hypothesis | Phase 4 (verify the fix) |
| Rules one out | Eliminate it; test the next live hypothesis. None left? Form new ones (3.1) |
| Inconclusive | Pick a more discriminating (cheaper-to-disconfirm) test |
Before proceeding to Phase 4:
subtype: bug-investigatedExample:
## Root Cause
Connection pool exhausted because connections aren't released in error path.
Confirmed by adding pool logging - saw connections increment without decrement on errors.
Ruled out: pool size mis-set (config matches env); slow query (query times well under timeout in logs).
Before fixing, write test that fails due to the bug:
it('handles empty input without crashing', () => {
// This test should FAIL before fix, PASS after
expect(() => processData('')).not.toThrow();
});
When the root cause lives in a dependency and the fix is a workaround — a version pin, an avoided API, a reimplemented helper — the workaround becomes removable on their release, which nothing in this repo will ever announce. Comments and tickets do not reach whoever holds the code then.
Add a test asserting the dependency is still pinned at the last known-bad version, with a header naming what to delete when it fails. Assert the pin, not the bug: a test that reproduces the bug goes green when upstream fixes it, silently, leaving the dead workaround behind.
Warranted when removal depends on someone else's release and the failure
mode is silent. Follow the $safeword:testing skill's upstream-workaround tripwire rules.
Close the fix report with a **Next:** line — imperative: the commit message to use, the ticket to mark done, or a follow-up issue for related debt the investigation surfaced (the stop hook reads it for the re-entry brief).
Examples:
fix(auth): release pool connection in error path, mark ticket 234 done.src/auth.ts:88.| Fix attempts | Action |
|---|---|
| 1-2 | Return to Phase 1 with new information |
| 3+ | STOP - Question architecture (see below) |
Pattern indicating architectural problem:
STOP and ask:
/figure-it-out to evaluate approaches (refactor / redesign / extract) before implementing anything.If you catch yourself thinking:
| Thought | Reality |
|---|---|
| "Quick fix for now, investigate later" | Investigate NOW or you never will |
| "Just try changing X" | That's guessing, not debugging |
| "I'll add multiple fixes and test" | Can't isolate what worked |
| "I don't fully understand but this might work" | You need to understand first |
| "One more fix attempt" (after 2+ failures) | 3+ failures = wrong approach |
ALL mean: STOP. Return to Phase 1.
| Phase | Key Question | Success Criteria |
|---|---|---|
| 1. Root Cause | "WHY is this happening?" | Understand cause, not just symptom |
| 2. Pattern | "What's different from working code?" | Identified key differences |
| 3. Hypothesis | "Which competing cause survives?" | Ruled out alternatives; one cause confirmed |
| 4. Implementation | "Does the fix work?" | Test passes, issue resolved |
Voice: plainspoken and concise — write to be scanned.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
debugging, root-cause-analysis, bug-hunting, troubleshooting
npx claudepluginhub arcadeai/safeword --plugin safeword24 skills in this plugin
/auditRun a diff-scoped code audit for architecture, dead code, and test quality. Uses the change from main to focus feature reviews; request a repository audit for whole-codebase discovery./bddBehavior-first feature development — use when building new capabilities, continuing feature work, or when work introduces new state or multiple user flows. Discovers desired behavior through examples and scenarios before implementation. Do NOT use for bug fixes, typos, or small isolated changes./brainstormUse when the user wants to explore options, weigh approaches, or think through uncertainty before committing to a direction. Collaborative brainstorming and rubber ducking — divergence-first thinking partner./cleanup-zombiesKill zombie dev servers and test processes. Use when ports are blocked, processes are hanging, or test runners won't start./closeoutClose a completed local delivery safely. Use when wrapping up a finished coding session by verifying it, merging only with explicit authority, capturing retrospective learning, and cleaning the exact merged branch and worktree. Do NOT use for cloud-agent tasks, unmerged work, or cleanup without a pull request./demand-researchTests whether a proposed product bet has credible demand. Use when Why now depends on an unresolved, decision-critical demand claim or when the user explicitly asks for demand research. Do NOT use for child features, mandated work, parity work, or when a cheaper experiment can answer the question before research.Other plugins' skills for the same job