Install
openclaw skills install @afonsoft/diagnoseUse when the user reports a hard bug, unexpected failure, or performance regression that needs root-cause analysis.
openclaw skills install @afonsoft/diagnoseA discipline for hard bugs and regressions. Skip phases only when explicitly justified. All questions and findings reported to the user must be in Portuguese (pt-BR).
When exploring the codebase, use the project's domain glossary from .claude/CONTEXT.md to get a clear mental model of the relevant modules, and check docs/architecture/ for decisions in the area you are touching.
Re-validation loop: after every hypothesis, fix, or change, re-run the reproduction and the regression checks before declaring the bug resolved.
This is the skill. Everything else is mechanical. If you have a fast, deterministic, agent-runnable pass/fail signal for the bug, you will find the cause — bisection, hypothesis-testing, and instrumentation all just consume that signal. If you do not have one, no amount of staring at code will save you.
Spend disproportionate effort here. Be aggressive. Be creative. Refuse to give up.
Ask the user in Portuguese when you need more data:
Preciso de um exemplo minimo que reproduza o erro. Voce consegue me fornecer:
1. O comando ou acao que dispara o problema.
2. A saida ou mensagem de erro exata.
3. O ambiente (local, CI, staging, producao).
➡️ Se nao tiver, vou tentar construir um caso de reproducao sozinho.
This is the skill. If you cannot reproduce the bug in isolation, you cannot fix it. If you cannot minimise the problem, you cannot reproduce it. If you cannot reproduce it, you cannot fix it.
This is the skill. If you cannot explain the bug, you cannot fix it.
Report the hypothesis to the user in Portuguese:
Hipotese atual: [DESCRICAO_DA_HIPOTESE].
Vou validar com [ACAO_EXPERIMENTAL]. Se confirmar, o proximo passo e [PROXIMO_PASSO].
Concorda ou quer que eu teste outra hipotese primeiro?
This is the skill. If you cannot see the bug, you cannot fix it.
Do the smallest, safest change that removes the root cause. Avoid band-aids. If the fix touches many files, present the plan to the user in Portuguese before editing.
Raiz do problema: [RAIZ].
Correcao proposta: [DESCRICAO_DA_CORRECAO].
Arquivos afetados: [LISTA].
Posso aplicar a correcao e depois rodar os testes?
This is the skill. If you cannot verify the fix, you cannot call it done.
Report the result in Portuguese:
Correcao aplicada em [ARQUIVOS].
- Teste de reproducao: [PASS/FAIL]
- Testes de regressao: [PASS/FAIL]
- Testes afetados: [PASS/FAIL]
O bug esta resolvido. Quer que eu abra uma Issue para documentar a causa raiz com /create-issues?
If the bug is not in the codebase but in the agent session — repeated tool-call failures, loops, context drift, or mismatch between expected and actual filesystem state — apply the agent-introspection loop.
Before trying to recover, record:
## Failure Capture
- Session / task:
- Goal in progress:
- Error:
- Last successful step:
- Last failed tool / command:
- Repeated pattern seen:
- Environment assumptions to verify:
Match the failure to a known pattern:
| Pattern | Likely Cause | Check |
|---|---|---|
| Maximum tool calls / repeated same command | loop or no-exit observer path | inspect the last N tool calls for repetition |
| Context overflow / degraded reasoning | unbounded notes, repeated plans, oversized logs | inspect recent context for duplication and low-signal bulk |
ECONNREFUSED / timeout | service unavailable or wrong port | verify service health, URL, and port assumptions |
429 / quota exhaustion | retry storm or missing backoff | count repeated calls and inspect retry spacing |
| file missing after write / stale diff | race, wrong cwd, or branch drift | re-check path, cwd, git status, and actual file existence |
| tests still failing after “fix” | wrong hypothesis | isolate the exact failing test and re-derive the bug |
Diagnosis questions:
Prefer these interventions in order:
Bad pattern: retrying the same action three times with slightly different wording. Good pattern: capture failure → classify the pattern → run one direct check → change the plan only if the check supports it.
End with:
## Agent Self-Debug Report
- Session / task:
- Failure:
- Root cause:
- Recovery action:
- Result: success | partial | blocked
- Token / time burn risk:
- Follow-up needed:
- Preventive change to encode later:
When the code "works" but misbehaves quietly, hunt for silent failures before declaring the bug resolved.
catch {}, ignored exceptions, errors converted to null / empty arrays with no context..catch(() => []), graceful-looking paths that make downstream bugs harder to diagnose.For each finding:
Diagnosis is iterative. After every change, re-run the reproduction. If the bug moves or changes, go back to Phase 3. Do not declare the bug fixed until the reproduction passes and the regression suite is green.
| Mistake | Fix |
|---|---|
| Fixing without a reproduction first | Build a reproduction before changing code. |
| Skipping minimisation | Minimise first, or you fix symptoms, not the cause. |
| Removing instrumentation too early | Keep it until the fix is verified. |
| Not adding a regression test | Every fixed bug deserves a test. |
| Declaring done without re-validation | Re-run the reproduction and the suite. |
qa-analyst — for test planning and bug reportingwrite-specs — for producing specs when the bug reveals missing requirementsimprove-codebase-architecture — when the diagnosis reveals structural seams that need deepeningagent-introspection-debugging — when the failure is the agent session itself (loops, context drift, repeated tool calls)silent-failure-hunter — when the code works but misbehaves quietly