debugging-difficult-bugs
Fungsinya
Skill ini memandu metode debugging yang cermat untuk bug tingkat sedang atau sulit. Skill ini meminta agent mereproduksi masalah nyata dan membaca log saat runtime sebelum mencoba perbaikan.
Kapan dipakai
- ✓Saat bug melibatkan waktu, state, streaming, atau perilaku runtime lain yang mungkin tidak tertangkap pengujian.
- ✓Saat sebuah pengujian gagal tetapi mungkin tidak memodelkan masalah yang sebenarnya.
- ✓Saat Anda tergoda untuk membuat perbaikan berdasarkan tebakan lagi tanpa bukti baru.
Link skill
https://github.com/mastra-ai/mastra/blob/main/.claude/skills/debugging-difficult-bugs/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
“Bug ini hanya terjadi saat dua permintaan masuk bersamaan. Bantu saya menemukan penyebab sebenarnya sebelum kita mengubah kode apa pun.”
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent menyatakan apa yang belum ia yakini, menambahkan logging sementara ke jalur kode yang sebenarnya, dan mereproduksi masalahnya. Setelah itu agent membaca log dan menarik kesimpulan sebelum mengusulkan perbaikan.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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
Pertanyaan umum
Apakah metode ini melewati penulisan pengujian?
Tidak. Skill ini menyatakan pengujian saja bisa memberi rasa percaya diri yang keliru, sehingga bukti runtime didahulukan dan pengujian ditambahkan setelahnya.
Kapan metode ini bisa dilewati?
Hanya jika jejak stack atau pengujian gagal yang deterministik sudah membuktikan penyebabnya.
Apakah log boleh berisi data pribadi?
Metode ini menyarankan hanya mencatat metadata, bukan prompt atau konten.
Detail
Deskripsi asli dari pembuat
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
Popularitas
- Bintang GitHub
- 29k
- Peringkat
- #9360
- Lisensi
- —
- Diperbarui
- 2/11/2026
Komentar
- …
Skill lain dari repositori ini
mastra-frontend
29kMembantu agent Anda membangun layar aplikasi dengan sistem desain playground Mastra, dengan menggabungkan komponen siap pakai alih-alih menata gaya dari nol.
pr-explainer
29kMembantu agent Anda mengubah pull request menjadi halaman HTML yang jelas dan mandiri, yang menjelaskan perubahan kepada peninjau.
pr-splitter
29kMembantu agent Anda memecah pull request besar dan berantakan menjadi pull request kecil yang mudah ditinjau, sambil menjaga pekerjaan asli tetap aman.
ralph-plan
29kMembantu agent Anda merencanakan perintah tugas terstruktur dan terfokus lewat percakapan singkat, dengan langkah dan pemeriksaan yang jelas.
Skill serupa
test-driven-development
311kMengajari agent Anda menulis tes yang gagal dulu, melihatnya gagal, lalu menulis kode terkecil yang lulus, sebelum membangun fitur atau perbaikan apa pun.
verification-before-completion
311kMengajari agent Anda menjalankan pemeriksaan nyata dan membaca keluarannya sebelum menyatakan tugas, perbaikan, atau build sudah selesai atau lulus.
migrate-to-shoehorn
310kMengganti type cast berisiko di file tes Anda dengan pustaka shoehorn, sehingga tes bisa memakai data parsial dan tetap lulus pemeriksaan tipe.