Index of every page on this site: llms.txt
All skills
kiln-skills avatar

/debug-root-cause

@555d7ea
Run it yourself

Systematically find and fix the root cause of bugs, errors, failing tests, and crashes in JavaScript/TypeScript and Python. Use whenever the user pastes an error or stack trace, says something is broken, "not working", "error", "kenapa gagal", "bug", a test fails, or behavior is unexpected — instead of guessing at a fix.

Use this Skill: https://skilld.dev/gh/kiln-skills/kiln/debug-root-cause

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈86 tokens for metadata: the name and description. ≈730 when used: this file.

Description uses 4.3% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈341 characters, or 4.3%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Debug: Root Cause First

The most common debugging failure is patching the symptom. This skill forces a reproduce → hypothesize → prove → fix loop.

1. Reproduce

  • Get the exact failing command (test, script, request). Run it yourself and capture the full output.
  • If it doesn't reproduce, stop and gather info: environment, versions (node -v, python --version, lockfile), input data, env vars. Don't fix what you can't see.
  • Make the reproduction as small and fast as possible (a single test, pytest path::test_name -x, npx vitest run file -t "name").

2. Read the error properly

  • Read the whole stack trace. The first frame in the user's own code (not node_modules / site-packages) is usually where to look.
  • Read the actual code at those lines, plus callers.
  • Common decoders:
    • Cannot read properties of undefined (reading 'x') / AttributeError: 'NoneType' → something upstream returned nothing; find where the value came from.
    • ERR_MODULE_NOT_FOUND, ModuleNotFoundError → path, ESM/CJS mismatch, virtualenv not active, missing dependency.
    • UnhandledPromiseRejection, RuntimeWarning: coroutine was never awaited → missing await.
    • Works locally, fails in CI → env vars, timezone, file ordering, node/python version, test isolation.
    • Flaky → shared state between tests, time, randomness, network, race conditions.

3. Hypothesize, then prove

Write down 1–3 hypotheses ranked by likelihood. For each, pick the cheapest experiment that would confirm or kill it:

  • Add a targeted log/print of the suspicious value (remove it after).
  • Write a failing test that pins the bug.
  • git bisect if it "used to work": git bisect start; git bisect bad; git bisect good <sha> then run the repro at each step.
  • Check what changed recently: git log -p --since="3 days ago" -- <file>.

Only move to a fix when one hypothesis is proven. If all are killed, go back to step 2 with the new evidence.

4. Fix at the root

  • Fix where the bad value/state is created, not where it explodes.
  • Avoid symptom patches: blanket try/except, ?. everywhere, # type: ignore, raising timeouts, retry on deterministic failures. If a guard really is the right answer, explain why.
  • Keep the fix minimal; refactors go in a separate step.

5. Prevent regression

  • Add (or keep) the test that failed before the fix and passes after.
  • Run the related test suite, not just the single test.
  • Search for the same pattern elsewhere: grep -rn "<pattern>" src/ — same bug often lives in sibling code.

6. Report

**Root cause:** <1–2 sentences, name file:line>
**Evidence:** <what proves it — output, a test>
**Fix:** <what changed and why there>
**Prevention:** <test added / similar patterns found>

Write the report in the user's language (for example, Indonesian if they wrote in Indonesian); translate the headings too.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts15d3 checks · Risk SAFE
  • Gen Agent Trust Hub15d

    This skill defines a structured debugging process for identifying and resolving code errors. It uses standard development tools and practices to analyze logs and reproduce bugs, presenting no malicious patterns or security risks outside of normal development activities.

  • Socket15d

    No alerts

  • Snyk15d

    Risk: LOW · No issues

Signed by skilld at 555d7ea. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 2 weeks ago

README badge

README badge for kiln-skills/kiln/debug-root-cause