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.
npx skills add https://github.com/mastra-ai/mastra --skill 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.
Use this workflow near the start of debugging when any of these are true:
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.
.jsonl file in the current working directory..jsonl file to send or ask them to tell you when reproduction is complete so you can inspect it..jsonl files, and any other temporary artifacts.Use append-only JSONL in cwd so it works across CLIs, dev servers, tests, and manual reproduction.
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 error;
}
Prefer compact, structured data over huge dumps.
Log:
Avoid logging:
Treat debug logs as potentially sensitive. Do not ask the user to paste them into public issues, PRs, or shared channels unless they have reviewed/redacted them first.
If sensitive data might appear, log redacted summaries:
debugBug('request.received', {
hasAuthHeader: Boolean(headers.authorization),
bodyKeys: Object.keys(body ?? {}),
messageCount: body?.messages?.length,
});
When the user needs to reproduce manually, say exactly this shape:
I added temporary unconditional JSONL instrumentation. Please reproduce the issue once, then send me or point me at:
<cwd>/debug-difficult-bug.jsonl
After I inspect that log, I’ll remove the instrumentation and make the actual fix.
If multiple processes have different working directories, either:
process.cwd(), process role, and pid at startup, ordebug-server-flow.jsonl, debug-worker-flow.jsonl, and debug-client-flow.jsonl.Before writing the fix, answer:
A difficult bug is not done until:
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup
Use when implementing any feature or bugfix, before writing implementation code
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always
Expert guidance for systematic backtesting of trading strategies. Use when developing, testing, stress-testing, or validating quantitative trading strategies. Covers "beating ideas to death" methodology, parameter robustness testing, slippage modeling, bias prevention, and interpreting backtest results. Applicable when user asks about backtesting, strategy validation, robustness testing, avoiding overfitting, or systematic trading development.
Cloud laboratory platform for automated protein testing and validation. Use when designing proteins and needing experimental validation including binding assays, expression testing, thermostability measurements, enzyme activity assays, or protein sequence optimization. Also use for submitting experiments via API, tracking experiment status, downloading results, optimizing protein sequences for better expression using computational tools (NetSolP, SoluProt, SolubleMPNN, ESM), or managing protein design workflows with wet-lab validation.
This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.
Take mastra-ai/debugging-difficult-bugs from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.