little cups of claude

tips and techniques for Claude and Claude Code

#23: Local Code Reviews 🔍

Today we'll check out /code-review, a bundled skill that has Claude Code look over our changes for bugs before anyone else sees them.

We type it in the same session we're working in. Claude reviews the changes on our branch, hunts for correctness bugs, and reports back right in the conversation. Let's take a look.

Running A Review

The simplest version takes no arguments:

/code-review

That covers our branch's commits ahead of its upstream, plus any uncommitted changes. If the branch has no upstream, Claude compares against main. /review is an alias for the same thing.

The review runs as a background subagent with its own context window, so it doesn't fill up our conversation, and we can keep working while it runs. The findings show up when it's done.

Pointing It Somewhere Else

Anything after the command becomes the review target:

/code-review 1234
/code-review main...my-feature
/code-review HEAD~15..HEAD
/code-review abc1234^..abc1234
/code-review src/auth

That's a pull request by number, one branch against another, our last 15 commits, a single commit, and a directory.

Fixing And Commenting

Two flags turn the report into action:

/code-review --fix
/code-review --comment 1234

--fix asks Claude to apply the findings to our working tree after the review. --comment posts them on a GitHub pull request as inline comments (or on a GitLab merge request as a single note). Either way, edits still go through our permission mode.

Trading Coverage For Confidence

We can pass an effort level first:

/code-review low
/code-review high src/billing

At low, the review only reports the findings it's most confident in, so there are fewer false positives. From medium up through max, it widens coverage. Whatever level we type gets remembered for later reviews, even in another session, until we type a different one. Neat!

Teaching It Our Rules

/code-review follows our CLAUDE.md, so project rules go there:

## Review rules

- Every new API route needs a rate limit entry in limits.ts
- Money is stored in integer cents, never floats

There's no SKILL.md on disk to edit since it's built in. If we want something completely different, a project or personal skill named code-review replaces the bundled one, and /review keeps running the original.

To keep Claude from starting reviews on its own while still letting us type it:

{
  "skillOverrides": {
    "code-review": "user-invocable-only"
  }
}

Watch Out

A background review applies its --fix edits outside our session's checkpoints. After one, /rewind won't undo the review's changes to files we hadn't already edited, so git is the way to back those out.

For a deeper pass, /code-review ultra sends the review to the cloud. That one needs a claude.ai account, so on providers like Amazon Bedrock it falls back to a local review.

More info about local code review can be found at the Claude Code docs.

Share

Share on Threads

Similar Cups