Перейти к содержанию
Skillpedia
Тестирование29k · #9360

debugging-difficult-bugs

Что он делает

Этот скилл задаёт аккуратный метод отладки средних и сложных багов. Он просит агента воспроизвести реальную проблему и прочитать журналы времени выполнения, прежде чем пытаться её исправить.

Когда использовать

  • ✓Когда баг связан с таймингом, состоянием, потоковой передачей или другим поведением во время работы, которое тесты могут не учитывать.
  • ✓Когда тест падает, но, возможно, не моделирует реальную проблему.
  • ✓Когда возникает соблазн сделать ещё одно исправление наугад без новых доказательств.

Ссылка на скилл

https://github.com/mastra-ai/mastra/blob/main/.claude/skills/debugging-difficult-bugs/SKILL.md

Скопируйте и вставьте её в ваш ИИ (Claude, ChatGPT или Cursor) с просьбой следовать инструкциям.

Как использовать

Самый простой способ: скопируйте сообщение и вставьте его в свой ИИ. Он прочитает скилл и выполнит инструкции.

Готовое сообщение для вставки

Используй этот скилл, чтобы помочь мне: https://github.com/mastra-ai/mastra/blob/main/.claude/skills/debugging-difficult-bugs/SKILL.md Прочитай файл SKILL.md по этой ссылке и следуй его инструкциям в моей задаче.
Хотите, чтобы ваш ИИ сам находил такие скиллы?Установите бесплатный MCP Skillpedia: одна строка, и перед каждой задачей он ищет среди 15 000+ скиллов.Установить за 1 минуту →

Пример запроса к вашему ИИ

“Этот баг возникает только тогда, когда приходят два запроса одновременно. Помоги найти настоящую причину, прежде чем мы что-то поменяем в коде.”

5 новых скиллов в неделю. 1 минута чтения.

Как это работает

Агент говорит, в чём он не уверен, добавляет временное логирование в реальный путь выполнения кода и воспроизводит проблему. Затем он читает журналы и формулирует вывод, прежде чем предлагать исправление.

Технический текст (оригинальный SKILL.md)

Оригинальный текст автора на английском, прямо с 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

  1. State the uncertainty

    • Acknowledge that the current test may not capture the actual bug.
    • Identify the real code path that must be observed.
  2. 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 .jsonl file 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.
  3. 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 .jsonl file to send or ask them to tell you when reproduction is complete so you can inspect it.
  4. 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.
  5. Clean up instrumentation

    • Remove all temporary unconditional logs after root cause is understood and the fix is verified.
    • Remove debug imports, helper functions, generated .jsonl files, 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.
  6. 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
Частые вопросы

Пропускает ли он написание тестов?

Нет. Он говорит, что одни тесты могут создавать ложную уверенность, поэтому сначала идут доказательства из времени выполнения, а тесты добавляются после.

Когда этот шаг можно пропустить?

Только тогда, когда трассировка стека или детерминированный падающий тест уже доказывают причину.

Должны ли журналы содержать личные данные?

Метод рекомендует записывать только метаданные, а не промпты или содержимое.

Подробности

Оригинальное описание автора

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

Популярность

Звёзды на GitHub
29k
Место в рейтинге
#9360
Лицензия
—
Обновлён
02.11.2026

Полезен ли этот скилл?

0

Войдите , чтобы голосовать.

Комментарии

  • …

Другие скиллы из этого репозитория

Похожие скиллы