Git review before commit

VerifiedCaution

Review the working tree before committing: run svelte-check, inspect all changes, classify modifications, and compose a commit message matching repo style.

Sby Skills Guide Bot
DevelopmentIntermediate
8/7/2026
Claude CodeCursorCodex
#git#pre-commit#commit-hygiene#code-review#secrets-check

Recommended for

Automated summary

Reviews the working tree before a Git commit: verifies type-checking, classifies every change, and drafts a message matching the repository's style.

Strengths

  • Runs git status, both diffs, and git log in parallel for a fast full inventory
  • Classifies each change block (intended, refactor side-effect, pre-existing, stranger) and forces a stop on anything unexplained
  • Checks secret hygiene (keys, .env files, absolute paths) before committing
  • Explicitly forbids risky moves: amending pushed commits, force-push, --no-verify, empty commits

Limitations

  • Assumes a Svelte project: the mandatory svelte-check step relies on the verify-svelte-check skill
  • Secret detection is a manual read of the diff, with no dedicated scanning tool
  • Does not cover Git repair work such as merge conflicts, history rewriting, or recovering lost commits
When to use it

Use it right before committing, pushing, or opening a pull request so unrelated files and secrets don't slip into the commit.

When not to use it

Skip it for resolving merge conflicts, rewriting history, or recovering lost commits, which need a Git repair skill instead.

Security analysis

Caution
Quality score90/100

The skill is not malicious and includes good safeguards against force-pushing, amending published commits, bypassing hooks, and committing secrets. However, it directs agents to use powerful git/network/build tools and includes guidance that can delete untracked files or discard local changes, so it warrants caution rather than a clean safe rating.

Findings
  • •Instructs running git, gh, pnpm, and svelte-check commands without declaring allowed-tools, so execution permissions may exceed metadata intent.
  • •Step 2 tells the agent to delete unexpected untracked files, which can cause data loss if classification is wrong.
  • •Step 3 suggests `git checkout -- file` to revert changes, which irreversibly discards local modifications.
  • •Optional PR flow uses `gh pr create` and `pnpm build`, involving network/auth and build execution; legitimate but powerful.
How this analysis is made

Examples

Review before committing a refactor
The refactor is finished — review the working tree and commit only the changes to the FormField components, leaving anything unrelated out.
Open a pull request
Commit this work and open a PR to main with gh, showing me the list of commits it includes.
Sanity check the diff
Before I commit, check the staged and unstaged diffs for anything unrelated or any secrets I might be about to include.

name: git-review-before-commit description: "Review the working tree before committing to Git. Triggers on: the user asks to commit or push, a large task is complete, or a PR is about to be created. Rules: ensure svelte-check passes (see the verify-svelte-check skill), use git status to inspect all files, use git diff for staged and unstaged changes, classify pre-existing versus new changes, match the repo style (see git log --oneline -10), do not stage irrelevant files, do not commit secrets, do not amend, and do not force-push."

Skill: Git review before commit

Pre-commit checklist

Run these in parallel where independent:

git status
git diff --staged
git diff
git log --oneline -10

Steps

1. Run svelte-check first

See verify-svelte-check skill. Never commit before type-check passes.

2. git status — full inventory

  • Confirm which files are staged vs unstaged
  • Spot any file NOT related to the task — investigate or revert
  • Spot any unexpected untracked file (test scaffolds, temp files, .local files, dumps) — delete or .gitignore, don't commit

3. git diff --staged + git diff

Read all changes line by line. Classify each block:

  • Intended: change addresses the user's request
  • Side-effect from refactor: not directly requested but follows from the intended change
  • Pre-existing: file was modified before this session — confirm not accidentally staged
  • Stranger: change that doesn't fit either category. STOP, investigate.

For each stranger block:

  • Revert with git checkout -- file if it's a scratch or accidental edit
  • If legitimate, mention in commit message body

4. Stage intentionally

Use git add <specific-files> rather than git add . / git add -A. Separate un-related changes into separate commits.

5. Inspect recent commits for style

git log --oneline -10

Sample repo style (from this codebase):

  • Short imperative subject (~50 chars)
  • Lowercase first letter
  • No conventional-commits like feat: / fix: unless the repo uses them — verify against git log
  • Multi-paragraph body if change has nuance, blank line between subject and body

Match style. Don't introduce a "Co-authored-by … Claude / model-name" footer unless the repo convention shows one in git log.

6. Compose commit message

Single-line example:

remove dead exports and unused props from admin form components

Multi-line example (only if nuance can't fit on one line):

remove dead exports and unused props from admin form components

- drop `placeholder`/`hint` props from FormField (no call site passes them)
- drop `confirmLabel`/`cancelLabel` props from ConfirmDialog (always default)
- drop `variant` prop from Header (always 'public')
- revert recent bind:value refactor per AGENTS.md bug #4

7. Commit (separate from push)

git commit -m "..."

Do NOT push unless the user explicitly asks.

8. (Optional) Make a PR with gh

Only when user asks. Before opening:

  • git log --oneline origin/main..HEAD to list commits in PR
  • Confirm the diff still builds: pnpm build
  • Open with gh pr create --base main --title "..." --body "..."
  • Return the PR URL

Forbidden actions

Per repo rules + safe defaults:

  • git commit --amend on already-pushed commits
  • git push --force / --force-with-lease without explicit user request
  • git config modification
  • Empty commits
  • Skipping hooks (--no-verify)
  • Interactive -i flag

Secret hygiene

Inspect the diff for:

  • API keys, tokens, JWT, secrets in env-style
  • Absolute paths exposing username (/Users/<name>/ / C:\Users\...) in source beyond what's already in repo
  • Database credentials, AWS keys, private IPs
  • .env files (they should be gitignored — verify)

If found, don't commit. Strip and ask user.

Final summary

After commit, report:

Committed: <hash-snip> "<subject>"
Files changed: <count>
Status: clean (or: working tree clean)

If asked to push:

Pushed to <remote>:<branch>
Result: <hash-snip>..<hash-snip>  <branch> -> origin/<branch>

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/git-review-before-commit-msih94xp/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/git-review-before-commit-msih94xp' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/git-review-before-commit-msih94xp/download' --output '.skill-downloads/git-review-before-commit-msih94xp/SKILL.md.part' && mv '.skill-downloads/git-review-before-commit-msih94xp/SKILL.md.part' '.skill-downloads/git-review-before-commit-msih94xp/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/git-review-before-commit-msih94xp/SKILL.md' && test -s '.skill-downloads/git-review-before-commit-msih94xp/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/git-review-before-commit' && cp -R '.skill-downloads/git-review-before-commit-msih94xp' '.claude/skills/git-review-before-commit'

Cursor
test -f '.skill-downloads/git-review-before-commit-msih94xp/SKILL.md' && test -s '.skill-downloads/git-review-before-commit-msih94xp/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/git-review-before-commit' && cp -R '.skill-downloads/git-review-before-commit-msih94xp' '.cursor/skills/git-review-before-commit'

Codex
test -f '.skill-downloads/git-review-before-commit-msih94xp/SKILL.md' && test -s '.skill-downloads/git-review-before-commit-msih94xp/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/git-review-before-commit' && cp -R '.skill-downloads/git-review-before-commit-msih94xp' '.agents/skills/git-review-before-commit'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/git-review-before-commit-msih94xp'

openskills read 'git-review-before-commit-msih94xp'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/git-review-before-commit-msih94xp/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills