Skill de revisión de Claude Code: code-review comprueba el diff antes de que hagas merge
Dmitriy Solodukha, desarrollador de Caprock · Publicado el
Probado el en Claude Code y Codex
Skill de revisión de Claude Code para todo agente: errores, pruebas, seguridad y alcance, con file:line y corrección, verificados antes de informar.
La skill code-review es una skill de revisión de Claude Code que también funciona en Codex, OpenCode y Cursor: revisa el diff sin commit o la rama con respecto a su base, e informa primero de errores de funcionamiento, luego de pruebas que faltan, problemas de seguridad y ampliaciones del alcance. Cada hallazgo incluye un archivo y una línea, por qué está mal y una solución concreta, y se demuestra a partir del código (el rastreo de una llamada, una reproducción, la ejecución de una prueba) antes de incluirlo en el informe. No hace observaciones menores de estilo a menos que lo pidas.
Instala la skill code-review
Un comando por agente. La skill es un único SKILL.md; no se ejecuta nada al instalarla.
Las nueve skills como plugin. Escribe esto dentro de Claude Code:
O solo esta skill, desde la carpeta de tu proyecto en una terminal:
Añade -g para instalarla en todos los proyectos.
Desde la carpeta de tu proyecto, en una terminal:
Añade -g para instalarla en todos los proyectos.
Desde la carpeta de tu proyecto, en una terminal:
Añade -g para instalarla en todos los proyectos. Aún no se ha probado en OpenCode: la skill contiene instrucciones sencillas en el formato abierto, pero ninguna ejecución en OpenCode la ha verificado.
Desde la carpeta de tu proyecto, en una terminal:
Añade -g para instalarla en todos los proyectos. Aún no se ha probado en Cursor: la skill contiene instrucciones sencillas en el formato abierto, pero ninguna ejecución en Cursor la ha verificado.
Prompts que usan la skill code-review
El agente elige la skill cuando tus palabras coinciden con su descripción; nombrarla lo asegura. Haz clic en un prompt para copiarlo.
Qué comprueba la skill code-review
- Selecciona el diff: el trabajo sin commit o, si no lo hay, la rama comparada con su base (de
origin/HEADo, en su defecto,mainomaster), e indica cuál en una línea. - Identifica la intención a partir de tu solicitud, los mensajes de commit y las instrucciones del proyecto para agentes; incumplir una regla del proyecto es un hallazgo.
- Lee el código, no solo el diff: la función que lo contiene, las funciones que la llaman y cada uso de un nombre modificado.
- Busca en orden: corrección, pruebas, seguridad, ampliación del alcance.
- Verifica cada hallazgo, o lo marca como no verificado e indica qué lo confirmaría. Es mejor tener menos hallazgos reales que muchos posibles.
- Añade CI:
ci_statusde Caprock o, en su defecto,gh pr checkso, si tampoco está disponible, “CI: not available”.
Qué ejecutamos y qué hicieron los agentes
Cada skill se ejecutó el 29 de noviembre de 2026 en un repositorio desechable creado para ella, con la skill instalada como skill del proyecto. Una rama feat/discount frente a master en un pequeño repositorio de Python: un código de descuento extraído de sus dos últimos caracteres y pasado a os.system (inyección de shell), un código no válido que provoca un fallo, un average() sin relación que divide entre cero con una lista vacía, y ninguna prueba para todo ello.
Claude Code (claude -p --model sonnet)
Review the changes on this branch before I merge them.
Invocó la skill code-review (se usó la skill del proyecto en lugar de la skill integrada de Claude Code con el mismo nombre) e informó de siete hallazgos: la inyección de shell, el código sin validar, el análisis de uno y tres dígitos, una línea de registro en cada llamada, el fallo de average([]), la falta de pruebas y average() como ampliación del alcance. Se verificó cada uno: cinco reproduciéndolos (la inyección creó un archivo en una carpeta temporal), y la falta de pruebas y la ampliación del alcance leyendo el código y su historial. Veredicto: corregir antes de hacer merge, con las líneas CI y Not checked.
Codex (0.163.0, codex exec)
Review the changes on this branch before I merge them.
Leyó la skill y siguió su formato con tres hallazgos verificados (inyección, análisis, pruebas). Pasó por alto average() y omitió la línea de CI; después de esta ejecución se modificó la skill para que la línea de CI fuera obligatoria, y no se volvió a ejecutar Codex. El inicio de su informe (enlaces mostrados como texto sin formato):
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.
Agentes en los que se probó
- Claude Code: probado el 29 de noviembre de 2026 con
claude -p --model sonnet, con la skill instalada como skill de proyecto en.claude/skills/. - Codex: probado el 29 de noviembre de 2026 con Codex 0.163.0 (
codex exec), con la skill en.agents/skills/. - OpenCode y Cursor: sin probar. La skill consiste en instrucciones en el formato abierto Agent Skills, pero ninguna ejecución en ninguno de los dos la ha verificado.
Límites
- Claude Code tiene un
/code-reviewintegrado con el mismo nombre. En la prueba se usó la skill de proyecto; no se probó cuál tiene prioridad con la instalación del plugin. - Codex informó de 3 hallazgos frente a los 7 de Claude Code en una ejecución de cada uno; no detectó el fallo de
average()ni el hallazgo sobre el alcance. - Un diff muy grande se revisa empezando por los archivos con más riesgo, y el resto se enumera en Not checked.
- No se probó la línea de CI mediante
ci_statusde Caprock: el repositorio de prueba no tenía un remoto.
Con Caprock y sin él
Cuando el servidor MCP de Caprock está conectado, la skill llama a ci_status para obtener las ejecuciones más recientes del flujo de trabajo y las comprobaciones del pull request abierto, e identifica los trabajos que fallan. Sin él, usa gh pr checks si se ha iniciado sesión en la CLI de GitHub, o escribe "CI: not available". Caprock es la app gratis y de código abierto que registra todas las sesiones de agentes de programación en tu computadora.
El SKILL.md completo
El archivo tal como está en dspv/skills en la revisión dfce799. Para instalarlo manualmente, guárdalo como .claude/skills/code-review/SKILL.md para Claude Code o .agents/skills/code-review/SKILL.md para Codex en tu proyecto.
--- 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`.
Preguntas sobre la skill code-review
- ¿Hay alguna skill de revisión de Claude Code que funcione en otros agentes?
- code-review es una de ellas: un SKILL.md sencillo que Claude Code, Codex, OpenCode y Cursor pueden leer. Se probó en Claude Code y Codex 0.163.0 el 29 de noviembre de 2026.
- ¿En qué se diferencia esta skill de revisión de código de la revisión integrada de Claude Code?
- Funciona igual en cualquier agente, presenta los informes en un formato fijo y demuestra cada hallazgo a partir del código antes de incluirlo. El comando integrado /code-review de Claude Code tiene el mismo nombre. En la prueba se usó esta skill instalada como skill del proyecto; desde el plugin, invócala con `/caprock-skills:code-review` (esa forma no se ejecutó).
- ¿Cambia mi código la skill code-review?
- No. Se detiene después del informe. Solo aplica correcciones cuando lo pides y luego vuelve a ejecutar las pruebas que ejecutó.
- ¿Hace comentarios sobre el estilo?
- Solo si lo pides o una regla del proyecto lo exige. Por defecto, se omiten el estilo, los nombres y el formato.