explain-changes.mdx 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. ---
  2. title: "Explain Changes"
  3. sidebarTitle: "Explain Changes"
  4. ---
  5. <Note>
  6. This feature is only available in **VS Code**. The diff view with inline comments requires VS Code's native diff capabilities.
  7. </Note>
  8. Explain Changes is an AI-powered code review feature that adds inline explanations to your code changes. When Cline makes modifications to your codebase, you can click a button to get streaming, contextual explanations that appear directly in VS Code's diff view.
  9. <Frame>
  10. <video
  11. autoPlay
  12. loop
  13. muted
  14. playsInline
  15. src="https://storage.googleapis.com/cline_public_images/explain-code-button.mp4"
  16. />
  17. </Frame>
  18. ## How It Works
  19. <Note>
  20. Explain Changes requires **[Checkpoints](/features/checkpoints)** to be enabled. Make sure to enable checkpoints in your Cline settings before using this feature.
  21. </Note>
  22. After Cline completes a task that involves file changes, you'll see an "Explain Changes" button alongside the "View Changes" button in the completion message. Clicking this button:
  23. 1. Opens a multi-file diff view showing all changed files
  24. 2. Streams AI-generated explanations as inline comments
  25. 3. Places comments at relevant code locations to explain what changed and why
  26. The AI uses the full conversation context to provide meaningful explanations, not just describing what code does, but explaining the reasoning behind the changes.
  27. ## Interactive Comment Threads
  28. One of the most powerful aspects of Explain Changes is that the comments are fully interactive. You can have conversations directly within each comment thread.
  29. ### Asking Follow-up Questions
  30. Each explanation comment has a reply input where you can ask questions about that specific piece of code:
  31. - "Why did you use this approach instead of X?"
  32. - "Can you explain this pattern in more detail?"
  33. - "What would happen if we changed this to Y?"
  34. The AI will respond with context-aware answers, understanding both the code being discussed and the original task context.
  35. ### Moving to Main Chat
  36. If a conversation in a comment thread becomes complex or you want to continue working on that code, click the title area of the comment thread to move the entire conversation into Cline's main chat input. This lets you:
  37. - Continue the discussion with full Cline capabilities
  38. - Have Cline make additional changes based on the discussion
  39. - Keep the context from your review conversation
  40. ## When to Use Explain Changes
  41. ### Learning and Onboarding
  42. When you're new to a codebase or working with unfamiliar patterns, Explain Changes helps you understand not just what Cline did, but why. The explanations cover:
  43. - Design decisions and trade-offs
  44. - Technical concepts and patterns used
  45. - Relationships between different changes
  46. ### Code Review
  47. Use Explain Changes as part of your review process:
  48. - Understand complex changes before committing
  49. - Verify the AI's reasoning matches your expectations
  50. - Catch potential issues by understanding the full context
  51. ### Knowledge Transfer
  52. The explanations serve as documentation for your changes. When other team members review your code, they can see the reasoning behind each modification.
  53. ## Best Practices
  54. 1. **Ask specific questions**: The more specific your follow-up questions, the more useful the AI's responses will be.
  55. 2. **Use for complex changes**: Explain Changes is most valuable for multi-file changes or complex logic. For simple changes, the diff view alone may be sufficient.
  56. 3. **Move important discussions to chat**: If a comment thread reveals something that needs more work, move it to main chat to take action.
  57. 4. **Review before committing**: Use Explain Changes as a final check before committing changes to ensure you understand everything Cline did.
  58. ## Related Features
  59. - [Checkpoints](/features/checkpoints) - Required for Explain Changes to work
  60. - [/explain-changes](/features/slash-commands/explain-changes) - Slash command to explain any git diff