Skip to content

minimike86/vscode-claude-commit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claude Commit

A VS Code extension that generates Conventional Commits messages from your staged changes by shelling out to the Claude Code CLI running on your own machine.

No API keys to configure, no extension settings to authenticate — if claude works in your terminal, this works in VS Code.


How it works

The extension adds a sparkle (✨) button to the Source Control title bar. When you click it:

  1. Find the repo. It talks to VS Code's built-in vscode.git extension via its public API to enumerate open repositories. If you have more than one, it asks which to target.
  2. Read the staged diff. It spawns git diff --staged in the repo root and captures stdout. If nothing is staged, it tells you and stops.
  3. Read recent history for style. It runs git log -10 --format=%s to grab the last ten commit subjects. These are fed to Claude as a style reference so the generated message matches your repo's voice (lowercase vs Title Case, scope conventions, etc.).
  4. Build a prompt. A fixed prompt template instructs Claude to produce a Conventional Commits message: <type>(<scope>): <subject>, imperative mood, ≤72-char subject, optional WHY body. The staged diff is appended at the bottom (truncated to maxDiffBytes if huge, so large refactors don't blow the prompt window). Any extraInstructions you've configured are inserted before the diff.
  5. Invoke the CLI. It spawns claude -p --output-format text with the prompt piped to stdin. On Windows, claude is typically a .cmd shim, so the spawn uses shell: true there; on macOS/Linux it spawns directly.
  6. Clean the output. Models occasionally wrap output in ``` fences or prepend Commit message: despite the prompt. A small stripWrapping pass removes those without being aggressive enough to chew real content.
  7. Drop it into the commit box. The cleaned message is written to repo.inputBox.value. You review, edit if needed, and commit normally — the extension never commits for you.

Errors at any step (CLI not found, non-zero exit, empty response) surface as VS Code notifications.

What it doesn't do

  • It doesn't read unstaged changes. Stage what you want described.
  • It doesn't call any Anthropic API directly. Everything goes through your local claude binary, so whatever auth/quotas/model that CLI is set up with is what gets used.
  • It doesn't commit. The generated text is placed in the input box only.
  • It doesn't store or transmit your diff anywhere except to the local CLI process.

Install

From a local build

Requires Node 18+, VS Code 1.85+, and the code CLI on PATH (Ctrl+Shift+P → "Shell Command: Install 'code' command in PATH").

npm run install:ext

The scripts/install.ps1 helper installs npm deps if missing, compiles TypeScript, packages a .vsix into dist/, and installs it into VS Code via code --install-extension. Reload the window afterwards.

Manually

npm install
npm run compile
npx @vscode/vsce package
code --install-extension claude-commit-0.1.0.vsix

Dev loop

Press F5 in VS Code to launch an Extension Development Host with the extension loaded — no install/reload cycle needed.


Use

  1. Open a Git repository in VS Code.
  2. Stage the changes you want to describe (Source Control panel → + next to each file).
  3. Click the ✨ sparkle in the Source Control title bar, or run Claude Commit: Generate commit message from the Command Palette.
  4. Wait a few seconds (a progress indicator appears in the SCM panel). The generated message lands in the commit input.
  5. Edit if you like, then commit normally.

Settings

Open Settings → search "Claude Commit":

Setting Default Description
claudeCommit.cliPath claude Path to the Claude Code CLI. Set this if claude isn't on the PATH VS Code sees (e.g. C:\Users\you\AppData\Roaming\npm\claude.cmd).
claudeCommit.maxDiffBytes 60000 Truncate the staged diff above this many bytes. Prevents huge refactors from blowing the model's prompt window.
claudeCommit.extraInstructions "" Free-form text appended to the prompt. Use for repo-specific conventions, e.g. "Prefix subjects with the JIRA ticket from the branch name."

Troubleshooting

"Could not run 'claude'." The CLI isn't on the PATH VS Code inherited. Either add it to PATH and restart VS Code, or set claudeCommit.cliPath to the absolute path of the binary/shim.

"No staged changes." Stage something first. The extension intentionally ignores unstaged work.

"Claude returned an empty response." Usually a transient CLI issue or a diff that confused the model. Try again, or shrink the diff (stage fewer files).

The message has the right idea but the wrong style. Add a couple more commits in your preferred style, or set claudeCommit.extraInstructions to spell out the convention.

Multi-root workspace picks the wrong repo. When more than one repository is open, the extension prompts you to choose. Pick the right one from the Quick Pick.


Project layout

src/extension.ts       # activate(), command registration, all logic
scripts/install.ps1    # build + package + install helper
package.json           # extension manifest (commands, menus, settings)
.vscodeignore          # files excluded from the packaged .vsix

The whole extension is a single file (~200 lines). It registers one command (claudeCommit.generate), contributes one SCM-title menu item, and exposes three settings. That's it.


License

MIT. See LICENSE.

About

A VS Code extension that generates Conventional Commits messages from your staged changes by shelling out to the Claude Code CLI running on your own machine.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors