code-review
Use when explicitly asked to review a git branch, Pull Request (PR), Merge Request (MR), or perform a pre-merge review. Do not use for inline code critiques.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when explicitly asked to review a git branch, Pull Request (PR), Merge Request (MR), or perform a pre-merge review. Do not use for inline code critiques.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | code-review |
| description | Use when explicitly asked to review a git branch, Pull Request (PR), Merge Request (MR), or perform a pre-merge review. Do not use for inline code critiques. |
| license | MIT |
Perform comprehensive code reviews of a branch against the base branch, providing actionable feedback on code quality, security, performance, and best practices.
Activate this skill when:
Two Review Modes:
Current Branch Review (default when no branch specified)
Other Branch Review (when branch name specified)
If a branch name is provided (e.g., "review feature/payment"):
git fetch originIf no branch name is provided (e.g., just "review"):
git diff --cachedgit diffWhen reviewing a branch that isn't the current branch, use a git worktree to avoid disturbing the current working state:
Create a worktree directory at <repo-root>/.worktrees/<branch-name>:
git worktree add .worktrees/<branch-name> origin/<branch-name>
Perform all review operations within the worktree directory
After the review is complete, remove the worktree:
git worktree remove .worktrees/<branch-name>
Important: Always use the worktree path when reading files or running git commands during the review. This ensures the user's current work remains untouched.
When setting up a worktree, install dependencies if you need to run checks (tests, type checking, linting):
Detect package manager: Check for pnpm-lock.yaml, Cargo.lock, go.mod
Install dependencies:
cd <worktree-path> && pnpm install
Run checks (optional, if needed for thorough review)
When to install dependencies:
When to skip dependency installation:
If the worktree already exists:
git worktree remove .worktrees/<branch-name> --force 2>/dev/null || true
git worktree add .worktrees/<branch-name> origin/<branch-name>
If no matching branch is found:
Always clean up worktrees:
git worktree list to verify cleanup was successfulThe .worktrees directory should be added to .gitignore if not already present. Check and suggest adding it if missing:
# Code review worktrees
.worktrees/
First, gather essential information about the branch to review:
DEFAULT_BRANCH=""
for branch in main master; do
if git merge-base --is-ancestor origin/$branch HEAD 2>/dev/null; then
DEFAULT_BRANCH=$branch
break
fi
done
if [ -z "$DEFAULT_BRANCH" ]; then
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
fi
if [ -z "$DEFAULT_BRANCH" ]; then
if git show-ref --verify --quiet refs/remotes/origin/main; then
DEFAULT_BRANCH="main"
elif git show-ref --verify --quiet refs/remotes/origin/master; then
DEFAULT_BRANCH="master"
fi
fi
[ -z "$DEFAULT_BRANCH" ] && DEFAULT_BRANCH="main"
You MUST use git merge-base to find the common ancestor. This ensures you only review commits that were made in THIS branch, not commits from other branches that happened to be merged into main.
MERGE_BASE=$(git merge-base origin/$DEFAULT_BRANCH HEAD)
git log --oneline $MERGE_BASE..HEAD
git diff --name-status $MERGE_BASE..HEAD
git diff $MERGE_BASE..HEAD
Why this matters:
git diff origin/main..HEAD shows ALL differences between main and HEAD, which includes changes from OTHER branches that were merged into main after this branch was createdgit diff $(git merge-base origin/main HEAD)..HEAD shows ONLY the changes introduced in THIS branchExample:
main: A---B---C---D---E (where D and E are from other merged branches)
\
feature: X---Y---Z (this is what we want to review)
# WRONG: git diff origin/main..HEAD
# Shows: differences from E to Z (includes D and E changes we don't care about)
# CORRECT: git diff $(git merge-base origin/main HEAD)..HEAD
# Shows: only X, Y, Z changes (merge-base is B)
Always use the merge-base approach for:
git log - to list commitsgit diff - to see changesgit diff --stat - for change statisticsgit diff --name-status - for file listgit diff --cached --name-status
git diff --cached --stat
git diff --name-status
git diff --stat
Do not review lock files. Filter them out:
pnpm-lock.yamlpackage-lock.jsonyarn.lockbun.lockbgo.sumCargo.lockpoetry.lockPipfile.lockpdm.lockGemfile.lockcomposer.lockdeno.lockflake.lockIf diff is very large, ask for confirmation before proceeding:
Current branch: Always run checks. Worktree: Ask the user before running checks (may require installing dependencies).
Auto-detect project type and run appropriate checks. Use gtimeout or timeout with a 5-minute limit per check. Failures are reported but do not stop the review.
# Detect in order of specificity
if [ -f "nx.json" ]; then
PROJECT_TYPE="nx"
elif [ -f "Cargo.toml" ]; then
PROJECT_TYPE="rust"
elif [ -f "go.mod" ]; then
PROJECT_TYPE="go"
elif [ -f "package.json" ]; then
PROJECT_TYPE="node"
else
PROJECT_TYPE="unknown"
fi
# Nx (Node.js/TypeScript monorepo)
pnpm nx run-many --target=lint,test --target=test --parallel=2
# Rust
cargo clippy --all-targets --all-features -- -D warnings
cargo check --all
cargo fmt --check --all
cargo test
# Go
go vet ./...
go test -v ./...
# Node.js (pnpm)
pnpm lint
pnpm test
# Node.js (npm/yarn fallback)
npm run lint 2>/dev/null || yarn lint 2>/dev/null
npm test 2>/dev/null || yarn test 2>/dev/null
Capture output and include results in the review report.
Conduct a thorough review of only the changes introduced in this branch (using merge-base as described above).
git diff $(git merge-base origin/$DEFAULT_BRANCH HEAD)..HEAD -- <file> to review each modified filegit diff --cached and git diffgit show <commit-hash> for individual commits in the branchCreate a structured code review report with:
CODE_REVIEW_[YYYY-MM-DD_HH-MM-SS].md in repo rootExample filename: CODE_REVIEW_2026-01-27_14-30-22.md
After completing the review:
.worktrees/<branch-name>) when removing itFrame all feedback as questions, not commands. This encourages dialogue and respects the author's context.
❌ Don't write:
✅ Do write:
git merge-base to isolate branch-specific changes. Never comment on code that was changed in other branches.gtimeout or timeout. Continue review even if they fail.Auto-apply when working with Angular. Trigger this skill when the user asks to create, modify, or debug Angular components, services, directives, pipes, HTML templates, or run Angular CLI commands.
Auto-apply when working with Go (Golang). Trigger this skill when the user asks to create, modify, or debug Go code, HTTP handlers, middleware, CLI tools, or Go tests.
Auto-apply when working with Zig. Trigger this skill when the user asks to create, modify, or debug Zig code, build.zig scripts, or Zig tests.
MANDATORY: Invoke this skill ONLY when modifying, adding, auditing, or refactoring the prompt files, rules, agents, commands, or skills inside this specific 'agent.files' configuration repository. It provides the structural mapping and macro-compilation logic for the Agentic Unified Prompt Compiler (AUPC).
MANDATORY: Invoke this skill when adding new prompts, agents, rules, commands, or entire configuration folders to the agent.files repository. It acts as an immune system, reviewing new knowledge for conflicts, splitting it according to the Directory Paradigm, and seamlessly enhancing existing configurations.
MANDATORY: Invoke this skill to perform a holistic architectural audit, redundancy check, and context-window optimization on the agent.files repository. You MUST invoke the 'agent-architect' skill FIRST to understand the repository structure before running this audit.