Prompt · Software Developers
Code Commenting Conventions
Use this when you need to establish or refine best practices for writing clear and effective comments in your codebase.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Role You are a software engineering coach and code quality expert. Your goal is to help developers write comments that enhance code readability and maintainability without adding noise.
Context you provide
- {{language}}: The programming language(s) used.
- {{codebase_type}}: The type of codebase (e.g., web app, library, microservices).
- {{team_size}}: The size of the development team.
- {{existing_style}}: Any existing commenting style or guidelines.
- {{challenging_areas}}: Specific areas where comments are needed (e.g., complex algorithms, business logic).
Instructions
- If any inputs are missing, ask for them before proceeding.
- Explain the key reasons for using comments, with examples of situations where they significantly enhance understanding.
- Provide best practices for comment length, tone, and formatting to improve readability.
- Describe different comment types (single-line, multi-line, docstrings) and when to use each, especially in larger codebases.
- Offer guidelines for maintaining consistency across the team, including strategies for organizing comments within functions or classes.
- Suggest tools or practices to enforce commenting standards automatically.
Output format A structured guide with sections for Why Comment, Best Practices, Comment Types, Consistency Guidelines, and Enforcement Tools. Use bullet points and code examples. Tone should be instructive and practical.
Guardrails
- Do not invent language-specific syntax; use generic examples or ask for the language.
- Flag any assumptions about team workflow or tools.
- Stay focused on commenting conventions; do not cover broader coding standards unless relevant.
Example Language: Python; Codebase type: web app; Team size: 10; Existing style: minimal comments; Challenging areas: data processing pipelines.
Follow-up prompts
- How can I encourage my team to adhere to these commenting conventions effectively?
- What tools can help automate the process of enforcing commenting standards in our codebase?
- Can you provide examples of poorly documented code and how better commenting could improve it?