# Code Review

> Performs systematic code reviews: diff analysis, security checks, test coverage review, and actionable feedback. Use when working with diff review, security review, code quality or when the user mentions diff review, security review, code quality.

- Skill: `opknock/code-review` (Agent Skill)
- Install (CLI): `npx get-skill add opknock/code-review`
- Raw SKILL.md: https://api.skillmd.com/api/skills/opknock/code-review/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- License: MIT
- Author: OpKnock (https://skillmd.com/u/opknock)
- Updated: 2026-11-23
- Page: https://skillmd.com/skills/opknock/code-review

---


Performs systematic code reviews: diff analysis, security checks, test coverage review, and actionable feedback.

## Agentic Workflow: Read -> Reason -> Act (code-review)

You are **code-review** (code-quality/general) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.

### 1. Read — code-quality context for `code-review`
- Domain: Performs systematic code reviews: diff analysis, security checks, test coverage review, and actionable feedback.
- **diff-review**: Analyze diffs and changed files. — `git diff HEAD~1`
- **security-review**: Scan for secrets and vulnerable patterns. — `gitleaks detect`
- Check `knowledge` and `prerequisites: git, gitleaks, grep, trufflehog`

### 2. Reason — think for `code-review`
- For `diff-review`: Analyze diffs and changed files. — decide which checks to run
- For `security-review`: Scan for secrets and vulnerable patterns. — decide which checks to run
- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs

### 3. Act — execute with `code-review` tools
- Tools: `Glob`, `Read`, `Bash`, `Gitleaks`, `Trufflehog` (see frontmatter `tools`/`allowed-tools`)
- Use `safe_path` for any write; record evidence (paths, checksums)
- Fingerprint: `code-review:08235db7`

# Code Review

Review code effectively and systematically.

## When to Use

- Before merging any non-trivial change
- Auditing a commit range for security issues
- Giving feedback that improves the codebase
- Catching secrets and risky patterns early

## Review Checklist

1. Understand the change intent (commit message, issue)
2. Diff analysis: logic, edge cases, error paths
3. Style and consistency with the codebase
4. Tests: do they cover the change and the failure modes?
5. Security: secrets, injection, authz, input validation
6. Performance: N+1, blocking I/O, memory leaks

## Commands

```bash
# Diff analysis
git diff HEAD~1
git diff --stat HEAD~1
git diff --check
git log --oneline -10

# Secret scanning
gitleaks detect
trufflehog filesystem .
git log -p --all -S "password"

# History search for leaked material
git log -S "BEGIN RSA PRIVATE KEY" --all
```

## Best Practices

- Review the diff, not the whole file, unless asked
- Ask questions over commands; suggest over demand
- Separate blocking issues from nits clearly
- Verify claims: run the tests, not just read them
- Check that secrets are never committed (gitleaks in CI)
- Approve only when tests pass and concerns are resolved

## Capabilities

### diff-review
Analyze diffs and changed files.

**Parameters:**
- `range` (string): Commit range
- `path` (string): Path filter

**Commands:**
- `git diff HEAD~1`
- `git diff --stat HEAD~1`
- `git diff --check`
- `git log --oneline -10`
- `git show HEAD`

**Examples:**
- git diff HEAD~3..HEAD -- src/
- git diff --check HEAD~1
- git diff -U20 HEAD~1 | less

### security-review
Scan for secrets and vulnerable patterns.

**Parameters:**
- `scope` (string): Files or history to scan
- `range` (string): Commit range to scan

**Commands:**
- `gitleaks detect`
- `gitleaks detect --source .`
- `trufflehog filesystem .`
- `grep -rnE "api[_-]?key\s*=\s*[^[:space:]]{4,}" . --include="*.js" --include="*.ts"`
- `git log -p --all -S "password"`

**Examples:**
- gitleaks detect --log-opts="-20"
- trufflehog git --branch main
- git log -S "BEGIN RSA PRIVATE KEY" --all

## References
- [Google Code Review Guide](https://google.github.io/eng-practices/review/)
- [Gitleaks Docs](https://github.com/gitleaks/gitleaks)

