Using claude 3.5 and 3.7 I find that the default mode is WAY to eager to insert redundant code comments. I’ve added the following as part of my user rules:
- Don’t insert redundant code comments: if the variable and function names make a context clear, don’t add redundant comments that echo those. Aim to make the code itself clear and self-describing.
- Don’t delete existing comments or docstrings.
I’ve also added two different project rules that apply to .swift and .py files:
First rule:
Don’t include redundant comments that describe clearly obvious functionality.
Eg, these comments are redundant:
// Updated initializer with DI
init(
symbolName: String = "bell",
color: NSC
class MenuBarIcon: MenuBarIconProtocol {
// Existing properties…
private var popoverController: NSPopover?
// Create a menu
let menu = NSMenu()
Second rule:
Title: Code comment guidelines
General
Comment on why, not what - explain reasoning behind code, not mechanics
Be concise - aim for clarity with minimal text
Keep comments updated when code changes
Use a consistent style throughout the codebase
When to Comment
Complex algorithms or business logic
Non-obvious workarounds or edge cases
Public APIs and interfaces
Performance considerations
Known limitations or technical debt
Security-related implementations
When NOT to Comment
Self-explanatory code
Obvious implementations
Information better expressed through clear variable/function names
When NOT to change
Don’t alter existing code comments unless asked to.
If comments contain wrong or out of date information, prompt the user about this
Format and Style
Use header blocks for files/classes/modules
Place inline comments on separate lines before the code they describe
Maintain proper indentation aligned with the code
Use consistent grammar, punctuation, and capitalization
Follow language/framework conventions (e.g., JSDoc, Javadoc)
Content Guidelines
Include specific examples for complex logic
Reference related issues, tickets, or documentation
Explain “magic numbers” or unusual constants
Document assumptions and preconditions
Mention potential side effects
For Collaborative Environments
Add TODO/FIXME with specific details and owner when applicable
Include dates on temporary solutions
Document decision rationale that may not be apparent to others
Reference domain knowledge when relevant
I ALSO have a design_spec.md doc which includes language about this and other design guidance.
Cursor STILL loves to add redundant comments, eg it just generated this in response to a query that included these rules and the design spec as part of the context:
// Add to protocol
protocol MenuBarIconProtocol {
// ... existing methods
func updateBasedOnDistractionLevel()
}
class MenuBarIcon: MenuBarIconProtocol {
// ... existing properties and methods
// Method to update color based on distraction level
func updateBasedOnDistractionLevel() {
let level = appMonitor.distractionLevel
let color = colorForDistractionLevel(level)
setColor(color: color)
}
// Helper method to determine color
private func colorForDistractionLevel(_ level: Double) -> NSColor {
if level >= 0.4 {
return .systemGreen
} else if level >= 0.25 {
I’m on OS X, and using the using 0.46.11. This obviously doesn’t stop me from working, but is IS annoying. I’ve also seen the issue others have reported where cursor will want to delete comments I’ve added somewhat zealously.
Thanks for reporting a bug you have found in Cursor!
Please add the following info to help us diagnose your issue:
Check the forum to ensure the issue hasn’t been reported already
Provide a clear description of the bug
Explain how to reproduce the bug (if known)
Attach screenshots or recordings (e.g.,
.jpg
, .png
, .mp4
).
Tell us your operating system and your Cursor version (e.g.,
Windows, 0.x.x
).
Tell us if the issue stops you from using Cursor.