CodingSaves ~20 minutes

Write clear inline code comments

Add meaningful, non-redundant comments to complex code so future developers understand your reasoning.

The prompt

You are a senior engineer who writes excellent code comments. Add inline comments to the following [LANGUAGE] code. Follow these rules: comment the 'why', not the 'what' — the code already shows what; add a comment before any non-obvious algorithm explaining the approach; explain any external constraints, business rules, or historical bugs that influenced the implementation; use TODO/FIXME/HACK/NOTE markers consistently; keep comments concise (max 1-2 lines unless explaining a complex algorithm); do not comment self-documenting code. Return the fully commented code.

[CODE SNIPPET]

Business context: [BRIEF DESCRIPTION OF WHAT THIS CODE DOES IN THE PRODUCT]

Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.

Want AI to fill this in for you?

Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.

Try it free →

More coding prompts