debugging-and-error-recovery
Fungsinya
Panduan ini membantu Anda menemukan dan memperbaiki error pada kode secara sistematis. Panduan ini mengajarkan Anda untuk berhenti, menyelidiki, dan menyelesaikan masalah, bukan menebak-nebak.
Kapan dipakai
- βSaat sebuah tes gagal setelah ada perubahan.
- βSaat program tidak berjalan sebagaimana mestinya.
- βSaat menemukan error yang tidak terduga.
Link skill
https://github.com/addyosmani/agent-skills/blob/main/skills/debugging-and-error-recovery/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
βKode saya memunculkan error aneh saat mencoba menyimpan data pengguna, bisakah Anda bantu cari tahu penyebabnya?β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Caranya adalah dengan meminta Anda mereproduksi error tersebut, lalu menemukan di mana error itu terjadi, menyederhanakan masalahnya, dan akhirnya memperbaiki penyebab utamanya.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
Debugging and Error Recovery
Overview
Systematic debugging with structured triage. When something breaks, stop adding features, preserve evidence, and follow a structured process to find and fix the root cause. Guessing wastes time. The triage checklist works for test failures, build errors, runtime bugs, and production incidents.
When to Use
- Tests fail after a code change
- The build breaks
- Runtime behavior doesn't match expectations
- A bug report arrives
- An error appears in logs or console
- Something worked before and stopped working
The Stop-the-Line Rule
When anything unexpected happens:
1. STOP adding features or making changes
2. PRESERVE evidence (error output, logs, repro steps)
3. DIAGNOSE using the triage checklist
4. FIX the root cause
5. GUARD against recurrence
6. RESUME only after verification passes
Don't push past a failing test or broken build to work on the next feature. Errors compound. A bug in Step 3 that goes unfixed makes Steps 4-6 wrong.
The Triage Checklist
Work through these steps in order. Do not skip steps.
Step 1: Reproduce
Make the failure happen reliably. If you can't reproduce it, you can't fix it with confidence.
Can you reproduce the failure?
βββ YES β Proceed to Step 2
βββ NO
βββ Gather more context (logs, environment details)
βββ Try reproducing in a minimal environment
βββ If truly non-reproducible, document conditions and monitor
When a bug is non-reproducible:
Cannot reproduce on demand:
βββ Timing-dependent?
β βββ Add timestamps to logs around the suspected area
β βββ Try with artificial delays (setTimeout, sleep) to widen race windows
β βββ Run under load or concurrency to increase collision probability
βββ Environment-dependent?
β βββ Compare Node/browser versions, OS, environment variables
β βββ Check for differences in data (empty vs populated database)
β βββ Try reproducing in CI where the environment is clean
βββ State-dependent?
β βββ Check for leaked state between tests or requests
β βββ Look for global variables, singletons, or shared caches
β βββ Run the failing scenario in isolation vs after other operations
βββ Truly random?
βββ Add defensive logging at the suspected location
βββ Set up an alert for the specific error signature
βββ Document the conditions observed and revisit when it recurs
For test failures (npm shown β substitute the repository's own test command, per the test-driven-development skill's Discover the Stack First section):
# Run the specific failing test
npm test -- --grep "test name"
# Run with verbose output
npm test -- --verbose
# Run in isolation (rules out test pollution)
npm test -- --testPathPattern="specific-file" --runInBand
Step 2: Localize
Narrow down WHERE the failure happens:
Which layer is failing?
βββ UI/Frontend β Check console, DOM, network tab
βββ API/Backend β Check server logs, request/response
βββ Database β Check queries, schema, data integrity
βββ Build tooling β Check config, dependencies, environment
βββ External service β Check connectivity, API changes, rate limits
βββ Test itself β Check if the test is correct (false negative)
Use bisection for regression bugs:
# Find which commit introduced the bug
git bisect start
git bisect bad # Current commit is broken
git bisect good <known-good-sha> # This commit worked
# Git will checkout midpoint commits; run your test at each
git bisect run npm test -- --grep "failing test" # substitute the repository's focused-test command
Step 3: Reduce
Create the minimal failing case:
- Remove unrelated code/config until only the bug remains
- Simplify the input to the smallest example that triggers the failure
- Strip the test to the bare minimum that reproduces the issue
A minimal reproduction makes the root cause obvious and prevents fixing symptoms instead of causes.
Step 4: Fix the Root Cause
Fix the underlying issue, not the symptom:
Symptom: "The user list shows duplicate entries"
Symptom fix (bad):
β Deduplicate in the UI component: [...new Set(users)]
Root cause fix (good):
β The API endpoint has a JOIN that produces duplicates
β Fix the query, add a DISTINCT, or fix the data model
Ask: "Why does this happen?" until you reach the actual cause, not just where it manifests.
Step 5: Guard Against Recurrence
β¦
Pertanyaan umum
Apa maksud 'preserve evidence'?
Maksudnya adalah menyimpan informasi penting tentang error, seperti pesan error, log, atau langkah-langkah yang Anda lakukan hingga error itu muncul.
Mengapa saya tidak boleh menambah fitur baru saat ada yang rusak?
Karena menambah kode bisa memperparah masalah atau menyembunyikan penyebab aslinya, sehingga lebih sulit diperbaiki.
Apa itu 'bisection'?
Itu adalah teknik untuk mencari perubahan spesifik yang menyebabkan masalah, dengan menguji versi kode yang lebih lama satu per satu hingga menemukan versi yang berfungsi dengan baik.
Detail
Deskripsi asli dari pembuat
Guides systematic root-cause debugging. Use when tests fail, builds break, something that worked yesterday broke, behavior doesn't match expectations, or you encounter any unexpected error. Use when you need to figure out what broke and why β a systematic approach to finding and fixing the root cause rather than guessing.
repo: addyosmani/agent-skills
Popularitas
- Bintang GitHub
- 107k
- Peringkat
- #768
- Lisensi
- MIT
- Diperbarui
- 13/10/2026
Komentar
- β¦
Skill lain dari repositori ini
api-and-interface-design
107kMembantu merancang API dan antarmuka yang terdefinisi dengan baik. Berguna saat merancang cara berbagai bagian perangkat lunak saling berkomunikasi.
browser-testing-with-devtools
107kMembantu agent Anda menguji kode langsung di browser sungguhan. Berguna untuk memeriksa cara kerja di lingkungan penggunaannya, serta menemukan error dan masalah performa.
ci-cd-and-automation
107kMengajarkan agent AI Anda untuk mengotomatisasi tugas berulang, mengirim proyek, dan mengelola infrastruktur.
code-review-and-quality
107kMelakukan tinjauan kode mendetail dari berbagai sisi. Berguna sebelum menggabungkan perubahan baru untuk memastikan kualitas dan mencegah masalah di kemudian hari.
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.