Code that works is good. Code that’s clear is even better.
Well-written comments help teammates (and future you) understand the why behind the code.
With GitHub Copilot, you don’t need to pause and think too hard.
Just prompt it to draft comments that make your logic easier to follow.
Let’s break it down! 📝💻
Ask Copilot to Generate Comments That Explain Your Code Clearly
Instead of leaving code bare, or writing vague notes, use Copilot Chat, Edit, or Agent Mode to quickly generate helpful, structured comments.
Try These Approaches
1️⃣ Copilot Chat: Add Explanations
# Add inline comments explaining each step of this function
Great for walking through logic in complex methods.
2️⃣ Edit Mode: Comment While You Code
Highlight a block and type:
# Add docstrings to describe inputs, outputs, and edge cases
Copilot will generate docstrings that make functions easier to reuse.
3️⃣ Agent Mode: Review for Readability
Review this file and suggest clearer inline comments where the logic might confuse a new developer.
Perfect when onboarding teammates or preparing for a code review.
Extra Prompts to Try
- # Add comments that explain the purpose of each class property
- // Generate a top-level comment explaining what this script does
- # Add inline notes for this algorithm to clarify performance trade-offs
Quick Takeaway
Readable code is not only about syntax.
With a few well-placed prompts, Copilot can help you document logic as you write it, making your code easier to maintain and share.