Claude Code 리뷰 스킬: 병합 전 diff를 확인하는 code-review
Dmitriy Solodukha, Caprock 개발자 · 게시일
Claude Code와 Codex에서 테스트
어떤 에이전트에서든 작동하는 Claude Code 리뷰 스킬입니다. 버그를 먼저, 이어 테스트, 보안, 범위를 확인하며, 각 항목에 file:line과 수정안을 제시하고 보고 전에 검증합니다.
code-review는 Codex, OpenCode, Cursor에서도 작동하는 Claude Code 리뷰 스킬입니다. 커밋하지 않은 diff나 기준 브랜치 대비 현재 브랜치를 검토하고, 동작 오류를 먼저 보고한 뒤 누락된 테스트, 보안 문제, 범위를 벗어난 변경을 보고합니다. 모든 발견 사항에는 파일과 줄 번호, 잘못된 이유, 구체적인 수정 방법이 포함됩니다. 보고서에 넣기 전에 호출자 추적, 재현, 테스트 실행 등을 통해 코드로 입증합니다. 요청하지 않으면 사소한 스타일 문제는 지적하지 않습니다.
code-review 스킬 설치
에이전트마다 명령어 하나로 설치합니다. 스킬은 SKILL.md 파일 하나이며, 설치 시 실행되는 것은 없습니다.
스킬 아홉 가지 전체를 플러그인으로 설치합니다. Claude Code 안에서 다음을 입력합니다:
이 스킬만 설치하려면 터미널에서 프로젝트 폴더로 이동한 뒤 다음을 실행합니다:
추가 옵션: -g 모든 프로젝트에 설치하려면 앞의 옵션을 추가합니다.
터미널에서 프로젝트 폴더로 이동한 뒤 다음을 실행합니다:
추가 옵션: -g 모든 프로젝트에 설치하려면 앞의 옵션을 추가합니다.
터미널에서 프로젝트 폴더로 이동한 뒤 다음을 실행합니다:
추가 옵션: -g 모든 프로젝트에 설치하려면 앞의 옵션을 추가합니다. 아직 OpenCode에서 테스트하지 않았습니다. 이 스킬은 개방형 형식의 일반 지침이지만, OpenCode에서 실행해 검증한 적은 없습니다.
터미널에서 프로젝트 폴더로 이동한 뒤 다음을 실행합니다:
추가 옵션: -g 모든 프로젝트에 설치하려면 앞의 옵션을 추가합니다. 아직 Cursor에서 테스트하지 않았습니다. 이 스킬은 개방형 형식의 일반 지침이지만, Cursor에서 실행해 검증한 적은 없습니다.
code-review 스킬을 사용하는 프롬프트
요청이 스킬 설명과 일치하면 에이전트가 해당 스킬을 선택합니다. 이름을 명시하면 확실하게 선택할 수 있습니다. 프롬프트를 클릭하면 복사됩니다.
code-review 스킬의 확인 항목
- diff 선택: 커밋하지 않은 작업을 검토하고, 없으면 브랜치를 기준 브랜치(
origin/HEAD에서 확인하며, 없으면main또는master)와 비교합니다. 어느 쪽인지 한 줄로 명시합니다. - 의도 파악은 요청, 커밋 메시지, 프로젝트의 에이전트 지침에서 파악합니다. 프로젝트 규칙 위반은 발견 사항에 해당합니다.
- diff뿐 아니라 코드도 확인: 해당 함수, 이를 호출하는 코드, 변경된 이름이 사용되는 모든 곳.
- 순서에 따른 확인: 정확성, 테스트, 보안, 작업 범위 확대.
- 모든 발견 사항 검증 또는 확인에 필요한 내용과 함께 미검증으로 표시합니다. 불확실한 발견 사항이 많은 것보다 확실한 발견 사항이 적은 편이 낫습니다.
- CI 추가: Caprock의
ci_status, 없으면gh pr checks, 둘 다 없으면 "CI: not available".
실행한 내용과 에이전트의 수행 결과
각 스킬은 2026년 11월 29일에 전용으로 만든 임시 저장소에서 프로젝트 스킬로 설치하여 실행했습니다. 작은 Python 저장소에서 master와 비교하는 feat/discount 브랜치를 사용했습니다. 마지막 두 글자를 파싱하여 os.system에 전달하는 할인 코드(셸 인젝션), 충돌을 일으키는 잘못된 코드, 빈 리스트에서 영으로 나누는 관련 없는 average()가 있었으며, 이 중 어느 것에도 테스트가 없었습니다.
Claude Code (claude -p --model sonnet)
Review the changes on this branch before I merge them.
code-review 스킬을 호출하고(Claude Code에 내장된 동명의 스킬보다 프로젝트 스킬이 우선 적용됨) 일곱 가지 문제를 보고했습니다. 셸 주입, 검증되지 않은 코드, 한 자리 및 세 자리 파싱, 호출마다 출력되는 로그 한 줄, average([]) 충돌, 누락된 테스트, 범위를 벗어난 average()입니다. 각 문제를 검증했습니다. 다섯 가지는 재현했고(주입으로 임시 폴더에 파일이 생성됨), 누락된 테스트와 범위 문제는 코드와 이력을 읽어 확인했습니다. 판정은 병합 전 수정이었으며 CI와 Not checked 줄을 포함했습니다.
Codex (0.163.0, codex exec)
Review the changes on this branch before I merge them.
스킬을 읽고 형식에 맞춰 검증된 발견 사항 세 가지(인젝션, 파싱, 테스트)를 보고했습니다. average()를 놓쳤고 CI 항목을 빠뜨렸습니다. 이 실행 후 스킬을 수정해 CI 항목을 필수로 지정했으며, Codex는 다시 실행하지 않았습니다. 보고서의 시작 부분입니다(링크는 일반 텍스트로 표시):
Reviewed: `feat/discount` vs `master`, 1 commit, 1 changed file. Verdict: **fix before merge** 1. [security] cart.py:9: Discount codes can execute arbitrary shell commands. Why: `SAVE10; echo injected > marker; #10` passes percentage parsing and executes the injected command. Fix: Replace `os.system` with Python file I/O or logging. Verified: Reproduced in a temporary directory; the injected command created a marker file.
테스트한 에이전트
- Claude Code:
.claude/skills/에 프로젝트 스킬로 설치한 상태에서 2026년 11월 29일에claude -p --model sonnet으로 테스트했습니다. - Codex: 2026년 11월 29일에 Codex 0.163.0(
codex exec)로 테스트했으며, 스킬은.agents/skills/에 설치했습니다. - OpenCode와 Cursor: 테스트하지 않았습니다. 스킬은 공개 Agent Skills 형식의 일반 지침이지만, 어느 쪽에서도 실행하여 확인하지 않았습니다.
한도
- Claude Code에는 같은 이름의 내장
/code-review가 있습니다. 테스트에서는 프로젝트 스킬이 사용됐으며, 플러그인으로 설치했을 때 어느 쪽이 우선하는지는 테스트하지 않았습니다. - 각각 한 번 실행했을 때 Codex는 3건, Claude Code는 7건의 문제를 보고했습니다. Codex는
average()충돌과 범위 관련 문제를 놓쳤습니다. - 매우 큰 diff는 위험도가 가장 높은 파일부터 리뷰하고, 나머지는 Not checked 아래에 나열합니다.
- 테스트 저장소에 원격 저장소가 없어 Caprock의
ci_status를 통한 CI 항목은 테스트하지 않았습니다.
Caprock을 사용할 때와 사용하지 않을 때
Caprock MCP 서버가 연결되어 있으면 스킬은 ci_status를 호출하여 최신 워크플로 실행과 열려 있는 PR의 검사 결과를 확인하고, 실패한 작업 이름을 표시합니다. 연결되어 있지 않으면 GitHub CLI에 로그인한 경우 gh pr checks를 사용하고, 그렇지 않으면 "CI: not available"을 기록합니다. Caprock은 컴퓨터의 모든 코딩 에이전트 세션을 기록하는 무료 오픈 소스 앱입니다.
SKILL.md 전문
dspv/skills의 리비전 dfce799에 있는 파일 그대로입니다. 수동으로 설치하려면 프로젝트 안에 Claude Code용은 .claude/skills/code-review/SKILL.md, Codex용은 .agents/skills/code-review/SKILL.md로 저장합니다.
--- name: code-review description: > Review the changes a coding agent made before they are committed or merged: the uncommitted diff, or the branch's diff against its base branch. Finds correctness bugs first, then missing or broken tests, security problems and scope creep. Every finding has file:line, why it is wrong and a concrete fix, and is checked against the code before it is reported. No style nitpicks unless asked. Use when the user says "review my changes", "review this diff", "review the branch before I merge", "code review", "check what the agent changed", or is looking for a claude code review skill that works in any agent. license: Apache-2.0 --- # Code review Review a diff the way a careful senior engineer would before approving it: find what will break, prove it from the code, say how to fix it. Do not edit files unless the user asks for fixes. ## 1. Pick the diff Use what the user named (a branch, a commit range, a file). Otherwise, in this order: 1. Uncommitted work: `git status --short`. If anything is staged, unstaged or untracked, review `git diff HEAD` plus the untracked files (read them whole; they are new code). 2. Otherwise the branch against its base. Find the base: the user's word, else `git symbolic-ref refs/remotes/origin/HEAD` (strip `refs/remotes/`), else `main` or `master`, whichever exists. Then review `git diff $(git merge-base <base> HEAD)...HEAD` and read `git log --oneline <base>..HEAD` for the stated intent. 3. If both are empty, say there is nothing to review and stop. State the diff you reviewed in one line (for example `uncommitted, 4 files` or `feat/x vs master, 3 commits, 6 files`). ## 2. Learn the intent Before judging, know what the change is meant to do: the user's request, commit messages, a PR description, a linked issue, the project's agent instructions (`CLAUDE.md`, `AGENTS.md` or the like). Those instructions are rules too: a change that breaks one is a finding. ## 3. Read the code, not only the diff For each changed hunk, open the surrounding function and its callers. A diff hides the line that makes it wrong: the caller that passes `None`, the other branch of the `if`, the second place that writes the same field. Use the project's search (`git grep`, `rg`) to find every use of a changed name, signature, return value or config key. ## 4. Look for problems, in this order 1. **Correctness.** Logic errors, wrong conditions, off-by-one, unhandled `null`/empty/error cases, wrong types or units, race conditions, resource leaks, broken callers of a changed signature, behavior that no longer matches the intent, data loss or migrations that cannot be undone. 2. **Tests.** New behavior with no test, a test that cannot fail (asserts nothing, mocks the thing under test), a test changed to pass instead of the code being fixed, deleted or skipped tests. If the project has a fast test command, run it and report the result. 3. **Security.** Injection (SQL, shell, path, HTML), secrets or tokens in code or logs, missing authorization checks, unsafe deserialization, user input reaching the file system or a network call unchecked. 4. **Scope creep.** Changes the task did not ask for: unrelated refactors, renamed files, reformatting, new dependencies, debug prints, commented-out code, edits to generated or lock files. Name them so the user can drop them; they are findings only when they risk something or hide the real change. Skip style, naming and formatting unless the user asked for them or a project rule requires it. ## 5. Verify every finding Before a finding goes in the report, prove it: - Re-read the exact lines and the code they depend on. Confirm the input that breaks it can actually reach it (trace the caller, the type, the validation upstream). - Where it is cheap, show it: run the failing test, a one-line script, or the project's check. - If you cannot prove it, either drop it or keep it marked **unverified** with what would confirm it. Never present a guess as a bug. Drop a finding that the code already handles elsewhere. Fewer real findings beat many maybe ones. ## 6. CI results (optional) If the branch has a pull request or CI runs, include the result: - When the Caprock MCP tools are available (server `caprock`), call `ci_status` (optional argument `repo`: a directory inside the repository). It returns the newest run of each workflow on the default branch and the checks of the open pull request, with failing jobs named. Caprock (<https://caprock.dev>, free, open source, runs locally) provides that tool. - Otherwise, if the GitHub CLI is installed and signed in, `gh pr checks` shows the checks of the current branch's pull request. - If neither is available, write `CI: not available` in the report and move on. A failing check related to the diff is a finding; read its log before blaming the diff. ## 7. Report Use this format, most severe first. Nothing else before it except the one-line diff summary. ``` Reviewed: <what diff> Verdict: <ready to merge | fix before merge | needs discussion> 1. [bug] path/to/file.py:42: <what is wrong, one sentence> Why: <the input or path that triggers it, and what happens> Fix: <the concrete change: code or exact steps> Verified: <how: test run, traced caller at file:line, reproduced> | unverified: <what would confirm> 2. [test] ... 3. [security] ... 4. [scope] ... CI: <checks passed | failing: job names | not available> Not checked: <anything you could not read or run> ``` Severity tags: `bug`, `test`, `security`, `scope`, and `rule` for a broken project instruction. If there are no findings, say so in one line and give the verdict; do not invent findings to fill the report. ## Stop conditions - Stop after the report. Apply fixes only if the user asks; then re-run the tests you ran. - If the diff is too large to read whole, say so, review the riskiest files first (logic over config, config over docs), and list the files you did not review under `Not checked`.
code-review 스킬 관련 질문
- 다른 에이전트에서도 작동하는 Claude Code 리뷰 스킬이 있나요?
- code-review가 그중 하나입니다. Claude Code, Codex, OpenCode, Cursor가 읽을 수 있는 일반 SKILL.md입니다. 2026년 11월 29일에 Claude Code와 Codex 0.163.0에서 테스트했습니다.
- 이 코드 리뷰 스킬은 Claude Code의 내장 리뷰와 어떻게 다른가요?
- 어떤 에이전트에서도 같은 방식으로 작동하고, 하나의 고정된 형식으로 보고하며, 각 발견 사항을 보고하기 전에 코드로 입증합니다. Claude Code에 내장된 /code-review 명령과 이름이 같습니다. 테스트에서는 이 스킬을 프로젝트 스킬로 설치해 사용했습니다. 플러그인에서는 `/caprock-skills:code-review`로 호출합니다(이 형식으로는 실행하지 않았습니다).
- code-review 스킬이 코드를 변경하나요?
- 아니요. 보고 후 중단합니다. 요청할 때만 수정 사항을 적용하고, 앞서 실행한 테스트를 다시 실행합니다.
- 스타일에 대해서도 의견을 제시하나요?
- 요청하거나 프로젝트 규칙에서 요구할 때만 확인합니다. 기본적으로 스타일, 이름 짓기, 서식은 건너뜁니다.