Code review

From TheBushidoCollective/han · View interactive version

Code review is an AI agent skill from the GitHub repository TheBushidoCollective/han. Code review a pull request

How to use this skill

Skill file

Code Review Skill

Provides a systematic approach to conducting code reviews.

Focuses on the review process and quality dimensions, not

technology-specific patterns.

Name

han-core:code-review - Code review a pull request

Synopsis

/code-review [arguments]

Scope

Use this skill to:

NOT for

Implementation

Provide a code review for the given pull request.

To do this, follow these steps precisely:

  1. Use a Haiku agent to check if the pull request (a) is closed, (b) is a draft, (c) does not need a code review (eg. because it is an automated pull request, or is very simple and obviously ok), (d) already has a code review from you from earlier, OR (e) is too large (>1000 lines changed) and should be split. If any of these conditions are true, do not proceed.
  2. Use another Haiku agent to give you a list of file paths to (but not the contents of) any relevant CLAUDE.md files from the codebase: the root CLAUDE.md file (if one exists), as well as any CLAUDE.md files in the directories whose files the pull request modified
  3. Use a Haiku agent to view the pull request, and ask the agent to return a summary of the change
  4. Then, launch 5 parallel Sonnet agents to independently code review the change. The agents should work independently without seeing other agents' findings, then return a list of issues and the reason each issue was flagged (eg. CLAUDE.md adherence, bug, historical git context, etc.):

a. Agent #1: Audit the changes to make sure they comply with the CLAUDE.md. Note that CLAUDE.md is guidance for Claude as it writes code, so not all instructions will be applicable during code review.

b. Agent #2: Read the file changes in the pull request, then do a shallow scan for obvious bugs. Avoid reading extra context beyond the changes, focusing just on the changes themselves. Focus on large bugs, and avoid small issues and nitpicks. Ignore likely false positives.

c. Agent #3: Read the git blame and history of the code modified, to identify any bugs in light of that historical context

d. Agent #4: Read previous pull requests that touched these files, and check for any comments on those pull requests that may also apply to the current pull request.

e. Agent #5: Read code comments in the modified files, and make sure the changes in the pull request comply with any guidance in the comments.

IMPORTANT: After all 5 agents complete, verify their work using proof-of-work principles:

  1. Deduplicate and score issues:

a. First, deduplicate issues from step 4:

b. Then, for each unique issue, launch a parallel Haiku agent that takes the PR, issue description, and list of CLAUDE.md files (from step 2), and returns a score to indicate the agent's level of confidence for whether the issue is real or false positive. To do that, the agent should score each issue on a scale from 0-100, indicating its level of confidence. For issues that were flagged due to CLAUDE.md instructions, the agent should double check that the CLAUDE.md actually calls out that issue specifically. The scale is (give this rubric to the agent verbatim):

  1. Filter out any issues with a score less than 80. If there are no issues that meet this criteria, do not proceed.
  2. Use a Haiku agent to repeat the eligibility check from #1, to make sure that the pull request is still eligible for code review.
  3. Finally, use the gh bash command to comment back on the pull request with the result. When writing your comment, keep in mind to:

a. Keep your output brief

b. Avoid emojis

c. Link and cite relevant code, files, and URLs

Examples of false positives, for steps 4 and 5:

Notes:

Review Process Overview

Phase 1: Pre-Review Preparation

Before starting review, gather context

  1. Understand the change:

```bash

# Review the diff

git diff <base-branch>...HEAD

# Check scope of changes

git diff --stat <base-branch>...HEAD

```

  1. Identify relevant context:

```bash

# Find similar patterns in codebase

grep -r "similar_pattern" .

```

  1. Verify business context:

Phase 2: Systematic Review

Review across these dimensions

1. Correctness

Check correctness by

2. Safety

Check safety by

3. Maintainability

Check maintainability by

4. Testability

Check testability by

5. Performance

Check performance by

6. Standards Compliance

Check standards compliance by

Phase 3: Confidence Scoring

Apply confidence scoring to all findings

Each identified issue must include a confidence score (0-100) indicating how certain you are that it's a genuine problem:

| Score | Confidence Level | When to Use |

|-------|------------------|-------------|

| 100 | Absolutely certain | Objective facts: linter errors, type errors, failing tests, security vulnerabilities |

| 90 | Very high confidence | Clear violations of documented standards, obvious correctness bugs |

| 80 | High confidence | Pattern violations, missing error handling, maintainability issues |

| 70 | Moderately confident | Potential issues that need context, possible edge cases |

| 60 | Somewhat confident | Questionable patterns, style concerns with codebase precedent |

| 50 | Uncertain | Potential improvements without clear precedent |

| <50 | Low confidence | Speculative concerns, personal preferences |

CRITICAL FILTERING RULE: Only report issues with confidence >= 80%. Lower-confidence findings create noise and should be omitted.

Confidence Scoring Guidelines

High Confidence (90-100) - Report these:

Medium-High Confidence (80-89) - Report these:

Medium Confidence (60-79) - DO NOT REPORT:

Low Confidence (<60) - DO NOT REPORT:

False Positive Filtering

CRITICAL: Apply these filters to avoid reporting non-issues:

DO NOT REPORT:

VERIFY BEFORE REPORTING:

Example of False Positive vs. Genuine Issue:

False Positive: "This function could use TypeScript generics for better type safety" (confidence: 60%, style preference, no documented standard)

Genuine Issue: "Function processPayment at services/payment.ts:42 performs database operation without transaction protection, risking data inconsistency if an error occurs mid-operation." (confidence: 90%, documented pattern violation, clear impact)

Phase 4: Feedback & Decision

Provide structured feedback

  1. Summary: High-level assessment
  2. Strengths: What's done well (positive reinforcement)
  3. Issues: Organized by severity with confidence scores:
  1. Actionable next steps: Specific changes with file:line references
  2. Decision: Approve, Request Changes, or Needs Discussion

Note: Suggestions/nice-to-haves are intentionally omitted. Focus only on high-confidence, actionable feedback.

Approval Criteria

Approve When

Request Changes When

Needs Discussion When

Common Review Pitfalls

Reviewers often miss

  1. Authorization bypasses: Operations without proper access control
  2. Breaking changes: Not checking compatibility
  3. Error handling gaps: Only reviewing happy paths
  4. Test quality: Tests exist but don't actually test edge cases
  5. Domain logic errors: Not understanding business rules
  6. Commented-out code: Leaving dead code instead of removing
  7. Magic numbers: Unexplained constants without names
  8. Over-clever code: Complex when simple would work
  9. Boy Scout Rule violations: Making code worse, not better

Red Flags (Never Approve)

These always require changes

Integration with Development Workflow

Code review fits in Phase 2: Implementation

Implementation -> Verification Suite -> Code Review -> Approval -> Merge
                 (automated checks)   (this skill)    (human)

Review happens AFTER verification

  1. Developer runs verification suite
  2. ALL automated checks must pass
  3. Code review skill applied for quality assessment
  4. Issues identified and fixed
  5. Re-verify after fixes
  6. Human reviews and approves for merge

Review is NOT a substitute for verification. Both are required.

Output Format

For your final comment, follow the following format precisely (assuming for this example that you found 3 issues):


Code review

Found 3 issues:

  1. <brief description of bug> (CLAUDE.md says "<...>")

<link to file and line with full sha1 + line range for context, note that you MUST provide the full sha and not use bash here, eg. https://github.com/anthropics/claude-code/blob/1d54823877c4de72b2316a64032a54afc404e619/README.md#L13-L17>

  1. <brief description of bug> (some/other/CLAUDE.md says "<...>")

<link to file and line with full sha1 + line range for context>

  1. <brief description of bug> (bug due to <file and code snippet>)

<link to file and line with full sha1 + line range for context>

Generated with Claude Code

<sub>- If this code review was useful, please react with thumbs up. Otherwise, react with thumbs down.</sub>



Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Generated with Claude Code

Constructive Feedback Principles

When providing feedback

  1. Be specific: Point to exact lines, not vague areas
  2. Explain why: Don't just say "this is wrong," explain the impact
  3. Provide direction: Suggest approaches or patterns
  4. Balance critique with praise: Note what's done well
  5. Prioritize issues: Critical vs. important vs. suggestions
  6. Be respectful: Code is not the person
  7. Assume competence: Ask questions, don't accuse
  8. Teach, don't just correct: Help developers grow

Example of constructive feedback

Good: "In services/payment_service:45, processing payments without

transaction protection could lead to data inconsistency if an error occurs

mid-operation. Wrap the operation in a transaction to ensure atomicity.

Consider the ACID principles from database design."

Bad: "Use transactions here."

Quality Philosophy

Code review ensures

Remember

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.