debugging-difficult-bugs
Qué hace
Esta skill guía un método de depuración cuidadoso para errores de dificultad media o alta. Pide al agente que reproduzca el problema real y lea los registros de ejecución antes de intentar una corrección.
Cuándo usarla
- ✓Cuando un error depende del tiempo, del estado, del streaming u otro comportamiento de ejecución que las pruebas podrían no captar.
- ✓Cuando una prueba falla pero podría no modelar el problema real.
- ✓Cuando tienes la tentación de hacer otra corrección basada en suposiciones sin nuevas pruebas.
Link de la skill
https://github.com/mastra-ai/mastra/blob/main/.claude/skills/debugging-difficult-bugs/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“Este error solo ocurre cuando llegan dos peticiones a la vez. Ayúdame a encontrar la causa real antes de cambiar código.”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
El agente indica qué no tiene claro, añade registros temporales en la ruta de código real y reproduce el problema. Después lee los registros y saca una conclusión antes de proponer una corrección.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de 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
Preguntas frecuentes
¿Omite escribir pruebas?
No. Indica que las pruebas por sí solas pueden dar una falsa confianza, así que primero van las pruebas de ejecución y luego se añaden pruebas.
¿Cuándo se puede omitir?
Solo cuando una traza de pila o una prueba determinista que falla ya demuestran la causa.
¿Los registros deben contener datos privados?
El método recomienda registrar solo metadatos, no prompts ni contenido.
Detalles
Descripción original del 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
Popularidad
- Estrellas en GitHub
- 29 mil
- Posición en el ranking
- #9360
- Licencia
- —
- Actualizada
- 2/11/2026
Comentarios
- …
Más skills de este repositorio
mastra-frontend
29 milAyuda a tu agente a crear pantallas de app con el sistema de diseño del playground de Mastra, combinando sus componentes listos en lugar de dar estilo desde cero.
pr-explainer
29 milAyuda a tu agente a convertir un pull request en una página HTML clara y autocontenida que explica el cambio a los revisores.
pr-splitter
29 milAyuda a tu agente a dividir un pull request grande y desordenado en pull requests más pequeños y fáciles de revisar, manteniendo a salvo el trabajo original.
ralph-plan
29 milAyuda a tu agente a planificar una tarea concreta y estructurada mediante un intercambio corto de mensajes, para que el trabajo tenga pasos y comprobaciones claros.
Skills parecidas
test-driven-development
311 milEnseña a tu agente a escribir primero una prueba que falle, verla fallar y después escribir el código más pequeño que la hace pasar, antes de construir cualquier función o corrección.
verification-before-completion
311 milEnseña a tu agente a ejecutar comprobaciones reales y leer su resultado antes de afirmar que una tarea, una corrección o una compilación está completa o en buen estado.
migrate-to-shoehorn
310 milSustituye los casts de tipo arriesgados de tus archivos de prueba por la librería shoehorn, para que las pruebas usen datos parciales y sigan pasando las comprobaciones de tipos.