/tsh-product-engineering:debugging-codefrom TSH Product Engineering
Finds and fixes root causes of bugs by reproducing the failure, securing a failing test, narrowing to the cause with evidence, applying minimal fixes, and keeping the test as a regression guard.
Ships in TSH Product Engineering. 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.
Read when SKILL.md points to them.
A bug is fixed when its cause is named, removed, and guarded by a test that failed before the fix and passes after it; anything else is a guess that happened to make the symptom go away. Each step produces the evidence the next one needs: no reproduction, no trustworthy test; no failing test, no proof the fix did anything; no known cause, no way to tell how far the fix reaches.
Investigate the bug in $ARGUMENTS; if empty, ask for the symptom before reading code.
A project's own incident runbook, bug-fix workflow or test conventions outrank this
skill — follow them and use this procedure for what they leave unstated. Find the
project's test, lint and build commands the way
discovering-technical-context does,
not by guessing.
creating-implementation-plans.
Say so and stop; do not build it under the name of a fix.tsh-product-testing plugin. A flaky unit or integration test whose cause is in
application code is in scope.tsh-platform-engineering. Name the gap to the user.| Severity | Rule |
|---|---|
| MUST | Reproduce the failure before changing any code. A bug you cannot reproduce stays open: report what was tried and what evidence would unblock it — never ship a speculative fix as a fix. |
| MUST | Have a failing automated test before fixing — one that already fails for this reason, an existing test corrected or extended to cover the case, or a new one at the lowest layer that exhibits the bug, in that order of preference. Watch it fail for the reported reason: a test that fails on setup, or on a different assertion, proves nothing. Only when no test layer in the project can exercise the fault, record the manual reproduction instead and say the guard is partial. |
| MUST | State the root cause as a causal chain — trigger → faulty code at file:line → observed symptom — with the evidence for each link: an observed value, a log line, a bisect result. "This looks wrong" is a hypothesis, not a cause. |
| NEVER | Fix at the symptom site when the cause is elsewhere: a null guard, a swallowed exception, a retry, a longer timeout, or a special case for the reported input. If the cause is genuinely out of reach, label the change a mitigation, name the open cause, and get the user's agreement. |
| MUST | Keep the fix minimal — only what the root cause requires. No refactoring, renaming or unrelated cleanup in the same change. |
| NEVER | Weaken, skip or delete a test to make it pass, or change an expected value, unless the test itself is shown to be wrong — and then say so explicitly in the report. |
| MUST | Assess the reach of the fix once the cause is known and before changing code — how many call sites the faulty code has, and whether the fix changes anything observable outside the module. Verification scales with the answer; a fix is never "simple" by the look of the symptom. |
| MUST | Stop and move to a plan when the fix needs a design decision, changes a contract others depend on, or reaches further than you can verify: hand the established root cause to creating-implementation-plans so it lands in the plan's Technical Context. |
| NEVER | Mutate production data or state while investigating. Production logs, metrics and databases are read-only evidence. |
| Reference | Load when | Covers |
|---|---|---|
| Reproducing failures | The bug does not reproduce on the first attempt, reproduces only in one environment, or it is unclear which test layer can express it | Narrowing the environment gap, data- and timing-dependent bugs, choosing the test layer, what to do when no automated test can capture it |
| Root-cause techniques | The first hypothesis fails, or the stack trace does not point at the faulty line | The hypothesis log, git bisect run with the repro test, shrinking the input, temporary instrumentation, async and minified stack traces, concurrency bugs |
Copy this checklist and track progress:
Debugging progress:
- [ ] 1. Pin the symptom
- [ ] 2. Reproduce
- [ ] 3. Secure a failing test
- [ ] 4. Find the root cause
- [ ] 5. Assess the reach of the fix
- [ ] 6. Apply the minimal fix
- [ ] 7. Verify
- [ ] 8. Look for siblings
- [ ] 9. Report
Step 1 — Pin the symptom. Write down expected versus actual behaviour, the exact
error and stack trace, the environment and commit where it happens, since when, and
how often. Pull what you can from the ticket, logs and git log yourself; ask the
user only for what is not recoverable. A vague symptom produces a vague fix.
Then assess what you are looking at before touching anything: a defect in code, a configuration or data problem, a missing feature, or a test that is itself wrong. Each goes a different way — only the first follows the full procedure below, a missing feature leaves for a plan, and a wrong test is corrected in step 3, after which the procedure skips to the report and says so. Note which test layers exist for the affected module; that decides how step 3 can be satisfied.
A live outage changes the order, not the rules: reverting the offending commit is a legitimate first mitigation — label it so, get the user's agreement, then run the procedure against the reverted change so the cause is found before it ships again.
Step 2 — Reproduce. Find the smallest, most reliable way to trigger the failure
and record it as a command or a numbered list of steps. Note the last known good
commit if there is one — it bounds the search in step 4. If the failure does not
reproduce, read ./references/reproducing-failures.md
before trying anything else.
Step 3 — Secure a failing test. Look before writing:
./references/reproducing-failures.md.Whichever applies, run it and confirm the failure message matches the symptom from step 1.
Step 4 — Find the root cause. Form one hypothesis at a time and test it with a
check that could disprove it. Read the stack trace from the bottom of your own code,
not the top of the framework's. When the first hypothesis fails, read
./references/root-cause-techniques.md and
keep a hypothesis log. Finish with the causal chain the rules table demands.
Step 5 — Assess the reach of the fix. You now know which code will change; measure what depends on it before changing it:
Local → step 7 as written. Shared or contract-changing → step 7 widens to the callers' suites and the relevant e2e, and the report calls the change out. A contract others depend on, or a reach you cannot verify → the plan rule applies.
Step 6 — Apply the minimal fix. Change the code at the cause, nothing more.
Step 7 — Verify. The test from step 3 now passes; the tests of the touched module — and of every caller, where step 5 found them — still pass; lint and typecheck are clean; the original reproduction from step 2 no longer fails. Remove every piece of temporary instrumentation.
Step 8 — Look for siblings. Search for the same faulty pattern elsewhere — the
same misused API, the same unchecked assumption, the copy-pasted block. Report each
hit with file:line; fix them only with the user's agreement, as separate changes.
Step 9 — Report.
Symptom: <expected vs actual, where, since when>
Reproduction: <command or steps>
Root cause: <trigger → file:line → symptom, with the evidence for each link>
Reach: <local | shared, N callers | contract change — what others now observe differently>
Fix: <files changed, one line on what changed and why it removes the cause>
Regression: <test name and path; existing, corrected or new — failed before, passes after>
Verified: <commands run and their results>
Siblings: <file:line list, or "none found">
Open: <mitigation-only status, residual risk, follow-ups — or "none">
Ship in this plugin — if this skill loaded, they are installed.
discovering-technical-context supplies
the project's commands and conventions;
creating-implementation-plans takes
over when the fix outgrows a minimal change;
reviewing-code judges the fix before merge.
What SKILL.md sets; muted values are Claude Code's defaults
Trigger on: 'fix this bug', 'why does this fail', 'this throws', a pasted stack trace or error log, a test that started failing, a regression after a merge, deploy or dependency upgrade, 'it worked yesterday', a production error that needs a code fix, or a bug ticket. Building new behaviour is orchestrating-feature-implementation; judging a finished fix is reviewing-code.
8 skills in this plugin
/capturing-ui-evidenceThe mechanical capture contract for UI verification: drives the playwright-cli against the pinned dev server URL to collect actual.png, computed-styles.json and a11y-snapshot.yml into the iteration artifact directory. Works with no design reference at all; when — and only when — the caller supplies a Figma URL, it also exports the shared reference image. Evidence collection only — judging the result is the ui-reviewer agent's job./creating-implementation-plansWrites TSH's implementation plan as a committed file at specifications/<task-id>/<task-name>.plan.md: phased tasks that each name their files and a verifiable Definition of Done, technical context persisted for implementers, explicit parallel groups. Use when a plan, spec, or task breakdown is asked for — a plan kept outside the repository cannot be committed, reviewed in a PR, or read by an implementer subagent./discovering-technical-contextEstablishes which conventions a change must follow before it is written, in priority order: the plan's persisted technical context, then project instructions (CLAUDE.md, .claude/rules, decision records), then existing codebase patterns, then external documentation. Use to answer 'how does this project do X' or to fill a plan's Technical Context section./orchestrating-feature-implementationImplements a feature, ticket, or plan end to end from the main conversation: confirms a plan file exists, delegates each task to implementer subagents — in parallel where the plan allows — gates on their reports, then closes with the plan's final verification phase: code review and functional verification in parallel. Use for any feature request or multi-file change, before the first file is edited./reviewing-codeTSH's pre-merge review of a delivered change set — a pasted diff, a task, or a PR: reads the plan and requirements first, compares the implementation against what was agreed, judges test coverage per layer, runs the project's tests, linters and build when they are available, then checks high-risk anti-patterns, security, and scalability. Use when a change must be judged for merge readiness, whether it arrives as a pasted diff or a branch, against its plan or acceptance criteria when those exist./reviewing-uiRuns one UI verification pass against Figma: delegates fresh Playwright-CLI capture of the running app to ui-capture-worker, then the design comparison to ui-reviewer, and returns PASS, FAIL, or VERIFICATION NOT RUN with a complete difference table. Read-only — it never fixes code. Use when asked to verify implemented UI against a Figma design or check whether a page matches its design.npx claudepluginhub thesoftwarehouse/agentic-collections --plugin tsh-product-engineeringOther plugins' skills for the same job