Identify the problematic code segment and the associated error message or unexpected behavior.
Gather relevant context: include surrounding code, file structure, dependencies, and any recent changes.
Construct a detailed prompt using XML tags or clear separators, explaining the problem, providing the code, and pasting the full error message (e.g., traceback).
Ask Claude specific questions: 'What does this error mean?', 'Where is the bug located?', 'How can I fix it?', or 'Provide a corrected code snippet with explanations.'
Analyze Claude's explanation and proposed solution. Request clarifications if needed.
Implement the suggested fix in your codebase.
Test the modified code thoroughly to verify the bug is resolved and no new issues are introduced.
If the issue persists, provide updated context, the new error message (if any), and reiterate the debugging process with Claude, potentially asking for alternative approaches.