/cursor-tutorials

How to make Cursor add code comments

Learn how to make Cursor add code comments automatically using simple settings and prompts to boost clarity, consistency, and your coding workflow.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to make Cursor add code comments

Cursor can add code comments automatically, but it only does it when you explicitly ask it to do so. The two main ways are: selecting the code and using the Cmd/Ctrl + K shortcut to tell Cursor what kind of comments you want, or using an AI command like “Explain this code with inline comments” directly in the chat. Cursor will then rewrite the code by inserting comments above lines or inside functions. It won’t invent its own style unless you define it.

 

How Cursor Actually Adds Comments

 

Cursor is basically a VS Code editor with an AI engine built into it. It does not auto‑annotate code by itself. You always have to trigger an edit or give a request. When you do, Cursor creates a diff (a proposed code change) where it inserts comment lines (// comment for JS/TS, # comment for Python, etc.). You can accept or reject the changes like normal Git-style edits.

  • Select code + Cmd/Ctrl + K: Opens the command box for that exact section.
  • Write a command like “Add inline comments explaining each step.”
  • Cursor proposes edits with comments added directly in your file.
  • You approve the diff and the comments are inserted.

 

Most Reliable Ways to Make Cursor Add Comments

 

Below are the practical workflows developers actually use in real projects.

  • Inline edit command while selecting code You highlight the code you want commented, press Cmd/Ctrl + K, and type something like: “Add clear inline comments in a beginner-friendly style, but do not change logic.”
  • Chat command targeting a file In the Chat panel, write: “Add explanatory comments to server.js. Do not refactor anything.” Cursor will open the applied diff for that file.
  • Explain mode Right-click → “Explain.” This gives an explanation in the sidebar. If you then say: “Insert these explanations as inline comments in the file.” Cursor will rewrite the file with comments.

 

Example: What Cursor Will Actually Produce

 

You highlight this JavaScript snippet and ask “Add helpful comments explaining each line.”

function sum(a, b) {
  return a + b;
}

Cursor will propose something like this:

function sum(a, b) {
  // Add the two input numbers and return the result
  return a + b;
}

This is exactly how it shows up in the diff panel before you accept it.

 

Tips So Cursor Doesn’t Overdo or Break Code

 

  • Always say: “Do not modify logic.” Otherwise Cursor sometimes rewrites code.
  • Define the style you want — short, long, beginner-friendly, JSDoc, etc.
  • Apply comments incrementally instead of to the entire file at once, especially in large codebases.
  • Use Undo if needed — Cursor edits are real file changes, so they’re reversible like any Git diff.

 

Summary

 

To make Cursor add comments, you either select code and press Cmd/Ctrl + K or issue a clear request in Chat. Cursor then generates a code diff with comments inserted exactly where you need them. It never adds comments automatically; you must explicitly ask.

Still stuck?
Copy this prompt into ChatGPT and get a clear, personalized explanation.

This prompt helps an AI assistant understand your setup and guide you through the fix step by step, without assuming technical knowledge.

AI AI Prompt

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022