Claude Commit Guard
Claude Commit Guard is a Visual Studio Code extension that runs a Claude Code review on your staged Git changes before you commit.
It is designed for developers who want a practical, senior-level review of their staged diff directly inside VS Code, without using an Anthropic API key or buying separate API credits. The extension uses the local Claude Code CLI, so it works through your existing Claude Code authentication.
Features
Claude Commit Guard reviews your staged Git diff and produces a structured Markdown report.
The review includes:
- Commit verdict:
SAFE_TO_COMMIT, COMMIT_WITH_CAUTION, or DO_NOT_COMMIT
- Executive summary
- Changed areas detected
- Blocking issues
- Recommended improvements
- Security and privacy notes
- Backward compatibility notes
- Edge cases to verify
- Tests to add
- Manual QA checklist
- Suggested commit message
- Confidence level
- English review followed by Hebrew review
- Visual separators between sections for easier reading
In addition to the written review, every run produces:
- A Code Score (overall 0–100, plus Security, Performance, Maintainability, and Readability sub-scores)
- A Review Summary with counts of Critical issues, Warnings, and Suggestions, and an estimated fix time
- Cost statistics (reviews today, cost, and token usage)
- Diagnostics for each finding, shown in the editor and Problems panel
- AI Fix quick-fixes to explain or apply a suggested fix directly from a finding
Code Score and Review Summary
Each review ends with a machine-readable summary that the extension renders into:
- A score banner at the top of the review document
- A "Last Review" card in the Source Control panel
The score banner looks like this:
Quality Score: 92/100
| Category | Score | |
| Security | 95 | ✔ |
| Performance | 88 | ✔ |
| Maintainability | 70 | ⚠ |
| Readability | 90 | ✔ |
Review Summary: Critical: 0 · Warnings: 2 · Suggestions: 11 · Estimated fix time: 12 min
Icons are derived from the score: ✔ for 85 and above, ⚠ for 60–84, ✖ below 60.
Cost Statistics and Dashboard
The review runs the Claude Code CLI with JSON output, so the extension can capture cost and token usage for each review.
Statistics are stored locally and aggregated per day. You can see them in two places:
- The "Last Review" card and cost line in the Source Control panel
- The Dashboard, a tab inside the Claude Commit Guard panel with cards for reviews today, cost today, all-time issues (Critical / Warnings / Suggestions), all-time reviews and cost, plus a recent-activity table
The panel has two tabs at the top — Guard and Dashboard. Switch to the Dashboard tab, use the panel button Open Dashboard, or run the command:
Claude Commit Guard: Open Dashboard
The dashboard renders inside the panel, so it never opens a separate editor tab.
One-Click Actions
Select code in any file, right-click, and open the Claude Guard submenu to run a focused task on the selection (or the whole file when nothing is selected):
- Explain
- Review
- Optimize
- Find Bugs
- Add Docs
- Generate Tests
- Refactor
Each action opens the result as a Markdown preview. These actions do not edit files or run commands.
Project Knowledge
You can give the extension persistent context about your project so it is included with every review.
Use the panel button Project Knowledge or the command:
Claude Commit Guard: Edit Project Knowledge
This creates and opens .claude-guard/project-knowledge.md in your repository. Anything you write there (stack, architecture, coding standards, conventions) is sent with every review. For example:
This project uses .NET 8, SQL Server, the Repository Pattern, and Clean Architecture.
Follow the team's Israeli Post coding standards.
Diagnostics and AI Fix
Findings from a review are shown as diagnostics (squiggles) in the editor and in the Problems panel, anchored to the relevant file and line.
On a finding, the lightbulb / Quick Fix menu offers:
- Explain — opens a Claude explanation of the finding and how to address it
- Apply suggested fix — replaces the affected lines with the fix proposed in the review (when available)
Apply suggested fix is safe by design. When the review completes, the extension records a snapshot of the exact lines each finding points to. Before applying a fix it re-checks those lines against the snapshot. If the file changed since the review (so the line numbers may no longer match), the fix is not applied and you are asked to run a new review instead. This prevents a fix from being written to the wrong place.
Diagnostics can be turned on or off with the panel button Toggle Diagnostics, the command Claude Commit Guard: Toggle Review Diagnostics, or the claudeCommitGuard.showDiagnostics setting.
Compatibility and Resilience
- Older Claude CLI versions — reviews prefer JSON output to capture cost and tokens, but if the installed CLI does not support
--output-format json, the extension automatically retries with text output and the review still runs normally (without cost stats).
- Malformed model output — the machine-readable data block is parsed defensively. If Claude returns partial or invalid JSON, or omits fields such as
fix, the review still opens and the verdict is recovered from the review text.
Source Control Panel
Claude Commit Guard adds a dedicated panel inside the VS Code Source Control view.
From the panel you can:
- Run a review manually
- Enable or disable automatic review
- Toggle review diagnostics
- Open the dashboard
- Edit project knowledge
- Open extension settings
- See the last review's score, summary, and today's cost
- See current timeout, debounce, cooldown, max diff size, Claude CLI path, and last status
Manual Review Flow
The recommended manual flow is:
git add .
Then run:
Claude Commit Guard: Review Staged Changes
The extension will read:
git diff --cached --no-ext-diff
Then it will send the staged diff to Claude Code CLI and open the review as a Markdown document inside VS Code.
Automatic Review
Claude Commit Guard can automatically run a review after you stage changes.
Automatic review is disabled by default.
When enabled, the extension watches the Git index file and starts a review after staged changes are detected.
The automatic review includes safety controls:
- Debounce delay after staging
- Cooldown between automatic reviews
- Diff hash check to avoid reviewing the same diff repeatedly
- Maximum staged diff size limit
- Automatic skip when possible secrets are detected
- Manual review remains available for large or sensitive diffs
Requirements
Claude Commit Guard requires:
- Visual Studio Code
- Git
- Claude Code CLI installed locally
- Claude Code authenticated on your machine
The extension does not require an Anthropic API key.
Installing Claude Code CLI
On Windows PowerShell, Claude Code can be installed with:
irm https://claude.ai/install.ps1 | iex
After installation, verify that Claude Code is available:
claude --version
If claude is not recognized, make sure the Claude Code installation directory is included in your system PATH.
On some Windows installations, Claude Code may be installed under:
C:\Users\<YOUR_USER>\.local\bin\claude.exe
If needed, configure the full path in VS Code settings:
"claudeCommitGuard.claudeExecutablePath": "C:\\Users\\<YOUR_USER>\\.local\\bin\\claude.exe"
Extension Settings
Claude Commit Guard contributes the following settings:
{
"claudeCommitGuard.claudeExecutablePath": "claude",
"claudeCommitGuard.claudeModel": "",
"claudeCommitGuard.reviewTimeoutMs": 300000,
"claudeCommitGuard.maxTurns": 1,
"claudeCommitGuard.autoReviewOnStage": false,
"claudeCommitGuard.autoReviewDebounceMs": 3000,
"claudeCommitGuard.autoReviewCooldownMs": 30000,
"claudeCommitGuard.autoReviewMaxDiffChars": 80000,
"claudeCommitGuard.showDiagnostics": true
}
claudeCommitGuard.claudeExecutablePath
Path to the Claude Code CLI executable.
Default:
"claude"
Use this when Claude Code is available through your PATH.
For a custom Windows path:
"C:\\Users\\<YOUR_USER>\\.local\\bin\\claude.exe"
claudeCommitGuard.claudeModel
Optional Claude Code model alias or full model name.
Leave empty to use the Claude Code default.
claudeCommitGuard.reviewTimeoutMs
Maximum time to wait for Claude Code review.
Default:
300000
That equals five minutes.
claudeCommitGuard.maxTurns
Maximum number of Claude Code turns for the review.
Default:
1
claudeCommitGuard.autoReviewOnStage
Enable or disable automatic review after staging changes.
Default:
false
claudeCommitGuard.autoReviewDebounceMs
Delay after a staging event before automatic review starts.
Default:
3000
claudeCommitGuard.autoReviewCooldownMs
Minimum time between automatic reviews.
Default:
30000
claudeCommitGuard.autoReviewMaxDiffChars
Maximum staged diff size for automatic review.
Default:
80000
Manual review still works for larger diffs.
claudeCommitGuard.showDiagnostics
Show review findings as diagnostics (squiggles) in the editor and Problems panel.
Default:
true
Privacy and Security
Claude Commit Guard sends your staged Git diff to the local Claude Code CLI.
Before sending the diff, the extension scans for common secret patterns such as:
password
apiKey
secret
- private keys
- connection strings
If possible secrets are detected:
- Manual review asks for confirmation before continuing.
- Automatic review is skipped.
This detection is best-effort only. You are responsible for reviewing what you stage before sending it to Claude Code.
The extension does not use an Anthropic API key. It stores data only on your machine:
- Generated review and action results are written as Markdown files in the extension's global storage so they can be reopened.
- Review statistics (counts, cost, tokens per day) are kept in VS Code global state for the dashboard.
- Project knowledge is stored in
.claude-guard/project-knowledge.md inside your repository.
None of this data is sent anywhere except the staged diff (and your project knowledge) that goes to your local Claude Code CLI during a review.
Known Limitations
Claude Commit Guard is a diff-based reviewer.
It reviews only the staged changes and may not fully understand:
- Runtime behavior outside the diff
- External service contracts
- Database schema assumptions
- Build-time generated files
- Hidden dependencies
- Files excluded from the staged diff
For critical changes, use Claude Commit Guard as an additional review layer, not as a replacement for human review, tests, CI, or security checks.
Recommended Workflow
For regular work:
git add .
Run:
Claude Commit Guard: Review Staged Changes
Review the generated Markdown report.
Fix issues if needed.
Then commit:
git commit -m "your commit message"
For automatic review, enable:
"claudeCommitGuard.autoReviewOnStage": true
Development
Install dependencies:
npm install
Compile:
npm run compile
Run the extension in development mode:
F5
Package locally:
npm run package
This creates a .vsix file that can be installed manually in VS Code.
Release Notes
1.1.0
- Code Score (overall plus Security, Performance, Maintainability, Readability)
- Review Summary with Critical / Warnings / Suggestions counts and estimated fix time
- Cost statistics (reviews, cost, and tokens) captured from the Claude Code CLI
- Dashboard tab with daily and all-time stats
- Findings shown as diagnostics in the editor and Problems panel
- AI Fix quick-fixes to explain or apply a suggested fix
- One-click editor actions: Explain, Review, Optimize, Find Bugs, Add Docs, Generate Tests, Refactor
- Project Knowledge file injected into every review
- Status bar verdict, suggested commit message prefill, and reliable Markdown preview
- Reviews now open as named files in rendered Markdown preview
1.0.1
Initial release.
- Manual review of staged Git changes
- Claude Code CLI integration
- Source Control panel
- Optional automatic review after staging
- Bilingual English/Hebrew review output
- Visual separators between review sections
- Secret detection safety check
- Markdown review output