Overview
This prompt guides programmers in enhancing code documentation through structured comments. Developers and code maintainers will benefit from improved readability and understanding of the codebase.
Prompt Overview
Purpose: This method calculates the sum of two integers.
Inputs: Two integers, a and b.
Outputs: Returns the sum of a and b.
Side effects: None.
Implementation details: Uses basic arithmetic to compute the result.
public int add(int a, int b) {
return a + b;
}
Purpose: This method checks if a number is even.
Inputs: An integer number.
Outputs: Returns true if number is even, otherwise false.
Side effects: None.
Implementation details: Utilizes the modulus operator to determine evenness.
public boolean isEven(int number) {
return number % 2 == 0;
}
Purpose: This method retrieves a user by their unique ID.
Inputs: A string userId.
Outputs: Returns a User object associated with the given ID.
Side effects: May throw an exception if the user is not found.
Implementation details: Queries the database for the user record.
public User getUserById(String userId) {
// Database query logic here
}
Purpose: This method logs an error message to the console.
Inputs: A string errorMessage.
Outputs: None.
Side effects: Outputs to the console.
Implementation details: Uses the System.out.println method for logging.
public void logError(String errorMessage) {
System.out.println(“Error: ” + errorMessage);
}
Quick Specs
- Media: Text
- Use case: Code documentation
- Techniques: Commenting, HTML formatting
- Models: TraceAnalyticsPolicyInspector, TraceAnalyticsPolicyQualifier, TraceMetricPolicyInspector
- Estimated time: 1-2 hours
- Skill level: Intermediate
Variables to Fill
No inputs required — just copy and use the prompt.
Example Variables Block
No example values needed for this prompt.
The Prompt
You are given a code file that contains multiple methods. Your task is to add detailed comments above all methods in this file using the comment styles and formatting consistent with the references provided by:
– TraceAnalyticsPolicyInspector
– TraceAnalyticsPolicyQualifier
– TraceMetricPolicyInspector
### Instructions
– For each method, write a clear, descriptive comment explaining:
– Purpose
– Inputs
– Outputs
– Side effects
– Any important implementation details
– Use paragraph tags “ or similar HTML-style formatting as observed in the reference comments to ensure structured, readable comments.
– Analyze the references to understand:
– Tone
– Style
– Formatting conventions for comments
– Apply the same style consistently to all methods in the given file.
– Ensure comments are complete but concise, aiding readability and maintainability without unnecessary verbosity.
### Steps
1. Review the commenting style in the references.
2. Understand the parameter descriptions, return explanations, and general comment structure used.
3. For each method in the given file:
– Identify the method’s purpose and behavior.
– Compose a descriptive comment using “ tags and formatting similar to the references.
4. Insert these comments immediately above each method definition.
### Output Format
– Return the full content of the original file with the newly added formatted comments above each method.
– Preserve original code indentation and formatting, only adding comments.
### Notes
– Do not alter method code or signatures.
– Follow the references exactly in terms of comment style and formatting.
– If a method’s purpose is unclear from the code, infer it cautiously or note TODO in the comment accordingly.
Screenshot Examples
How to Use This Prompt
- Copy the prompt provided above.
- Analyze the commenting style in the reference documents.
- Identify each method’s purpose, inputs, outputs, and side effects.
- Write structured comments using tags above each method.
- Ensure consistent formatting and clarity throughout all comments.
- Return the original file with comments added, preserving code structure.
Tips for Best Results
- Commenting Style: Use structured comments with clear sections for purpose, inputs, outputs, and side effects.
- Consistency: Maintain the same tone and formatting across all method comments to enhance readability.
- Clarity: Ensure comments are concise yet informative, avoiding unnecessary verbosity while providing essential details.
- Implementation Details: Highlight any important implementation specifics that may affect how the method is used or understood.
FAQ
- What is the purpose of adding comments to methods?
Comments clarify the purpose, inputs, outputs, and implementation details of methods. - How should comments be formatted?
Use HTML-style formatting like <p> tags for structured and readable comments. - What should be included in method comments?
Include purpose, inputs, outputs, side effects, and important implementation details. - Why is consistent commenting style important?
Consistency aids readability and maintainability, making it easier for others to understand the code.
Compliance and Best Practices
- Best Practice: Review AI output for accuracy and relevance before use.
- Privacy: Avoid sharing personal, financial, or confidential data in prompts.
- Platform Policy: Your use of AI tools must comply with their terms and your local laws.
Revision History
- Version 1.0 (February 2026): Initial release.


