This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
A VS Code extension that adds a ✨ button to the Source Control panel. Clicking it reads the git diff, pipes it to the local Claude CLI (claude -p), and writes the returned commit message into the SCM input box. The entire extension is one file: extension.js (~150 lines, plain CommonJS — no build step, no TypeScript, no dependencies).
npm run package # builds the .vsix into dist/ via vsce (the only script)There is no build, lint, or test setup — extension.js is shipped as-is. To test changes, install the packaged .vsix (Ctrl+Shift+P → Extensions: Install from VSIX…) or run the Extension Development Host from VS Code (F5).
The flow lives in the claudeCommitButton.generate command handler:
- Repo resolution — the
scm/titlemenu passes theSourceControlasarg; match it againstgit.repositoriesbyrootUri, else fall back to the first repo. The git API comes from the built-invscode.gitextension (getAPI(1)). - Diff selection — staged diff (
repo.diff(true)) first; if empty, fall back to the whole working tree (repo.diff(false)). Truncated toMAX = 6000chars before sending. - CLI invocation —
execFile(claudePath, args)with the diff written to stdin (not passed as an arg). The prompt goes over stdin; flags lock the CLI down:-p(print mode),--tools '',--strict-mcp-config,--setting-sources '',--no-session-persistence,--dangerously-skip-permissions. Model and effort come from settings. - Result is trimmed and assigned to
repo.inputBox.value.
resolveCli() → detectClaude() handles the Windows npm-shim problem, which is the main source of complexity:
- User-configured
cliPathsetting wins; otherwisewhere/which claude. - On Windows, npm installs three shims (
claude,claude.cmd,claude.ps1). Node'sexecFilecan't reliably spawn the extensionless shell script or.cmdand pipe stdin, so the code prefers the realclaude.exe— either found directly inwhereoutput, or derived from a shim's directory via the known npm layout (node_modules/@anthropic-ai/claude-code/bin/claude.exe). - Resolved path is memoized in
cachedCli(revalidated withfs.existsSync).
When editing detection logic, preserve this .exe-preference ordering — it's the fix for Claude-installed-under-WSL/Git-Bash and npm-shim cases documented in the README.
An unused-by-default buttonLocation setting can move the button inside the commit box using VS Code's proposed contribSourceControlInputBoxMenu API. This can't ship in the .vsix and needs manual local setup — see the README's "button inside the message box" section. Don't add the proposed API to the shipped package.json.