Add teaching-style comments into pasted code, explaining the underlying concept behind each line instead of restating what the code says, producing a reusable study aid.
You are an instructor who thinks most auto-generated code comments are nearly worthless for learning, because a comment that says "increment i by 1" above a line that reads `i += 1` restates the code without teaching anything, while a comment explaining why a loop condition is written one way instead of another, or what concept a particular pattern demonstrates, actually earns its place in the file. My comment style should be [STYLE:select:brief one-line comments,fuller teaching comments that explain the concept too]. My code is: [CODE] If I left [CODE] blank, ask me to paste it before doing anything else instead of inventing a snippet to comment. Return the same code back to me with comments added directly into it, formatted using [LANGUAGE]'s actual comment syntax, positioned immediately above or beside the line each one refers to, exactly as it would look if I pasted the result back into my own file. Do not restate what a line obviously already says in code, `i += 1` does not need a comment that says "add one to i." Instead, comment on lines where a real decision, pattern, or concept is present, why a specific comparison operator was chosen, what a loop is actually accumulating and why, what a particular built-in method or function call does that is not obvious from its name alone, or where a piece of syntax is doing double duty in a way that is easy to misread. If I chose brief one-line comments, keep each one to a short phrase naming the concept or purpose at play, without full sentences. If I chose fuller teaching comments, expand each one into a short sentence or two that explains the underlying concept the way an instructor would say it out loud, connecting the specific line to the general idea it demonstrates, so studying the file later teaches the concept again, not just what that one line does. Skip commenting on lines that are self-evident from good naming alone, and skip adding a comment to every single line regardless of whether it earns one, since a file where every line has a comment is exactly as hard to learn from as a file with none, because the comments that matter get lost in the ones that do not. Close by asking whether there is one specific part of the code I want commented in even more depth than the rest, since a single line I am stuck on usually deserves a longer explanation than the uniform treatment the rest of the file needs.
Use this prompt anywhere
10,000+ expert prompts for ChatGPT, Claude, Gemini, and wherever you use AI.
Get Early AccessDiscover more prompts that could help with your workflow.
Build a small working program that calls a real public API, with the request, response, and API key setup explained step by step.
Explain a core functional programming idea, such as pure functions or immutability, with a broken code example and its fixed version shown side by side.
Explain a built-in math function, square root, power, absolute value, or rounding, covering math and syntax, then generate practice calls to predict before revealing results.
10,000+ expert-curated prompts for ChatGPT, Claude, Gemini, and wherever you use AI. Our extension helps any prompt deliver better results.