pre-commit-review is a reusable skill package for reviewing Git diffs before committing, pushing, or opening a pull request.
It is designed for agent workflows such as Codex- or Claude-style skill systems, where you want a structured, repeatable pre-commit quality gate instead of an ad hoc diff summary.
- English:
README.md - Simplified Chinese:
README.zh-CN.md
Translations should stay functionally aligned. If you update one version, update the others in the same change when possible.
- Reviews the most relevant diff source in priority order:
- user-provided diff
- staged changes
- unstaged changes
- branch vs. base branch
- Produces a consistent review format focused on:
- what changed
- hygiene issues
- intent
- logic shifts
- blast radius
- regression risk
- Returns a clear verdict:
SAFE_TO_COMMITSAFE_TO_COMMIT_WITH_NOTESDO_NOT_COMMIT
- Uses a read-only helper script to collect local Git context without mutating the repository
This repository is not an application or framework. It is a small, portable skill package that can be:
- published as a standalone open source repository
- copied into an existing skills collection
- adapted for local agent tooling that needs pre-commit review behavior
.
├── install.sh
├── SKILL.md
├── agents/
│ └── openai.yaml
├── references/
│ ├── output-examples.md
│ └── visual-output.md
├── scripts/
│ └── collect_diff_context.sh
└── tests/
├── collect_diff_context_test.sh
├── eval_contract_test.sh
├── install_agent_matrix_test.sh
├── output-eval.json
├── skill_contract_test.sh
├── trigger-eval.json
└── install_smoke_test.sh
Defines the skill itself:
- when it should be triggered
- how the diff source is resolved
- how large diffs are handled
- what review dimensions must be covered
- the required output template and verdict rules
A read-only helper script that gathers local repository context for the review workflow. It:
- detects whether the current directory is a Git repository
- prefers staged changes when present
- falls back to unstaged changes or branch-vs-base comparison
- reports diff stats, file lists, and status
- truncates oversized diffs safely when needed
It does not fetch, stage, reset, install, or modify files.
Contains optional guidance loaded only when needed, such as localized output examples and visual report formatting.
Provides lightweight agent metadata for environments that expose skills through an agent registry.
Installs this skill package into host-specific skills directories for supported AI coding agents.
Runs a small end-to-end installer smoke test against temporary directories.
From a clone of this repository, install globally for any supported agent:
./install.sh --agent codex
./install.sh --agent claude-code
./install.sh --agent gemini-cli
./install.sh --agent kiro-cliList every supported agent id and its project/global paths:
./install.sh --list-agentsDefaults:
- Global installs use the agent-specific global path shown by
--list-agents - Project installs use the agent-specific project path shown by
--list-agents --dir PATHoverrides both defaultsAGENT_SKILLS_DIRoverrides the global default for all agents- Dedicated overrides are also supported for existing integrations:
CODEX_SKILLS_DIR,CLAUDE_SKILLS_DIR,GEMINI_SKILLS_DIR,KIRO_SKILLS_DIR, andCODEX_HOME - Backward-compatible aliases are supported:
claude,gemini, andkiro
Useful flags:
--copycopies the skill into the target directory and is the default mode--linkcreates a symlink to this repository, which is useful for local development--projectinstalls into the agent's project-local skills directory--dir PATHoverrides the target skills directory--forcereplaces an existing non-managed target--dry-runprints what would happen without changing anything
Examples:
./install.sh --agent cursor --project
./install.sh --agent windsurf --link --project
./install.sh --agent github-copilot --dry-run
./install.sh kiro --dir .kiro/skillsThe skill resolves review input in this order:
- A diff explicitly provided by the user
- Staged changes in the current repository
- Unstaged changes if nothing is staged
- Current branch compared with a detected base branch
- If no diff is available, the skill asks for staged changes or a provided diff
When local repository access is available, the workflow prefers using scripts/collect_diff_context.sh as the source of truth for:
- diff source
- review boundaries
- changed file counts
- staged vs. unstaged notes
- untracked file warnings
Clone this repository, then run the installer for your host:
./install.sh codexor:
./install.sh --agent claude-code
./install.sh --agent gemini-cli
./install.sh --agent kiro-cliRestart the agent or start a new session after installing so it can discover the new skill.
Clone or copy this repository into the place where your agent runtime expects custom skills.
Example layout:
your-skills/
└── pre-commit-review/
├── SKILL.md
├── agents/
├── references/
└── scripts/
Then register or expose the skill according to your agent platform's skill-loading mechanism.
If you already maintain a larger skills repository, copy this directory in as one skill package and preserve the relative paths:
SKILL.mdscripts/collect_diff_context.shreferences/agents/openai.yaml
The helper script is referenced by the skill instructions, so the directory structure should remain intact unless you also update those references.
The expected output is an action-first, fast-scanning pre-commit review with:
- a verdict plus a one-line conclusion
- diff source
- review scope
- change scale
- priority findings with concrete fixes
- the minimum risk and test guidance needed to make a commit decision
The default review should answer three questions first:
- can this be committed now
- what must be fixed before commit
- what should be tested next
Only include deeper intent analysis, before/after logic detail, or extra supporting notes when they materially improve the review.
Final verdicts mean:
SAFE_TO_COMMIT: reviewed scope looks safe to commit nowSAFE_TO_COMMIT_WITH_NOTES: safe to commit now, but follow-up notes or review limits existDO_NOT_COMMIT: blocking issue found; do not commit as-is
This package is intentionally conservative:
- it avoids pretending to see local changes when no repository is available
- it distinguishes staged and unstaged review scope
- it warns about untracked files not present in
git diff - it treats large diffs as partial-review situations unless risky files are inspected
- This repository does not include the runtime that loads or executes the skill.
- The included installer covers common Codex, Claude Code, and Gemini CLI locations, but some local setups may still require
--diroverrides. - The helper script expects a working
gitexecutable in the environment. - The current repository itself may be used outside Git, but local diff collection only works inside a Git repository.
Contributions are best focused on:
- improving review heuristics
- tightening safety boundaries
- refining the output template
- making diff collection more robust across repository states
If you change script paths or repository layout, update SKILL.md accordingly.
If you update user-facing documentation, keep localized README files synchronized.
This project is licensed under the Apache License 2.0. See LICENSE.