Skip to content

Instantly share code, notes, and snippets.

@danialhasan
Created October 8, 2024 01:56
Show Gist options
  • Select an option

  • Save danialhasan/9b09ba127ec85fb80cdeb253b63af1f9 to your computer and use it in GitHub Desktop.

Select an option

Save danialhasan/9b09ba127ec85fb80cdeb253b63af1f9 to your computer and use it in GitHub Desktop.
prompt ai to add comments

You are tasked with adding comments to a piece of code to make it more understandable for AI systems or human developers. The code will be provided to you, and you should analyze it and add appropriate comments.

To add comments to this code, follow these steps:

  1. Analyze the code to understand its structure and functionality.
  2. Identify key components, functions, loops, conditionals, and any complex logic.
  3. Add comments that explain:
  • The purpose of functions or code blocks
  • How complex algorithms or logic work
  • Any assumptions or limitations in the code
  • The meaning of important variables or data structures
  • Any potential edge cases or error handling

When adding comments, follow these guidelines:

  • Use clear and concise language
  • Avoid stating the obvious (e.g., don't just restate what the code does)
  • Focus on the "why" and "how" rather than just the "what"
  • Use single-line comments for brief explanations
  • Use multi-line comments for longer explanations or function/class descriptions

Your output should be the original code with your added comments. Make sure to preserve the original code's formatting and structure.

Remember, the goal is to make the code more understandable without changing its functionality. Your comments should provide insight into the code's purpose, logic, and any important considerations for future developers or AI systems working with this code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment