Helpful comments for existing code
Prompt for helpful comments and function descriptions in existing code, without changing logic or names. Paste it into an AI tool of your choice, which then comments the code.
- Topic
- Understanding code
- Type
- Prompt
- Level
- Beginner
- Time
- about 5 min
Results depend on the tool, the model and what you enter.
Result preview
Example: written by our editors, not real AI output.
def net_price(gross, rate): """Converts a gross price into the net price. gross: price including tax, as a decimal. rate: tax rate as a fraction, e.g. 0.2. Returns the net price rounded to two places. """ # Round only at the end so rounding errors do not add up. return round(gross / (1 + rate), 2) Check: what happens when rate = -1?
Fill in
What you type stays in this browser window. We store and send nothing.
- Python
- TypeScript
- Java
- PHP
- Go
- new team members
- me in six months
- external contributors
- students
- the maintenance team
Your prompt
You have edited the prompt. Changes in the fields above no longer overwrite it.
This is an instruction for an AI, not the result itself.
Where this prompt works
These AI tools are a good fit for this prompt:
How to use it
- Fill in the fields or tap a suggestion. Leave out names, addresses and other personal data.
- Copy the finished prompt into an AI tool of your choice.
- Read through the comments and resolve the Check points before you adopt them.
Why does this work?
Comments that explain the why stay useful after changes. The rule not to change logic keeps the change small and easy to review.
Tips
- Leave out sensitive values such as keys or passwords before pasting, or replace them with placeholders.