Read Anthropic’s case study about Graphite Reviewer

Code review comment types

Greg Foster
Greg Foster
Graphite software engineer
Try Graphite

Code reviews play a key role in maintaining code quality, improving team collaboration, and supporting developers’ professional growth. Effective code review comments are clear, constructive, and focused on enhancing the code—not criticizing the developer. In this guide, we'll break down the types of comments, strategies for clarity, and techniques to make your feedback more impactful.

Code reviews should encourage a positive development culture. Always use a respectful tone and frame your comments objectively, focusing on the code rather than the person writing it.

Avoid: "Why did you use threads here? This is pointless and adds unnecessary complexity."

Better: "The concurrency model seems to add complexity without improving performance. Would a single-threaded approach simplify this implementation without sacrificing speed?"

Why it matters: Courteous comments avoid personal friction and promote healthier team collaboration. Aim for clarity and kindness to help developers understand the feedback and feel empowered to make improvements.

Not all feedback requires a lengthy explanation, but if the reasoning isn’t obvious, clarify why you’re suggesting a change.

For example: "Switching to a Set here would remove duplicates more efficiently than filtering a list."

Why it matters: Including context behind suggestions makes it easier for developers to understand your rationale, reduces back-and-forth discussions, and improves the code review process.

While developers are responsible for implementing fixes, balancing feedback with actionable suggestions is helpful.

  • When to provide guidance: For complex issues or when the intent might be unclear.
  • Examples:
    • "Consider using a HashMap here to improve lookup time."
    • "You can simplify this method by extracting the repeated logic into a helper function."
    • "Here’s an example snippet: if (condition) { return; }."

Why it matters: Offering actionable suggestions speeds up the review process and helps junior developers learn better practices. Avoid rewriting the code for them unless absolutely necessary.

Adding labels to comments ensures developers can prioritize feedback appropriately:

  • Nit: Minor improvement (e.g., style, formatting). "Nit: Consider aligning variable names to match camelCase convention."
  • Optional: A suggestion that’s nice to have but not mandatory. "Optional: Using a constant here could make the value easier to update later."
  • Blocking: Critical issues that must be fixed before merging. "Blocking: This function doesn’t handle edge cases and could result in runtime errors."
  • FYI: Informational only; no action required. "FYI: This library will be deprecated in the next release."

Why it matters: Clearly labeled comments streamline the review process and prevent developers from treating all feedback as equally urgent.

If you ask for clarification and the developer provides a logical explanation, sometimes it’s better to document the reasoning rather than insist on rewriting the code.

  • When to accept explanations: If the justification improves code readability or makes sense contextually.
  • What to look for: Ensure explanations don’t cover up unnecessarily complex code.

For example: "Thanks for explaining! Adding a comment here to clarify the purpose of this method would help future readers."

Code reviews are collaborative, and developers may push back on suggestions. When this happens:

  1. Consider their perspective: They might have insights the reviewer hasn’t accounted for.
  2. Be objective: If their reasoning makes sense for code health, acknowledge it.
  3. Advocate politely: If their approach still introduces risks, explain why your suggestion improves the code.

Example: "I see your point, but this approach might cause performance issues under heavy load. Would you consider revisiting this design to optimize for scalability?"

Why it matters: Encouraging respectful discussions builds trust and ensures code reviews remain a collaborative, learning-focused activity.

  1. Be courteous and focus on the code, not the developer.
  2. Explain the reasoning when feedback isn’t immediately obvious.
  3. Provide actionable guidance without being overly prescriptive.
  4. Use labels like 'Nit', 'Optional', or 'Blocking' to clarify comment priority.
  5. Accept reasonable explanations while encouraging code clarity.
  6. Handle disagreements professionally and keep the discussion constructive.

By incorporating these practices into your code reviews, you can foster a culture of continuous improvement, enhance code quality, and build stronger collaboration across your development team.

Built for the world's fastest engineering teams, now available for everyone