$ recombobulate _
home / tips / use-claude-for-pre-commit-code-reviews
use-claude-for-pre-commit-code-reviews

You don't need a teammate to review your code before committing — Claude Code can do a first pass right in the terminal.

git diff HEAD | claude -p "Review this diff for bugs, security issues, 
and anything that violates RESTful conventions. Be concise."

Pipe your staged diff directly to Claude using the -p flag for a quick, focused review. Tailor the criteria to your project — ask it to check for N+1 queries, missing error handling, hardcoded credentials, or naming convention violations.

You can take this further by wiring it into a git hook so it runs automatically before every commit:

# .git/hooks/pre-commit
#!/bin/sh
git diff --cached | claude -p \
  "Review this diff for obvious bugs or missing input validation. 
  If you find a critical issue, print it and exit with code 1." \
  || exit 1

This gives you a free automated reviewer on every commit. Claude is especially good at catching the things you stop seeing after staring at the same code for an hour — missing null checks, copy-paste errors, and forgotten TODOs.

# Or review just your staged changes
git diff --cached | claude -p "Check for security issues only."

A 10-second Claude review before every commit catches more bugs than you'd expect.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Scan Pending Changes for Security Issues with /security-review

The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.

bagwaa @bagwaa · 1 hour ago
0
Run Setup Scripts on Every Session with the SessionStart Hook

The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.

bagwaa @bagwaa · 1 hour ago
0
Write Property-Based Tests with fast-check and Claude

Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.

bagwaa @bagwaa · 2 hours ago