---
name: code-review
description: Review code changes like a senior engineer — correctness, security, performance, readability — for JavaScript/TypeScript and Python. Use whenever the user asks to review, check, audit, or "look over" code, a diff, a PR, a branch, or staged changes, or asks "is this okay?", "ada bug?", "cek kode ini", even if they don't say "review".
title: code-review
canonical_url: https://skilld.dev/gh/kiln-skills/kiln/code-review
last_updated: 2026-11-12T03:45:56.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [scripts/collect_diff.sh](https://skilld.dev/api/skills-raw/kiln-skills/kiln/code-review/scripts/collect_diff.sh).
>
> If the user asked to install this Skill, run `npx skilld install kiln-skills/kiln/code-review`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/code-review`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/kiln-skills/kiln/code-review) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/code-review`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/code-review --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/code-review --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Code Review

Goal: find the issues that actually matter, ranked by impact, with concrete fixes. Not a style lecture.

## 1. Establish scope

Figure out what to review, in this order:
1. Files/snippets the user pointed at.
2. Otherwise `git diff --staged`; if empty, `git diff`; if empty, `git diff main...HEAD` (try `master` if `main` doesn't exist).
3. If still nothing, ask.

Run `scripts/collect_diff.sh` to get the diff plus a file list in one go. Read the surrounding code of every changed hunk — bugs usually live at the boundary between new and old code, so the diff alone is not enough.

## 2. Understand intent before judging

Read the commit message / PR description / user's explanation. Ask yourself: what is this change trying to do? A review that misses the intent produces noise.

## 3. Check, in priority order

**🔴 Blocker — correctness & security**
- Logic errors, off-by-one, wrong conditions, unhandled `null`/`undefined`/`None`
- Async mistakes: missing `await`, unhandled promise rejections, `async` in `forEach`, race conditions, Python `asyncio` calls blocking the loop
- Injection: SQL string concatenation, `eval`/`exec`, shell commands built from input, `dangerouslySetInnerHTML`, Python `pickle`/`yaml.load` on untrusted data
- Secrets hard-coded, auth/permission checks missing on new endpoints
- Resource leaks: files/connections not closed (use `with` / `try…finally`)
- Mutable default arguments in Python (`def f(x=[])`)

**🟡 Should fix — robustness & performance**
- N+1 queries, work inside loops that could be hoisted, unbounded memory growth
- Error handling that swallows exceptions (`except: pass`, empty `catch {}`)
- TypeScript: `any`, unsafe `as` casts, non-null `!` hiding real nulls
- Missing tests for new branches
- React: missing/incorrect `useEffect` dependencies, keys from array index on reorderable lists

**🟢 Nice to have — maintainability**
- Naming, duplication, dead code, overly long functions
- Only mention if it materially helps; skip pure taste.

## 4. Verify, don't guess

If a project has them, run them and include results:
- JS/TS: `npx tsc --noEmit`, `npm run lint`, `npm test -- --related` (or the project's equivalents in `package.json`)
- Python: `ruff check`, `mypy`, `pytest -q` on affected tests

Don't claim something is a bug unless you can explain the input that triggers it. If unsure, say "possible issue" and why.

## 5. Output format

```
## Summary
<1–2 sentences: what changed and the overall verdict: ✅ ready to merge / ⚠️ needs fixes / ❌ don't merge>

## 🔴 Blockers
- `path/file.ts:42` — <the problem>. <why it's dangerous>.
  Fix: <short code fix>

## 🟡 Should fix
...

## 🟢 Suggestions
...

## What's already good
<1–3 specific points, not filler>
```

Write the report in the user's language (for example, Indonesian if they wrote in Indonesian); translate the headings too. Omit empty sections. Max ~10 findings; if more, keep the most important and say how many minor ones were left out.

Offer to apply the fixes — don't edit files unless the user asks.
