code-review

code-review is a command for coding agents from halflength-ampleness75/claude-code-recipes. It costs 13 tokens per session (652 once invoked), scanned A, original, MIT.

A command that examines the changes currently prepared for a Git commit, or the uncommitted changes if none are prepared. It reports possible bugs, security problems, performance issues, and style violations.

In plain words
What is it for?
Use it to review staged Git changes file by file and receive findings grouped by issue type. If there are no changes, it reports that there is nothing to review.
Why use it?
It gives a structured review before code is committed, helping catch mistakes such as unsafe input handling, missing cleanup, incorrect conditions, or exposed secrets.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/halflength-ampleness75/claude-code-recipes/code-review
Clone the repo
git clone --depth 1 https://github.com/halflength-ampleness75/claude-code-recipes

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for code-review

README.md
[![agentmods](https://agentmods.dev/badge/commands/halflength-ampleness75/claude-code-recipes/code-review.svg)](https://agentmods.dev/commands/halflength-ampleness75/claude-code-recipes/code-review)
Your own site
<a href="https://agentmods.dev/commands/halflength-ampleness75/claude-code-recipes/code-review"><img src="https://agentmods.dev/badge/commands/halflength-ampleness75/claude-code-recipes/code-review.svg" alt="Measured on agentmods" height="20"></a>
Per session 13 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 652 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00013 $0.00652
Opus 5 $0.00006 $0.00326
Sonnet 5 $0.00003 $0.00130
Haiku 4.5 $0.00001 $0.00065

Measured 3d ago against content hash e8a9d9b6df67, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

code-review scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/code-review.md · 88 lines

How it starts

The opening of the file, as written. The whole thing — 88 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are a senior code reviewer. Review the currently staged git changes and produce a structured report.

Step 1 — Gather the Diff

Run git diff --cached to get the staged changes. If nothing is staged, fall back to git diff for unstaged changes. If both are empty, inform the user there is nothing to review and stop.

Also run git diff --cached --stat to get a file-level summary of what changed.

Step 2 — Analyze Each Changed File

For every file in the diff, check for the following categories of issues. Read the full file when surrounding context is needed to understand a change.

Bug Risk

  • Off-by-one errors, null/undefined dereferences, race conditions
  • Incorrect logic (inverted conditions, wrong operator, missing break/return)
  • Resource leaks (unclosed handles, missing cleanup)
  • Type mismatches or unsafe casts

Security

  • SQL injection, command injection, path traversal
  • Hardcoded secrets, API keys, or credentials
  • Missing input validation or sanitization
  • Insecure use of cryptography or random number generation
  • Exposed stack traces or verbose error messages in production paths

Performance

  • O(n^2) or worse algorithms where O(n) or O(n log n) is possible
  • Unnecessary allocations inside hot loops
  • Missing pagination or unbounded queries
  • Synchronous I/O blocking an async context

Code Quality & Style

  • Dead code, unused imports, unreachable branches
  • Functions longer than 40 lines that should be decomposed
  • Inconsistent naming conventions
  • Missing or misleading comments
  • Duplicated logic that should be extracted

Error Handling

  • Swallowed exceptions (empty catch blocks)
  • Missing error propagation
  • Generic catches that mask specific failures
  • Missing validation at public API boundaries

Test Coverage

  • New logic paths that lack corresponding tests
  • Modified behavior without updated tests

Step 3 — Produce the Report

Output a Markdown report in this exact structure:

## Code Review Report

**Files reviewed:** (count)
**Issues found:** (count)

### Critical (must fix before merge)
- [ ] **[FILE:LINE]** [Category] — Description of the issue and suggested fix

### Warning (should fix)
- [ ] **[FILE:LINE]** [Category] — Description and suggestion

### Nit (optional improvement)
- [ ] **[FILE:LINE]** [Category] — Description and suggestion

### Positive Notes
- Anything done well that is worth calling out

### Summary
One-paragraph overall assessment: is this diff safe to merge, or does it need changes?

Read the full file on GitHub · 88 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 88 lines · 13 tokens per session scan A e8a9d9b6df67

Subscribe to this mod's changes

code-review is a command published in the GitHub repository halflength-ampleness75/claude-code-recipes (2 stars, last pushed 4d ago), licensed MIT. It adds 13 tokens to every session and 652 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.