debugging-difficult-bugs
O que ela faz
Esta skill orienta um método cuidadoso de depuração para bugs de dificuldade média ou alta. Ela pede ao agente que reproduza o problema real e leia os logs de execução antes de tentar uma correção.
Quando usar
- ✓Quando um bug envolve tempo, estado, streaming ou outro comportamento em execução que os testes podem não capturar.
- ✓Quando um teste está falhando, mas pode não representar o problema real.
- ✓Quando você está tentado a fazer mais uma correção por chute, sem novas evidências.
Link da skill
https://github.com/mastra-ai/mastra/blob/main/.claude/skills/debugging-difficult-bugs/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“Este bug só acontece quando duas requisições chegam ao mesmo tempo. Me ajude a encontrar a causa real antes de mudarmos qualquer código.”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
O agente informa o que não tem certeza, adiciona logs temporários ao caminho real do código e reproduz o problema. Depois lê os logs e chega a uma conclusão antes de propor uma correção.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do GitHub.
Debugging Difficult Bugs
Use this skill early for medium or hard bugs where normal TDD may give false confidence because the test does not fully capture the real bug.
Core idea: instrument the actual runtime path, reproduce the real issue, then inspect append-only JSONL logs before deciding on a fix.
When to Use
Use this workflow near the start of debugging when any of these are true:
- The bug is medium or hard complexity, especially if it spans multiple functions, packages, processes, or UI/runtime boundaries.
- A test is red, but the failing test might be an incomplete model of the real bug.
- You are tempted to make a second speculative fix without new runtime evidence.
- The bug depends on runtime ordering, state, caching, streaming, concurrency, persistence, UI interaction, or external services.
- The user says they can reproduce the issue manually.
- The test passes after a change, but you are not confident it proves the actual reported bug is fixed.
Do not keep iterating only on tests if you do not understand the runtime behavior.
Skip this workflow only when the root cause is already directly proven by a stack trace or by a deterministic failing test that exercises the real runtime path. If you are tempted to make a second speculative fix, use this workflow.
Required Approach
State the uncertainty
- Acknowledge that the current test may not capture the actual bug.
- Identify the real code path that must be observed.
Add temporary unconditional instrumentation
- Add minimal but sufficient logs through the suspected code flow.
- Log boundaries, meaningful branch decisions, state transitions, async ordering points, return values, and caught errors; do not log every line.
- Logs must be unconditional: do not gate them behind an env var, debug flag, or log level.
- Each log point must append one JSON object per line to a
.jsonlfile in the current working directory. - Include enough context to reconstruct the path: event name, timestamp, relevant ids, input shape, state transitions, branch decisions, return values, and caught errors.
Reproduce the real issue
- Prefer to run the reproduction yourself if possible.
- If the issue requires the user's environment or manual interaction, ask the user to reproduce it after instrumentation is added.
- Tell the user exactly which
.jsonlfile to send or ask them to tell you when reproduction is complete so you can inspect it.
Analyze the log before fixing
- Read the JSONL log chronologically.
- Compare expected flow vs actual flow.
- Identify the first point where state or behavior diverges.
- Only then implement the fix.
Clean up instrumentation
- Remove all temporary unconditional logs after root cause is understood and the fix is verified.
- Remove debug imports, helper functions, generated
.jsonlfiles, and any other temporary artifacts. - Check the final diff for instrumentation remnants.
- Do not leave debug files, log helpers, or noisy runtime logging in the final diff unless the user explicitly asks.
Keep or improve tests
- Add or adjust a focused regression test once the real bug is understood.
- Make the test assert the actual broken behavior discovered from logs, not the earlier incorrect assumption.
JSONL Logging Pattern
Use append-only JSONL in cwd so it works across CLIs, dev servers, tests, and manual reproduction.
Node / TypeScript
import { appendFileSync } from 'node:fs';
import { join } from 'node:path';
function debugBug(event: string, data: Record<string, unknown> = {}) {
appendFileSync(
join(process.cwd(), 'debug-difficult-bug.jsonl'),
`${JSON.stringify({
ts: new Date().toISOString(),
event,
...data,
})}\n`,
);
}
Call it at every meaningful branch or state transition:
debugBug('workflow.start', { runId, stepId, inputKeys: Object.keys(input ?? {}) });
debugBug('workflow.beforeStep', {
runId,
stepId,
status: step.status,
hasResumeData: Boolean(resumeData),
});
try {
const result = await executeStep();
debugBug('workflow.afterStep', { runId, stepId, resultShape: Object.keys(result ?? {}) });
return result;
} catch (error) {
debugBug('workflow.stepError', {
runId,
stepId,
errorName: error instanceof Error ? error.name : typeof error,
errorMessage: error instanceof Error ? error.message : String(error),
});
throw err
Perguntas frequentes
Ele pula a escrita de testes?
Não. Ele diz que apenas testes podem dar falsa confiança, então as evidências de execução vêm primeiro, e os testes são adicionados depois.
Quando ele pode ser pulado?
Apenas quando um stack trace ou um teste que falha de forma determinística já comprova a causa.
Os logs devem conter dados privados?
O método recomenda registrar apenas metadados, e não prompts ou conteúdo.
Detalhes
Descrição original do autor
Use early when debugging a medium or hard bug, especially when tests alone may not reveal the real runtime failure. Trigger this before extended TDD iteration when a bug involves runtime state, ordering, persistence, streaming, concurrency, UI/manual reproduction, external services, or when a red or newly passing test may not model the real issue. Skip only when the root cause is already directly proven by a stack trace or deterministic test that exercises the real runtime path.
repo: mastra-ai/mastra
Popularidade
- Estrelas no GitHub
- 29 mil
- Posição no ranking
- #9360
- Licença
- —
- Atualizada em
- 02/11/2026
Comentários
- …
Mais skills deste repositório
mastra-frontend
29 milAjuda seu agente a criar telas de aplicativo com o sistema de design do playground da Mastra, combinando seus componentes prontos em vez de estilizar do zero.
pr-explainer
29 milAjuda seu agente a transformar um pull request em uma página HTML clara e autocontida que explica a mudança para os revisores.
pr-splitter
29 milAjuda seu agente a dividir um pull request grande e confuso em pull requests menores e revisáveis, mantendo o trabalho original seguro.
ralph-plan
29 milAjuda seu agente a planejar um comando de tarefa focado e estruturado por meio de uma conversa curta, para que o trabalho tenha passos e verificações claros.
Skills parecidas
test-driven-development
311 milEnsina seu agente a escrever primeiro um teste que falha, ver a falha e depois escrever o menor código que passa, antes de criar qualquer funcionalidade ou correção.
verification-before-completion
311 milEnsina seu agente a rodar verificações reais e ler a saída antes de afirmar que uma tarefa, correção ou build está concluído ou passando.
migrate-to-shoehorn
310 milSubstitui conversões de tipo arriscadas nos seus arquivos de teste pela biblioteca shoehorn, para que os testes usem dados parciais e ainda passem na checagem de tipos.