Back to prompts
Coding & Developmentbeginner
4.3

Code Commenter

Paste uncommented code and get it back with clear, helpful comments explaining what each part does.

Copy & Paste this prompt
You are a senior developer who writes excellent code comments. I'll paste code that has no comments (or poor comments). Add clear, helpful comments that explain:

1. **What** each section/function does (purpose)
2. **Why** important decisions were made (reasoning)
3. **How** complex logic works (explanation for non-obvious parts)

Rules:
- Don't comment obvious things (e.g., `i++` doesn't need "increment i")
- Use the comment style appropriate for the language
- Add a brief docstring/header comment for each function
- Keep comments concise — one line where possible
- Don't modify the code itself, only add comments

Language: [AUTO-DETECT or specify]

Code:
[PASTE YOUR CODE HERE]
#comments#documentation#code-quality#readability

Works with

chatgptclaudegemini

💡 Pro Tips

  • Specify the language if auto-detection might get it wrong
  • Ask for 'beginner-friendly comments' if the code will be read by juniors
  • Works great for code you inherited and need to understand quickly

🧠 Why This Works

Good comments explain why, not what. This prompt adds contextual comments that help future developers understand design decisions, non-obvious logic, and potential gotchas—without cluttering code with redundant descriptions of obvious operations.

📅 When to Use This Prompt

Use when preparing code for handoff to another developer, when documenting complex algorithms or business logic, or when your team's codebase needs better inline documentation for maintainability.

🎯 What You'll Get

You'll get your code with strategically placed comments explaining the reasoning behind decisions, warnings about edge cases, and documentation of non-obvious behavior—following your language's documentation conventions.

🔗 Related Prompts

Coding & DevelopmentPremium

Technical Documentation Writer

Generate clear, maintainable technical documentation from code — README, API docs, architecture guides, and runbooks.

codingdevelopmenttechnical
4.7
intermediate
Coding & Development

Senior Engineer Code Review

Get a thorough code review as if a senior engineer is looking at your PR — bugs, patterns, performance, and suggestions.

code-reviewbest-practicessecurity
4.9
intermediate
Coding & DevelopmentPremium

Legacy Code Refactoring Roadmap

Create a safe, step-by-step refactoring plan for messy legacy code without breaking production.

refactoringlegacy-codecode-quality
4.7
advanced