The quality of the AI's answer depends entirely on the quality of context you provide. When debugging, always include: the full error message and stack trace, the relevant file, steps to reproduce, and what you have already tried.
Chất lượng câu trả lời của AI phụ thuộc hoàn toàn vào chất lượng ngữ cảnh bạn cung cấp. Khi debug, hãy luôn bao gồm: toàn bộ thông báo lỗi và stack trace, file liên quan, các bước để tái hiện lỗi, và những gì bạn đã thử.
1# Bad — vague, no context2"my app is broken, fix it"34# Bad — partial error only5"I get TypeError, what's wrong?"67# Good — full context8"Getting this error when submitting the login form:910TypeError: Cannot read properties of undefined (reading 'token')11 at handleSubmit (src/components/LoginForm.tsx:42:28)12 at HTMLFormElement.<anonymous> (src/components/LoginForm.tsx:18:5)Sometimes you don't need the AI to fix the bug immediately — you need it to help you think systematically. Ask the AI to form hypotheses about the root cause and rank them by likelihood before making any changes.
Đôi khi bạn không cần AI sửa lỗi ngay — bạn cần nó giúp bạn suy nghĩ có hệ thống. Yêu cầu AI đưa ra các giả thuyết về nguyên nhân gốc rễ và xếp hạng chúng theo độ khả thi trước khi thực hiện bất kỳ thay đổi nào.
1# Ask for hypotheses first2"Before fixing anything, here is the bug and the relevant code.3List the 3 most likely root causes, ranked by probability.4Explain your reasoning for each."56# Then narrow down7"Hypothesis #1 seems most plausible. What would you check8to confirm or rule it out without changing any code yet?"This approach avoids time-wasting trial-and-error loops and helps you understand the problem rather than just applying random patches.
Cách tiếp cận này tránh được vòng lặp 'thử-sai' tốn thời gian và giúp bạn hiểu vấn đề thay vì chỉ áp dụng bản vá ngẫu nhiên.
AI is excellent at decoding complex error messages, especially from bundlers, compilers, or third-party libraries. Paste the entire stack trace and ask for a plain-English explanation of each part.
AI rất giỏi giải mã các thông báo lỗi phức tạp, đặc biệt là từ bundlers, trình biên dịch, hoặc thư viện bên thứ ba. Paste toàn bộ stack trace và yêu cầu giải thích từng phần.
1# Ask for plain-language explanation2"Explain this stack trace in plain English.3Which line is the actual source of the error vs4which are just propagation frames?56[paste full stack trace]"78# Diff expected vs actual behavior9"Here is the function and its test.10The test expects X but gets Y.11Walk me through the execution step by step12to find where behavior diverges."Instead of guessing, let the AI suggest exactly which log statements to add to narrow the problem. Then ask it to write a failing test that reproduces the bug — when that test passes, the bug is fixed.
Thay vì đoán mò, hãy để AI đề xuất chính xác những log nào cần thêm để thu hẹp vấn đề. Sau đó, yêu cầu nó viết một failing test tái hiện lỗi — khi test đó pass, lỗi đã được sửa.
1# Ask for targeted logging2"Without changing any logic, add console.log statements3to this function that would tell us the value of4each variable at the point the error occurs."56# Ask for a reproducing test7"Write a failing unit test that reproduces this bug.8The test should pass once the bug is fixed.9Use the existing test patterns in src/__tests__/."1011# Then fix with the test as a safety net12"Now fix the bug. The test you just wrote must pass13and no existing tests should break."Một failing test trước khi sửa là bằng chứng rõ ràng nhất rằng bạn đang sửa đúng vấn đề.
AI can confidently give wrong answers. Recognizing the warning signs early will save you significant time.
AI có thể tự tin đưa ra câu trả lời sai. Nhận biết các dấu hiệu cảnh báo sớm sẽ giúp bạn tránh lãng phí thời gian.
AI sometimes invents method names, parameters, or config options that do not exist — especially for newer or less popular libraries. Always check official docs when the AI suggests an API you have not seen before.
AI đôi khi bịa đặt tên phương thức, tham số, hoặc tùy chọn cấu hình không tồn tại — đặc biệt với các thư viện mới hoặc ít phổ biến. Luôn kiểm tra tài liệu chính thức khi AI đề xuất một API bạn chưa thấy trước đây.
AI can apply a patch that looks reasonable but does not address the root cause — or worse, masks the symptom while the real problem remains. If an AI fix "resolves" the error but you do not understand why, ask for an explanation.
AI có thể áp dụng một bản vá trông hợp lý nhưng không giải quyết nguyên nhân gốc rễ — hoặc tệ hơn, che giấu triệu chứng trong khi vấn đề thực sự vẫn còn đó. Nếu bản vá của AI "giải quyết" lỗi nhưng bạn không hiểu tại sao, hãy đặt câu hỏi.
Nếu bạn thấy mình áp dụng bản vá thứ ba hoặc thứ tư cho cùng một lỗi, hãy dừng lại. Yêu cầu AI phân tích nguyên nhân gốc rễ thay vì tiếp tục vá: "Dừng vá. Giải thích nguyên nhân gốc rễ của lỗi này và đề xuất giải pháp đúng đắn về mặt kiến trúc."
- Always provide the full error, relevant file, reproduction steps, and what you already tried.
Luôn cung cấp lỗi đầy đủ, file liên quan, các bước tái hiện, và những gì bạn đã thử.
- Ask the AI to form and rank hypotheses before making any changes.
Yêu cầu AI đưa ra giả thuyết và xếp hạng chúng trước khi thực hiện bất kỳ thay đổi nào.
- Use AI to explain stack traces and identify which frame is the actual error source.
Sử dụng AI để giải thích stack trace và xác định khung nào là nguồn gốc thực sự của lỗi.
- Ask the AI to add targeted logging or write a failing test that reproduces the bug before fixing it.
Yêu cầu AI thêm logging có mục tiêu hoặc viết một failing test tái hiện lỗi trước khi sửa.
- Check official docs when AI suggests unfamiliar APIs — hallucinated APIs are a common trap.
Kiểm tra tài liệu chính thức khi AI đề xuất API không quen thuộc — ảo giác API là bẫy phổ biến.
- If you are applying a third patch, stop and request root-cause analysis instead.
Nếu bạn đang áp dụng bản vá thứ ba, hãy dừng lại và yêu cầu phân tích nguyên nhân gốc rễ.