Code review

From TheBushidoCollective/han · View interactive version

Code review is an AI agent skill from the GitHub repository TheBushidoCollective/han. Review current branch changes against REVIEW.md guidelines

How to use this skill

Skill file

Code Review

Name

session-code-review:code-review - Review session changes against REVIEW.md and CLAUDE.md guidelines

Synopsis

/code-review [--branch <base>]

Description

Performs a thorough code review of all changes on the current branch compared to the base branch (defaults to main or master). Reviews against REVIEW.md and CLAUDE.md guidelines in the repository.

This is a local-only review — no PR or GitHub integration required. It examines your uncommitted changes, staged changes, and all commits on the current branch.

Implementation

Follow these steps exactly:

1. Determine the base branch

If --branch was provided, use that. Otherwise, detect the default branch:

git remote show origin | grep 'HEAD branch' | sed 's/.*: //'

2. Gather review guidelines

Read the following files if they exist:

These define the review criteria. If no REVIEW.md or CLAUDE.md exists, use general best practices (security, correctness, logic errors).

3. Get the full diff

# Uncommitted changes
git diff

# Staged changes
git diff --cached

# All commits on this branch vs base
git diff <base-branch>...HEAD

4. Review the changes

For each changed file, check against the guidelines from step 2. Focus on:

Do NOT flag:

5. Report findings

For each issue found, report:

If no issues are found, report: "No issues found. Changes comply with REVIEW.md and CLAUDE.md guidelines."

6. Offer to fix

If issues were found, ask the user if they'd like you to fix them.

Example Interaction

User: /code-review

Claude: Reviewing changes on branch `feature/auth-flow` against `main`...

Found REVIEW.md with 3 rules:
1. All API routes must validate auth tokens
2. Database queries must use parameterized statements
3. Error responses must not leak internal details

Reviewing 4 changed files...

## Code Review Results

### 1. Missing auth validation (critical)
`src/routes/users.ts:45` — New GET `/users/:id` endpoint does not validate the auth token. REVIEW.md rule: "All API routes must validate auth tokens."

**Fix**: Add `validateToken(req)` middleware before the handler.

### 2. SQL injection risk (critical)
`src/db/queries.ts:23` — String interpolation in SQL query: `` `SELECT * FROM users WHERE id = ${id}` ``. REVIEW.md rule: "Database queries must use parameterized statements."

**Fix**: Use `db.query('SELECT * FROM users WHERE id = ?', [id])`.

---

Found 2 issues (2 critical). Would you like me to fix them?
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.